@@ -24,28 +24,28 @@ org.biojava.nbio.core.sequence.io.FastaReaderHelper;
2424
2525public class CookbookAlignPairGlobal {
2626
27- ` public static void main(String[] args) { `
28- ` String[] ids = new String[] {"Q21691", "Q21495", "O48771"}; `
29- ` try { `
30- ` alignPairGlobal(ids[0], ids[1]); `
31- ` } catch (Exception e){ `
32- ` e.printStackTrace(); `
33- ` } `
27+ ` public static void main(String[] args) { `
28+ ` String[] ids = new String[] {"Q21691", "Q21495", "O48771"}; `
29+ ` try { `
30+ ` alignPairGlobal(ids[0], ids[1]); `
31+ ` } catch (Exception e){ `
32+ ` e.printStackTrace(); `
33+ ` } `
3434` } `
3535
36- ` private static void alignPairGlobal(String id1, String id2) throws Exception { `
37- ` ProteinSequence s1 = getSequenceForId(id1), s2 = getSequenceForId(id2); `
38- ` SubstitutionMatrix ` <AminoAcidCompound >` matrix = new SimpleSubstitutionMatrix ` <AminoAcidCompound >` (); `
39- ` SequencePair ` <ProteinSequence, AminoAcidCompound>` pair = Alignments.getPairwiseAlignment(s1, s2, `
40- ` PairwiseSequenceAlignerType.GLOBAL, new SimpleGapPenalty(), matrix); `
41- ` System.out.printf("%n%s vs %s%n%s", pair.getQuery().getAccession(), pair.getTarget().getAccession(), pair); `
36+ ` private static void alignPairGlobal(String id1, String id2) throws Exception { `
37+ ` ProteinSequence s1 = getSequenceForId(id1), s2 = getSequenceForId(id2); `
38+ ` SubstitutionMatrix ` <AminoAcidCompound >` matrix = new SimpleSubstitutionMatrix ` <AminoAcidCompound >` (); `
39+ ` SequencePair ` <ProteinSequence, AminoAcidCompound>` pair = Alignments.getPairwiseAlignment(s1, s2, `
40+ ` PairwiseSequenceAlignerType.GLOBAL, new SimpleGapPenalty(), matrix); `
41+ ` System.out.printf("%n%s vs %s%n%s", pair.getQuery().getAccession(), pair.getTarget().getAccession(), pair); `
4242` } `
4343
44- ` private static ProteinSequence getSequenceForId(String uniProtId) throws Exception { `
45- ` URL uniprotFasta = new URL(String.format(" ` [ ` http://www.uniprot.org/uniprot/%s.fasta ` ] ( http://www.uniprot.org/uniprot/%s.fasta ) ` ", uniProtId)); `
46- ` ProteinSequence seq = FastaReaderHelper.readFastaProteinSequence(uniprotFasta.openStream()).get(uniProtId); `
47- ` System.out.printf("id : %s %s%n%s%n", uniProtId, seq, seq.getOriginalHeader()); `
48- ` return seq; `
44+ ` private static ProteinSequence getSequenceForId(String uniProtId) throws Exception { `
45+ ` URL uniprotFasta = new URL(String.format(" ` [ ` http://www.uniprot.org/uniprot/%s.fasta ` ] ( http://www.uniprot.org/uniprot/%s.fasta ) ` ", uniProtId)); `
46+ ` ProteinSequence seq = FastaReaderHelper.readFastaProteinSequence(uniprotFasta.openStream()).get(uniProtId); `
47+ ` System.out.printf("id : %s %s%n%s%n", uniProtId, seq, seq.getOriginalHeader()); `
48+ ` return seq; `
4949` } `
5050
5151}
@@ -71,28 +71,28 @@ org.biojava.nbio.core.sequence.io.FastaReaderHelper;
7171
7272public class CookbookAlignPairLocal {
7373
74- ` public static void main(String[] args) { `
75- ` String[] ids = new String[] {"Q21691", "Q21495", "O48771"}; `
76- ` try { `
77- ` alignPairLocal(ids[0], ids[1]); `
78- ` } catch (Exception e){ `
79- ` e.printStackTrace(); `
80- ` } `
74+ ` public static void main(String[] args) { `
75+ ` String[] ids = new String[] {"Q21691", "Q21495", "O48771"}; `
76+ ` try { `
77+ ` alignPairLocal(ids[0], ids[1]); `
78+ ` } catch (Exception e){ `
79+ ` e.printStackTrace(); `
80+ ` } `
8181` } `
8282
83- ` private static void alignPairLocal(String id1, String id2) throws Exception { `
84- ` ProteinSequence s1 = getSequenceForId(id1), s2 = getSequenceForId(id2); `
85- ` SubstitutionMatrix ` <AminoAcidCompound >` matrix = new SimpleSubstitutionMatrix ` <AminoAcidCompound >` (); `
86- ` SequencePair ` <ProteinSequence, AminoAcidCompound>` pair = Alignments.getPairwiseAlignment(s1, s2, `
87- ` PairwiseSequenceAlignerType.LOCAL, new SimpleGapPenalty(), matrix); `
88- ` System.out.printf("%n%s vs %s%n%s", pair.getQuery().getAccession(), pair.getTarget().getAccession(), pair); `
83+ ` private static void alignPairLocal(String id1, String id2) throws Exception { `
84+ ` ProteinSequence s1 = getSequenceForId(id1), s2 = getSequenceForId(id2); `
85+ ` SubstitutionMatrix ` <AminoAcidCompound >` matrix = new SimpleSubstitutionMatrix ` <AminoAcidCompound >` (); `
86+ ` SequencePair ` <ProteinSequence, AminoAcidCompound>` pair = Alignments.getPairwiseAlignment(s1, s2, `
87+ ` PairwiseSequenceAlignerType.LOCAL, new SimpleGapPenalty(), matrix); `
88+ ` System.out.printf("%n%s vs %s%n%s", pair.getQuery().getAccession(), pair.getTarget().getAccession(), pair); `
8989` } `
9090
91- ` private static ProteinSequence getSequenceForId(String uniProtId) throws Exception { `
92- ` URL uniprotFasta = new URL(String.format(" ` [ ` http://www.uniprot.org/uniprot/%s.fasta ` ] ( http://www.uniprot.org/uniprot/%s.fasta ) ` ", uniProtId)); `
93- ` ProteinSequence seq = FastaReaderHelper.readFastaProteinSequence(uniprotFasta.openStream()).get(uniProtId); `
94- ` System.out.printf("id : %s %s%n%s%n", uniProtId, seq, seq.getOriginalHeader()); `
95- ` return seq; `
91+ ` private static ProteinSequence getSequenceForId(String uniProtId) throws Exception { `
92+ ` URL uniprotFasta = new URL(String.format(" ` [ ` http://www.uniprot.org/uniprot/%s.fasta ` ] ( http://www.uniprot.org/uniprot/%s.fasta ) ` ", uniProtId)); `
93+ ` ProteinSequence seq = FastaReaderHelper.readFastaProteinSequence(uniprotFasta.openStream()).get(uniProtId); `
94+ ` System.out.printf("id : %s %s%n%s%n", uniProtId, seq, seq.getOriginalHeader()); `
95+ ` return seq; `
9696` } `
9797
9898}
@@ -122,34 +122,34 @@ org.biojava.nbio.core.util.ConcurrencyTools;
122122
123123public class CookbookAlignAllGlobal {
124124
125- ` public static void main(String[] args) { `
126- ` String[] ids = new String[] {"Q21691", "Q21495", "O48771"}; `
127- ` try { `
128- ` alignAllGlobal(ids); `
129- ` } catch (Exception e){ `
130- ` e.printStackTrace(); `
131- ` } `
125+ ` public static void main(String[] args) { `
126+ ` String[] ids = new String[] {"Q21691", "Q21495", "O48771"}; `
127+ ` try { `
128+ ` alignAllGlobal(ids); `
129+ ` } catch (Exception e){ `
130+ ` e.printStackTrace(); `
131+ ` } `
132132` } `
133133
134- ` private static void alignAllGlobal(String[] ids) throws Exception { `
135- ` List ` <ProteinSequence >` lst = new ArrayList ` <ProteinSequence >` (); `
136- ` for (String id : ids) { `
137- ` lst.add(getSequenceForId(id)); `
138- ` } `
139- ` SubstitutionMatrix ` <AminoAcidCompound >` matrix = new SimpleSubstitutionMatrix ` <AminoAcidCompound >` (); `
140- ` List ` <SequencePair<ProteinSequence, AminoAcidCompound>` > alig = Alignments.getAllPairsAlignments(lst, `
141- ` PairwiseSequenceAlignerType.GLOBAL, new SimpleGapPenalty(), matrix); `
142- ` for (SequencePair ` <ProteinSequence, AminoAcidCompound>` pair : alig) { `
143- ` System.out.printf("%n%s vs %s%n%s", pair.getQuery().getAccession(), pair.getTarget().getAccession(), pair); `
144- ` } `
145- ` ConcurrencyTools.shutdown(); `
134+ ` private static void alignAllGlobal(String[] ids) throws Exception { `
135+ ` List ` <ProteinSequence >` lst = new ArrayList ` <ProteinSequence >` (); `
136+ ` for (String id : ids) { `
137+ ` lst.add(getSequenceForId(id)); `
138+ ` } `
139+ ` SubstitutionMatrix ` <AminoAcidCompound >` matrix = new SimpleSubstitutionMatrix ` <AminoAcidCompound >` (); `
140+ ` List ` <SequencePair<ProteinSequence, AminoAcidCompound>` > alig = Alignments.getAllPairsAlignments(lst, `
141+ ` PairwiseSequenceAlignerType.GLOBAL, new SimpleGapPenalty(), matrix); `
142+ ` for (SequencePair ` <ProteinSequence, AminoAcidCompound>` pair : alig) { `
143+ ` System.out.printf("%n%s vs %s%n%s", pair.getQuery().getAccession(), pair.getTarget().getAccession(), pair); `
144+ ` } `
145+ ` ConcurrencyTools.shutdown(); `
146146` } `
147147
148- ` private static ProteinSequence getSequenceForId(String uniProtId) throws Exception { `
149- ` URL uniprotFasta = new URL(String.format(" ` [ ` http://www.uniprot.org/uniprot/%s.fasta ` ] ( http://www.uniprot.org/uniprot/%s.fasta ) ` ", uniProtId)); `
150- ` ProteinSequence seq = FastaReaderHelper.readFastaProteinSequence(uniprotFasta.openStream()).get(uniProtId); `
151- ` System.out.printf("id : %s %s%n%s%n", uniProtId, seq, seq.getOriginalHeader()); `
152- ` return seq; `
148+ ` private static ProteinSequence getSequenceForId(String uniProtId) throws Exception { `
149+ ` URL uniprotFasta = new URL(String.format(" ` [ ` http://www.uniprot.org/uniprot/%s.fasta ` ] ( http://www.uniprot.org/uniprot/%s.fasta ) ` ", uniProtId)); `
150+ ` ProteinSequence seq = FastaReaderHelper.readFastaProteinSequence(uniprotFasta.openStream()).get(uniProtId); `
151+ ` System.out.printf("id : %s %s%n%s%n", uniProtId, seq, seq.getOriginalHeader()); `
152+ ` return seq; `
153153` } `
154154
155155}
@@ -176,34 +176,34 @@ 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- ` } `
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+ ` } `
186186` } `
187187
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(); `
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(); `
200200` } `
201201
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; `
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; `
207207` } `
208208
209209}
0 commit comments