@@ -23,29 +23,29 @@ import org.biojava.nbio.core.sequence.io.FastaReaderHelper;
2323
2424public class CookbookAlignPairGlobal {
2525
26- ` public static void main (String [] args ) {`
27- ` String [] ids = new String [] {" Q21691" , " Q21495" , " O48771" };`
28- ` try {`
29- ` alignPairGlobal(ids[0 ], ids[1 ]);`
30- ` } catch (Exception e){`
31- ` e. printStackTrace();`
32- ` }`
33- ` }`
34-
35- ` private static void alignPairGlobal (String id1 , String id2 ) throws Exception {`
36- ` ProteinSequence s1 = getSequenceForId(id1), s2 = getSequenceForId(id2);`
37- ` SubstitutionMatrix ` < AminoAcidCompound > ` matrix = new SimpleSubstitutionMatrix ` <AminoAcidCompound >` ();`
38- ` SequencePair ` < ProteinSequence , AminoAcidCompound > ` pair = Alignments . getPairwiseAlignment(s1, s2,`
39- ` PairwiseSequenceAlignerType . GLOBAL , new SimpleGapPenalty (), matrix);`
40- ` System . out. printf(" %n%s vs %s%n%s" , pair. getQuery(). getAccession(), pair. getTarget(). getAccession(), pair);`
41- ` }`
42-
43- ` private static ProteinSequence getSequenceForId (String uniProtId ) throws Exception {`
44- ` URL uniprotFasta = new URL (String . format(" `[` http://www.uniprot.org/uniprot/%s.fasta` ](http://www.uniprot.org/uniprot/%s.fasta)` " , uniProtId));`
45- ` ProteinSequence seq = FastaReaderHelper . readFastaProteinSequence(uniprotFasta. openStream()). get(uniProtId);`
46- ` System . out. printf(" id : %s %s%n%s%n" , uniProtId, seq, seq. getOriginalHeader());`
47- ` return seq;`
48- ` }`
26+ public static void main (String [] args ) {
27+ String [] ids = new String [] {" Q21691" , " Q21495" , " O48771" };
28+ try {
29+ alignPairGlobal(ids[0 ], ids[1 ]);
30+ } catch (Exception e){
31+ e. printStackTrace();
32+ }
33+ }
34+
35+ private static void alignPairGlobal (String id1 , String id2 ) throws Exception {
36+ ProteinSequence s1 = getSequenceForId(id1), s2 = getSequenceForId(id2);
37+ SubstitutionMatrix<AminoAcidCompound > matrix = new SimpleSubstitutionMatrix<AminoAcidCompound > ();
38+ SequencePair<ProteinSequence , AminoAcidCompound > pair = Alignments . getPairwiseAlignment(s1, s2,
39+ PairwiseSequenceAlignerType . GLOBAL , new SimpleGapPenalty (), matrix);
40+ System . out. printf(" %n%s vs %s%n%s" , pair. getQuery(). getAccession(), pair. getTarget(). getAccession(), pair);
41+ }
42+
43+ private static ProteinSequence getSequenceForId (String uniProtId ) throws Exception {
44+ URL uniprotFasta = new URL (String . format(" [ http://www.uniprot.org/uniprot/%s.fasta](http://www.uniprot.org/uniprot/%s.fasta)" , uniProtId));
45+ ProteinSequence seq = FastaReaderHelper . readFastaProteinSequence(uniprotFasta. openStream()). get(uniProtId);
46+ System . out. printf(" id : %s %s%n%s%n" , uniProtId, seq, seq. getOriginalHeader());
47+ return seq;
48+ }
4949
5050}
5151
@@ -69,29 +69,29 @@ import org.biojava.nbio.core.sequence.io.FastaReaderHelper;
6969
7070public class CookbookAlignPairLocal {
7171
72- ` public static void main (String [] args ) {`
73- ` String [] ids = new String [] {" Q21691" , " Q21495" , " O48771" };`
74- ` try {`
75- ` alignPairLocal(ids[0 ], ids[1 ]);`
76- ` } catch (Exception e){`
77- ` e. printStackTrace();`
78- ` }`
79- ` }`
80-
81- ` private static void alignPairLocal (String id1 , String id2 ) throws Exception {`
82- ` ProteinSequence s1 = getSequenceForId(id1), s2 = getSequenceForId(id2);`
83- ` SubstitutionMatrix ` < AminoAcidCompound > ` matrix = new SimpleSubstitutionMatrix ` <AminoAcidCompound >` ();`
84- ` SequencePair ` < ProteinSequence , AminoAcidCompound > ` pair = Alignments . getPairwiseAlignment(s1, s2,`
85- ` PairwiseSequenceAlignerType . LOCAL , new SimpleGapPenalty (), matrix);`
86- ` System . out. printf(" %n%s vs %s%n%s" , pair. getQuery(). getAccession(), pair. getTarget(). getAccession(), pair);`
87- ` }`
88-
89- ` private static ProteinSequence getSequenceForId (String uniProtId ) throws Exception {`
90- ` URL uniprotFasta = new URL (String . format(" `[` http://www.uniprot.org/uniprot/%s.fasta`](http://www.uniprot.org/uniprot/%s.fasta)` " , uniProtId));`
91- ` ProteinSequence seq = FastaReaderHelper . readFastaProteinSequence(uniprotFasta. openStream()). get(uniProtId);`
92- ` System . out. printf(" id : %s %s%n%s%n" , uniProtId, seq, seq. getOriginalHeader());`
93- ` return seq;`
94- ` }`
72+ public static void main (String [] args ) {
73+ String [] ids = new String [] {" Q21691" , " Q21495" , " O48771" };
74+ try {
75+ alignPairLocal(ids[0 ], ids[1 ]);
76+ } catch (Exception e){
77+ e. printStackTrace();
78+ }
79+ }
80+
81+ private static void alignPairLocal (String id1 , String id2 ) throws Exception {
82+ ProteinSequence s1 = getSequenceForId(id1), s2 = getSequenceForId(id2);
83+ SubstitutionMatrix<AminoAcidCompound > matrix = new SimpleSubstitutionMatrix<AminoAcidCompound > ();
84+ SequencePair<ProteinSequence , AminoAcidCompound > pair = Alignments . getPairwiseAlignment(s1, s2,
85+ PairwiseSequenceAlignerType . LOCAL , new SimpleGapPenalty (), matrix);
86+ System . out. printf(" %n%s vs %s%n%s" , pair. getQuery(). getAccession(), pair. getTarget(). getAccession(), pair);
87+ }
88+
89+ private static ProteinSequence getSequenceForId (String uniProtId ) throws Exception {
90+ URL uniprotFasta = new URL (String . format(" http://www.uniprot.org/uniprot/%s.fasta" , uniProtId));
91+ ProteinSequence seq = FastaReaderHelper . readFastaProteinSequence(uniprotFasta. openStream()). get(uniProtId);
92+ System . out. printf(" id : %s %s%n%s%n" , uniProtId, seq, seq. getOriginalHeader());
93+ return seq;
94+ }
9595
9696}
9797
@@ -121,35 +121,35 @@ import org.biojava.nbio.core.util.ConcurrencyTools;
121121
122122public class CookbookAlignAllGlobal {
123123
124- ` public static void main (String [] args ) {`
125- ` String [] ids = new String [] {" Q21691" , " Q21495" , " O48771" };`
126- ` try {`
127- ` alignAllGlobal(ids);`
128- ` } catch (Exception e){`
129- ` e. printStackTrace();`
130- ` }`
131- ` }`
132-
133- ` private static void alignAllGlobal (String [] ids ) throws Exception {`
134- ` List ` < ProteinSequence > ` lst = new ArrayList ` <ProteinSequence >` ();`
135- ` for (String id : ids) {`
136- ` lst. add(getSequenceForId(id));`
137- ` }`
138- ` SubstitutionMatrix ` < AminoAcidCompound > ` matrix = new SimpleSubstitutionMatrix ` <AminoAcidCompound >` ();`
139- ` List ` < SequencePair<ProteinSequence , AminoAcidCompound > ` > alig = Alignments . getAllPairsAlignments(lst,`
140- ` PairwiseSequenceAlignerType . GLOBAL , new SimpleGapPenalty (), matrix);`
141- ` for (SequencePair ` < ProteinSequence , AminoAcidCompound > ` pair : alig) {`
142- ` System . out. printf(" %n%s vs %s%n%s" , pair. getQuery(). getAccession(), pair. getTarget(). getAccession(), pair);`
143- ` }`
144- ` ConcurrencyTools . shutdown();`
145- ` }`
146-
147- ` private static ProteinSequence getSequenceForId (String uniProtId ) throws Exception {`
148- ` URL uniprotFasta = new URL (String . format(" `[` http://www.uniprot.org/uniprot/%s.fasta`](http://www.uniprot.org/uniprot/%s.fasta)` " , uniProtId));`
149- ` ProteinSequence seq = FastaReaderHelper . readFastaProteinSequence(uniprotFasta. openStream()). get(uniProtId);`
150- ` System . out. printf(" id : %s %s%n%s%n" , uniProtId, seq, seq. getOriginalHeader());`
151- ` return seq;`
152- ` }`
124+ public static void main (String [] args ) {
125+ String [] ids = new String [] {" Q21691" , " Q21495" , " O48771" };
126+ try {
127+ alignAllGlobal(ids);
128+ } catch (Exception e){
129+ e. printStackTrace();
130+ }
131+ }
132+
133+ private static void alignAllGlobal (String [] ids ) throws Exception {
134+ List<ProteinSequence > lst = new ArrayList<ProteinSequence > ();
135+ for (String id : ids) {
136+ lst. add(getSequenceForId(id));
137+ }
138+ SubstitutionMatrix<AminoAcidCompound > matrix = new SimpleSubstitutionMatrix<AminoAcidCompound > ();
139+ List<SequencePair<ProteinSequence , AminoAcidCompound > > alig = Alignments . getAllPairsAlignments(lst,
140+ PairwiseSequenceAlignerType . GLOBAL , new SimpleGapPenalty (), matrix);
141+ for (SequencePair<ProteinSequence , AminoAcidCompound > pair : alig) {
142+ System . out. printf(" %n%s vs %s%n%s" , pair. getQuery(). getAccession(), pair. getTarget(). getAccession(), pair);
143+ }
144+ ConcurrencyTools . shutdown();
145+ }
146+
147+ private static ProteinSequence getSequenceForId (String uniProtId ) throws Exception {
148+ URL uniprotFasta = new URL (String . format(" http://www.uniprot.org/uniprot/%s.fasta" , uniProtId));
149+ ProteinSequence seq = FastaReaderHelper . readFastaProteinSequence(uniprotFasta. openStream()). get(uniProtId);
150+ System . out. printf(" id : %s %s%n%s%n" , uniProtId, seq, seq. getOriginalHeader());
151+ return seq;
152+ }
153153
154154}
155155
@@ -176,35 +176,35 @@ import org.biojava.nbio.core.util.ConcurrencyTools;
176176
177177public class CookbookAlignAllLocal {
178178
179- ` public static void main (String [] args ) {`
180- ` String [] ids = new String [] {" Q21691" , " Q21495" , " O48771" };`
181- ` try {`
182- ` alignAllLocal(ids);`
183- ` } catch (Exception e){`
184- ` e. printStackTrace();`
185- ` }`
186- ` }`
187-
188- ` private static void alignAllLocal (String [] ids ) throws Exception {`
189- ` List ` < ProteinSequence > ` lst = new ArrayList ` <ProteinSequence >` ();`
190- ` for (String id : ids) {`
191- ` lst. add(getSequenceForId(id));`
192- ` }`
193- ` SubstitutionMatrix ` < AminoAcidCompound > ` matrix = new SimpleSubstitutionMatrix ` <AminoAcidCompound >` ();`
194- ` List ` < SequencePair<ProteinSequence , AminoAcidCompound > ` > alig = Alignments . getAllPairsAlignments(lst,`
195- ` PairwiseSequenceAlignerType . LOCAL , new SimpleGapPenalty (), matrix);`
196- ` for (SequencePair ` < ProteinSequence , AminoAcidCompound > ` pair : alig) {`
197- ` System . out. printf(" %n%s vs %s%n%s" , pair. getQuery(). getAccession(), pair. getTarget(). getAccession(), pair);`
198- ` }`
199- ` ConcurrencyTools . shutdown();`
200- ` }`
201-
202- ` private static ProteinSequence getSequenceForId (String uniProtId ) throws Exception {`
203- ` URL uniprotFasta = new URL (String . format(" `[` http://www.uniprot.org/uniprot/%s.fasta`](http://www.uniprot.org/uniprot/%s.fasta)` " , uniProtId));`
204- ` ProteinSequence seq = FastaReaderHelper . readFastaProteinSequence(uniprotFasta. openStream()). get(uniProtId);`
205- ` System . out. printf(" id : %s %s%n%s%n" , uniProtId, seq, seq. getOriginalHeader());`
206- ` return seq;`
207- ` }`
179+ public static void main (String [] args ) {
180+ String [] ids = new String [] {" Q21691" , " Q21495" , " O48771" };
181+ try {
182+ alignAllLocal(ids);
183+ } catch (Exception e){
184+ e. printStackTrace();
185+ }
186+ }
187+
188+ private static void alignAllLocal (String [] ids ) throws Exception {
189+ List<ProteinSequence > lst = new ArrayList<ProteinSequence > ();
190+ for (String id : ids) {
191+ lst. add(getSequenceForId(id));
192+ }
193+ SubstitutionMatrix<AminoAcidCompound > matrix = new SimpleSubstitutionMatrix<AminoAcidCompound > ();
194+ List<SequencePair<ProteinSequence , AminoAcidCompound > > alig = Alignments . getAllPairsAlignments(lst,
195+ PairwiseSequenceAlignerType . LOCAL , new SimpleGapPenalty (), matrix);
196+ for (SequencePair<ProteinSequence , AminoAcidCompound > pair : alig) {
197+ System . out. printf(" %n%s vs %s%n%s" , pair. getQuery(). getAccession(), pair. getTarget(). getAccession(), pair);
198+ }
199+ ConcurrencyTools . shutdown();
200+ }
201+
202+ private static ProteinSequence getSequenceForId (String uniProtId ) throws Exception {
203+ URL uniprotFasta = new URL (String . format(" http://www.uniprot.org/uniprot/%s.fasta" , uniProtId));
204+ ProteinSequence seq = FastaReaderHelper . readFastaProteinSequence(uniprotFasta. openStream()). get(uniProtId);
205+ System . out. printf(" id : %s %s%n%s%n" , uniProtId, seq, seq. getOriginalHeader());
206+ return seq;
207+ }
208208
209209}
210210
0 commit comments