Skip to content

Commit e97e2fe

Browse files
dicknetherlandsandreasprlic
authored andcommitted
/* FASTA */
1 parent 3a5d929 commit e97e2fe

File tree

2 files changed

+41
-7
lines changed

2 files changed

+41
-7
lines changed

_wikis/BioJava3:HowTo.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,20 @@ The examples in this section require the biojava-fasta module. The
139139
examples that deal with converting to/from DNA sequences also require
140140
the biojava-dna module.
141141

142-
At some point, convenience wrapper classes will be added to make the
143-
parsing process simpler for the most common use-cases.
142+
Convenience wrapper classes are provided to make the parsing process
143+
simpler for the most common use-cases.
144144

145-
### Parsing a FASTA file
145+
### Parsing a FASTA file (the easy way)
146+
147+
` ThingParser`<FASTA>` parser = ThingParserFactory.`
148+
`   getReadParser(FASTA.format, new File("/path/to/my/fasta.fa"));`
149+
` while (parser.hasNext()) {`
150+
`   FASTA fasta = parser.next(); `
151+
`   // fasta contains a complete FASTA record.`
152+
` }`
153+
` reader.close();`
154+
155+
### Parsing a FASTA file (the hard way)
146156

147157
` FASTAReader reader = new FASTAFileReader(new File("/path/to/my/fasta.fa"));`
148158
` FASTABuilder builder = new FASTABuilder();`
@@ -163,7 +173,14 @@ parsing process simpler for the most common use-cases.
163173
` fasta.setDescription("My Description Line");`
164174
` fasta.setSequence(SymbolListFormatter.formatSymbols(mySeq));`
165175

166-
### Writing a FASTA file
176+
### Writing a FASTA file (the easy way)
177+
178+
` ThingParser`<FASTA>` parser = ThingParserFactory.`
179+
`   getWriteParser(FASTA.format, new File("/path/to/my/fasta.fa"), fasta);`
180+
` parser.parseAll();`
181+
` writer.close();`
182+
183+
### Writing a FASTA file (the hard way)
167184

168185
` FASTAEmitter emitter = new FASTAEmitter(fasta);`
169186
` FASTAWriter writer = new FASTAFileWriter(new File("/path/to/new/fasta.fa"));`

_wikis/BioJava3:HowTo.mediawiki

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,19 @@ All the examples in this section require the biojava-dna module.
124124

125125
The examples in this section require the biojava-fasta module. The examples that deal with converting to/from DNA sequences also require the biojava-dna module.
126126

127-
At some point, convenience wrapper classes will be added to make the parsing process simpler for the most common use-cases.
127+
Convenience wrapper classes are provided to make the parsing process simpler for the most common use-cases.
128128

129-
=== Parsing a FASTA file ===
129+
=== Parsing a FASTA file (the easy way) ===
130+
131+
ThingParser<FASTA> parser = ThingParserFactory.
132+
getReadParser(FASTA.format, new File("/path/to/my/fasta.fa"));
133+
while (parser.hasNext()) {
134+
FASTA fasta = parser.next();
135+
// fasta contains a complete FASTA record.
136+
}
137+
reader.close();
138+
139+
=== Parsing a FASTA file (the hard way) ===
130140

131141
FASTAReader reader = new FASTAFileReader(new File("/path/to/my/fasta.fa"));
132142
FASTABuilder builder = new FASTABuilder();
@@ -147,7 +157,14 @@ At some point, convenience wrapper classes will be added to make the parsing pro
147157
fasta.setDescription("My Description Line");
148158
fasta.setSequence(SymbolListFormatter.formatSymbols(mySeq));
149159
150-
=== Writing a FASTA file ===
160+
=== Writing a FASTA file (the easy way) ===
161+
162+
ThingParser<FASTA> parser = ThingParserFactory.
163+
getWriteParser(FASTA.format, new File("/path/to/my/fasta.fa"), fasta);
164+
parser.parseAll();
165+
writer.close();
166+
167+
=== Writing a FASTA file (the hard way) ===
151168

152169
FASTAEmitter emitter = new FASTAEmitter(fasta);
153170
FASTAWriter writer = new FASTAFileWriter(new File("/path/to/new/fasta.fa"));

0 commit comments

Comments
 (0)