-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathBioJava:CookBook3:MSA.html
More file actions
164 lines (108 loc) · 4.96 KB
/
BioJava:CookBook3:MSA.html
File metadata and controls
164 lines (108 loc) · 4.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!DOCTYPE html>
<!--
Original Design: Spectral by HTML5 UP
html5up.net | @n33co
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
Jekyll build mod
-->
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>BioJava:CookBook3:MSA</title>
<meta name="description" content="How to create a Multiple Sequence Alignment in BioJava">
<!--[if lte IE 8]><script src="/js/ie/html5shiv.js"></script><![endif]-->
<link rel="canonical" href="http://biojava.org/wikis/BioJava:CookBook3:MSA.html">
<link rel="stylesheet" href="/css/main.css" />
<!--[if lte IE 8]><link rel="stylesheet" href="/css/ie8.css" /><![endif]-->
<!--[if lte IE 9]><link rel="stylesheet" href="/css/ie9.css" /><![endif]-->
<link rel="alternate" type="application/rss+xml" title="BioJava" href="http://biojava.org/feed.xml">
</head>
<body>
<!-- Page Wrapper -->
<div id="page-wrapper">
<!-- Header -->
<header id="header">
<h1><a href="/index.html">BioJava</a></h1>
<nav id="nav">
<ul>
<li class="special">
<a href="#menu" class="menuToggle"><span>Menu</span></a>
<div id="menu">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="/elements.html">Elements</a></li>
<li><a href="/generic.html">Generic</a></li>
<li><a href="/wiki.html">Wiki Pages</a></li>
<li><a href="#">Sign Up</a></li>
<li><a href="#">Log In</a></li>
<li><a href="/feed.xml"
class="icon fa-feed"> RSS Feed</a></li>
</ul>
</div>
</li>
</ul>
</nav>
</header>
<h1 id="how-to-create-a-multiple-sequence-alignment-in-biojava">How to create a Multiple Sequence Alignment in BioJava</h1>
<java>
package org.biojava.nbio.alignment;
import java.net.URL; import java.util.ArrayList; import java.util.List;
import org.biojava.nbio.alignment.Alignments; import
org.biojava.nbio.alignment.template.Profile; import
org.biojava.nbio.core.sequence.ProteinSequence; import
org.biojava.nbio.core.sequence.compound.AminoAcidCompound; import
org.biojava.nbio.core.sequence.io.FastaReaderHelper; import
org.biojava.nbio.core.util.ConcurrencyTools;
public class CookbookMSA {
` public static void main(String[] args) {`
` String[] ids = new String[] {"Q21691", "A8WS47", "O48771"};`
` try {`
` multipleSequenceAlignment(ids);`
` } catch (Exception e){`
` e.printStackTrace();`
` }`
` }`
` private static void multipleSequenceAlignment(String[] ids) throws Exception {`
` List`<proteinsequence>` lst = new ArrayList`<proteinsequence>`();`
` for (String id : ids) {`
` lst.add(getSequenceForId(id));`
` }`
` Profile`<ProteinSequence, AminoAcidCompound>` profile = Alignments.getMultipleSequenceAlignment(lst);`
` System.out.printf("Clustalw:%n%s%n", profile);`
` ConcurrencyTools.shutdown();`
` }`
` private static ProteinSequence getSequenceForId(String uniProtId) throws Exception {`
` URL uniprotFasta = new URL(String.format("`[`http://www.uniprot.org/uniprot/%s.fasta`](http://www.uniprot.org/uniprot/%s.fasta)`", uniProtId));`
` ProteinSequence seq = FastaReaderHelper.readFastaProteinSequence(uniprotFasta.openStream()).get(uniProtId);`
` System.out.printf("id : %s %s%n%s%n", uniProtId, seq, seq.getOriginalHeader());`
` return seq;`
` }`
}
</proteinsequence></proteinsequence></java>
<!-- Footer -->
<footer id="footer">
<ul class="icons">
<li><a target="_blank" href="https://github.com/biojava" class="icon fa-github"
><span class="label">github</span></a></li>
</ul>
<ul class="copyright">
<li>©
2000,
2016
BioJava</li>
<li>Design: <a href="http://html5up.net" target="_blank">HTML5 UP</a></li>
<li>Built with: <a href="http://jekyllrb.com" target="_blank">Jekyll</a></li>
</ul>
</footer>
<!-- Scripts -->
<script src="js/jquery.min.js"></script>
<script src="js/jquery.scrollex.min.js"></script>
<script src="js/jquery.scrolly.min.js"></script>
<script src="js/skel.min.js"></script>
<script src="js/util.js"></script>
<!--[if lte IE 8]><script src="js/ie/respond.min.js"></script><![endif]-->
<script src="js/main.js"></script>
</div>
</body>
</html>