Skip to content

Commit ad98077

Browse files
committed
More manual fixes
1 parent 3ce5d8d commit ad98077

File tree

1 file changed

+53
-47
lines changed

1 file changed

+53
-47
lines changed

_wikis/BioJava:Cookbook:Sequence.md

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -29,76 +29,82 @@ static method from either DNATools, RNATools or ProteinTools.
2929

3030
### String to SymbolList
3131

32-
```java import org.biojava.bio.seq.\*; import org.biojava.bio.symbol.\*;
32+
```java
33+
import org.biojava.bio.seq.\*; import org.biojava.bio.symbol.\*;
3334

3435
public class StringToSymbolList {
3536

36-
public static void main(String[] args) {`
37-
`  `
38-
`   try {`
39-
`     //create a DNA SymbolList from a String`
40-
`     SymbolList dna = DNATools.createDNA("atcggtcggctta");`
41-
42-
`     //create a RNA SymbolList from a String`
43-
`     SymbolList rna = RNATools.createRNA("auugccuacauaggc");`
44-
45-
`     //create a Protein SymbolList from a String`
46-
`     SymbolList aa = ProteinTools.createProtein("AGFAVENDSA");`
47-
`   }`
48-
`   catch (IllegalSymbolException ex) {`
49-
`     //this will happen if you use a character in one of your strings that is`
50-
`     //not an accepted IUB Character for that Symbol.`
51-
`     ex.printStackTrace();`
52-
`   }`
53-
`  `
54-
` }`
55-
56-
} ```
37+
 public static void main(String[] args) {
38+
  
39+
   try {
40+
     //create a DNA SymbolList from a String
41+
     SymbolList dna = DNATools.createDNA("atcggtcggctta");
42+
43+
     //create a RNA SymbolList from a String
44+
     SymbolList rna = RNATools.createRNA("auugccuacauaggc");
45+
46+
     //create a Protein SymbolList from a String
47+
     SymbolList aa = ProteinTools.createProtein("AGFAVENDSA");
48+
   }
49+
   catch (IllegalSymbolException ex) {
50+
     //this will happen if you use a character in one of your strings that is
51+
     //not an accepted IUB Character for that Symbol.
52+
     ex.printStackTrace();
53+
   }
54+
  
55+
 }
56+
57+
}
58+
```
5759

5860
### String to Sequence
5961

60-
```java import org.biojava.bio.seq.\*; import org.biojava.bio.symbol.\*;
62+
```java
63+
import org.biojava.bio.seq.\*; import org.biojava.bio.symbol.\*;
6164

6265
public class StringToSequence {
6366

64-
` public static void main(String[] args) {`
67+
 public static void main(String[] args) {
6568

66-
`   try {`
67-
`     //create a DNA sequence with the name dna_1`
68-
`     Sequence dna = DNATools.createDNASequence("atgctg""dna_1");`
69+
   try {
70+
     //create a DNA sequence with the name dna_1
71+
     Sequence dna = DNATools.createDNASequence("atgctg""dna_1");
6972

70-
`     //create an RNA sequence with the name rna_1`
71-
`     Sequence rna = RNATools.createRNASequence("augcug""rna_1");`
73+
     //create an RNA sequence with the name rna_1
74+
     Sequence rna = RNATools.createRNASequence("augcug""rna_1");
7275

73-
`     //create a Protein sequence with the name prot_1`
74-
`     Sequence prot = ProteinTools.createProteinSequence("AFHS""prot_1");`
75-
`   }`
76-
`   catch (IllegalSymbolException ex) {`
77-
`     //an exception is thrown if you use a non IUB symbol`
78-
`     ex.printStackTrace();`
79-
`   }`
80-
` }`
76+
     //create a Protein sequence with the name prot_1
77+
     Sequence prot = ProteinTools.createProteinSequence("AFHS""prot_1");
78+
   }
79+
   catch (IllegalSymbolException ex) {
80+
     //an exception is thrown if you use a non IUB symbol
81+
     ex.printStackTrace();
82+
   }
83+
 }
8184

82-
} ```
85+
}
86+
```
8387

8488
### SymbolList to String
8589

8690
You can call the seqString() method on either a SymbolList or a Sequence
8791
to get it's Stringified version.
8892

89-
```java import org.biojava.bio.symbol.\*;
93+
```java
94+
import org.biojava.bio.symbol.\*;
9095

9196
public class SymbolListToString {
9297

93-
` public static void main(String[] args) {`
94-
`   SymbolList sl = null;`
95-
`   //code here to instantiate sl`
96-
`  `
97-
`   //convert sl into a String`
98-
`   String s = sl.seqString();`
99-
` }`
98+
 public static void main(String[] args) {
99+
   SymbolList sl = null;
100+
   //code here to instantiate sl
101+
  
102+
   //convert sl into a String
103+
   String s = sl.seqString();
104+
 }
100105

101-
} ```
106+
}
107+
```
102108

103109
The above example uses the process of 'tokenization' to create the
104110
String, in this case hidden in the SeqString method. Different types of

0 commit comments

Comments
 (0)