@@ -72,10 +72,8 @@ We really want to make it easy to create a sequence and what could be
72
72
easier than using a String.
73
73
74
74
``` java
75
-
76
- ` ProteinSequence proteinSequence = new ProteinSequence (" ARNDCEQGHILKMFPSTWYVBZJX" );`
77
- ` DNASequence dnaSequence = new DNASequence (" ATCG" );`
78
-
75
+ ProteinSequence proteinSequence = new ProteinSequence (" ARNDCEQGHILKMFPSTWYVBZJX" );
76
+ DNASequence dnaSequence = new DNASequence (" ATCG" );
79
77
```
80
78
81
79
The storage of the sequence data is defined by the Sequence interface
@@ -110,8 +108,8 @@ some level of api changes as we improve the overall design.
110
108
111
109
``` java
112
110
113
- ` UniprotProxySequenceReader ` < AminoAcidCompound > ` uniprotSequence = new UniprotProxySequenceReader ` <AminoAcidCompound >` (" YA745_GIBZE" , AminoAcidCompoundSet . getAminoAcidCompoundSet());`
114
- ` ProteinSequence proteinSequence = new ProteinSequence (uniprotSequence);`
111
+ UniprotProxySequenceReader<AminoAcidCompound > uniprotSequence = new UniprotProxySequenceReader<AminoAcidCompound > (" YA745_GIBZE" , AminoAcidCompoundSet . getAminoAcidCompoundSet());
112
+ ProteinSequence proteinSequence = new ProteinSequence (uniprotSequence);
115
113
116
114
```
117
115
@@ -124,17 +122,15 @@ but is very specific to learning the location of the sequence data in
124
122
the file.
125
123
126
124
``` java
127
-
128
- ` File file = new File (inputFile);`
129
- ` FastaReader `< ProteinSequence ,AminoAcidCompound > ` fastaProxyReader = new FastaReader `<ProteinSequence ,AminoAcidCompound >`(file, new GenericFastaHeaderParser `<ProteinSequence ,AminoAcidCompound >`(), new FileProxyProteinSequenceCreator (file, AminoAcidCompoundSet . getAminoAcidCompoundSet()));`
130
- ` LinkedHashMap `< String ,ProteinSequence > ` proteinProxySequences = fastaProxyReader. process();`
131
-
132
- ` for (String key : proteinProxySequences. keySet()){`
133
- ` ProteinSequence proteinSequence = proteinProxySequences. get(key);`
134
- ` System . out. println(key);`
135
- ` System . out. println(proteinSequence. toString());`
136
- ` }`
137
-
125
+ File file = new File (inputFile);
126
+ FastaReader<ProteinSequence ,AminoAcidCompound > fastaProxyReader = new FastaReader<ProteinSequence ,AminoAcidCompound > (file, new GenericFastaHeaderParser<ProteinSequence ,AminoAcidCompound > (), new FileProxyProteinSequenceCreator (file, AminoAcidCompoundSet . getAminoAcidCompoundSet()));
127
+ LinkedHashMap<String ,ProteinSequence > proteinProxySequences = fastaProxyReader. process();
128
+
129
+ for (String key : proteinProxySequences. keySet()){
130
+ ProteinSequence proteinSequence = proteinProxySequences. get(key);
131
+ System . out. println(key);
132
+ System . out. println(proteinSequence. toString());
133
+ }
138
134
```
139
135
140
136
In the above example a FastaReader class is created where we abstract
@@ -171,10 +167,8 @@ code. The following code shows the use of FastaReaderHelper and
171
167
FastaWriterHelper.
172
168
173
169
``` java
174
-
175
- ` LinkedHashMap `< String , DNASequence > ` dnaSequences = FastaReaderHelper . readFastaDNASequence(new File (" 454Scaffolds.fna" ));`
176
- ` FastaWriterHelper . writeNucleotideSequence(new File (" 454Scaffolds-1.fna" ),dnaSequences. values());`
177
-
170
+ LinkedHashMap<String , DNASequence > dnaSequences = FastaReaderHelper . readFastaDNASequence(new File (" 454Scaffolds.fna" ));
171
+ FastaWriterHelper . writeNucleotideSequence(new File (" 454Scaffolds-1.fna" ),dnaSequences. values());
178
172
```
179
173
180
174
Working with Sequence Objects
@@ -204,17 +198,18 @@ Avoid using any kind of String method to do this since String operations
204
198
are costly in BioJava (due to the String conversion that must be
205
199
applied). Here is an example on how to do it for any Sequence object.
206
200
207
- ``` java List<Sequence<AminoAcidCompound>\> translations =
201
+ ``` java
202
+ List<Sequence<AminoAcidCompound > > translations =
208
203
populateFromSomewhere(); Collections . sort(translations, new
209
- Comparator<Sequence<? extends Compound > \ >() {
210
-
211
- ` public int compare (Sequence ` <? extends Compound >` o1 , Sequence ` <? extends Compound >` o2 ) {`
212
- ` Integer o1Length = o1. getLength();`
213
- ` Integer o2Length = o2. getLength();`
214
- ` return o1Length. compareTo(o2Length);`
215
- `}`
216
-
217
- }); ```
204
+ Comparator<Sequence<? extends Compound > > () {
205
+
206
+ public int compare (Sequence<? extends Compound > o1 , Sequence<? extends Compound > o2 ) {
207
+ Integer o1Length = o1. getLength();
208
+ Integer o2Length = o2. getLength();
209
+ return o1Length. compareTo(o2Length);
210
+ }
211
+ });
212
+ ```
218
213
219
214
Note our usage of the generic type to capture Sequence objects of any
220
215
type since the assessment of length is something which can be applied to
@@ -241,9 +236,7 @@ non-ambiguity CompoundSets with Codon table 1 in Frame 1 in the forward
241
236
orientation.
242
237
243
238
``` java
244
-
245
- ` ProteinSequence protein = new DNASequence (" ATG" ). getRNASequence(). getProteinSequence();`
246
-
239
+ ProteinSequence protein = new DNASequence (" ATG" ). getRNASequence(). getProteinSequence();
247
240
```
248
241
249
242
### Translating in a Different Frame
@@ -257,11 +250,9 @@ object when we request the RNA. Multiple frames of translations are
257
250
possible but see later on.
258
251
259
252
``` java
260
-
261
- ` DNASequence dna = new DNASequence (" AATG" );`
262
- ` RNASequence rna = dna. getRNASequence(Frame . TWO );`
263
- ` ProteinSequence protein = rna. getProteinSequence();`
264
-
253
+ DNASequence dna = new DNASequence (" AATG" );
254
+ RNASequence rna = dna. getRNASequence(Frame . TWO );
255
+ ProteinSequence protein = rna. getProteinSequence();
265
256
```
266
257
267
258
### Translating in Multiple Frames
@@ -273,10 +264,11 @@ translation in. The following example attempts to translate a sequence
273
264
in all three forward frames. The code returns a map of the results keyed
274
265
by their frame.
275
266
276
- ``` java TranscriptionEngine te = TranscriptionEngine.getDefault();
267
+ ``` java
268
+ TranscriptionEngine te = TranscriptionEngine . getDefault();
277
269
Frame [] frames = Frame . getForwardFrames();
278
- Map<Frame , Sequence<AminoAcidCompound > \ > results =
279
- te . multipleFrameTranslation(dna, frames); ```
270
+ Map<Frame , Sequence<AminoAcidCompound > > results = te . multipleFrameTranslation(dna, frames);
271
+ ```
280
272
281
273
Using this we can replicate the functionality found in EMBOSS' transeq
282
274
package.
@@ -295,34 +287,32 @@ will build an engine to
295
287
- Convert any initiating amino acid which is not methionine into one
296
288
- Trim stops
297
289
298
- ```java TranscriptionEngine.Builder b = new
299
- TranscriptionEngine.Builder(); b.table(11).initMet(true).trimStop(true);
300
- TranscriptionEngine engine = b.build(); ```
290
+ ``` java
291
+ TranscriptionEngine . Builder b = new TranscriptionEngine .Builder ();
292
+ b. table(11 ). initMet(true ). trimStop(true );
293
+ TranscriptionEngine engine = b. build();
294
+ ```
301
295
302
296
This can be handed to the translation methods like so:
303
297
304
298
``` java
305
-
306
- ` DNASequence dna = new DNASequence("ATG");`
307
- ` RNASequence rna = dna.getRNASequence(engine);`
308
- ` ProteinSequence protein = rna.getProteinSequence(engine);`
309
-
299
+ DNASequence dna = new DNASequence (" ATG" );
300
+ RNASequence rna = dna. getRNASequence(engine);
301
+ ProteinSequence protein = rna. getProteinSequence(engine);
310
302
```
311
303
312
304
The translation can be started from the TranscriptionEngine directly
313
305
except this results in more general objects (you will get back objects
314
306
which implement the Sequence interface and not the true object type).
315
307
316
308
``` java
317
-
318
- ` DNASequence dna = new DNASequence("ATG");`
319
- ` TranscriptionEngine engine = TranscriptionEngine.getDefault(); //Get the default engine`
320
- ` Sequence`<NucleotideCompound>` rna = engine.getDnaRnaTranslator().createSequence(dna);`
321
- ` Sequence`<AminoAcidCompound>` protein = engine.getRnaAminoAcidTranslator().createSequence(rna);`
322
- ` `
323
- ` //Or to jump to it straight away use this method (coming soon)`
324
- ` Sequence`<AminoAcidCompound>` protein = engine.translate(dna);`
325
-
309
+ DNASequence dna = new DNASequence (" ATG" );
310
+ TranscriptionEngine engine = TranscriptionEngine . getDefault(); // Get the default engine
311
+ Sequence<NucleotideCompound > rna = engine. getDnaRnaTranslator(). createSequence(dna);
312
+ Sequence<AminoAcidCompound > protein = engine. getRnaAminoAcidTranslator(). createSequence(rna);
313
+
314
+ // Or to jump to it straight away use this method (coming soon)
315
+ Sequence<AminoAcidCompound > protein = engine. translate(dna);
326
316
```
327
317
328
318
### Codon Tables
0 commit comments