|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.biojava.bio.seq.io.StreamReader
public class StreamReader
Parses a stream into sequences.
This object implements SequenceIterator, so you can loop over each sequence produced. It consumes a stream, and uses a SequenceFormat to extract each sequence from the stream.
It is assumed that the stream contains sequences that can be handled by the one format, and that they are not seperated other than by delimiters that the format can handle.
Sequences are instantiated when they are requested by nextSequence, not before, so it is safe to use this object to parse a gigabyte fasta file, and do sequence-by-sequence processing, while being guaranteed that StreamReader will not require you to keep any of the sequences in memory.
More functionality is offered by RichStreamReader
,
Use of this interface is prefered.
RichStreamReader
Constructor Summary | |
---|---|
StreamReader(BufferedReader reader,
SequenceFormat format,
SymbolTokenization symParser,
SequenceBuilderFactory sf)
|
|
StreamReader(InputStream is,
SequenceFormat format,
SymbolTokenization symParser,
SequenceBuilderFactory sf)
|
Method Summary | |
---|---|
void |
BadLineParsed(ParseErrorEvent theEvent)
This method determines the behaviour when a bad line is processed. |
boolean |
hasNext()
Returns whether there are more sequences to iterate over. |
Sequence |
nextSequence()
Pull the next sequence out of the stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StreamReader(InputStream is, SequenceFormat format, SymbolTokenization symParser, SequenceBuilderFactory sf)
public StreamReader(BufferedReader reader, SequenceFormat format, SymbolTokenization symParser, SequenceBuilderFactory sf)
Method Detail |
---|
public Sequence nextSequence() throws NoSuchElementException, BioException
This method will delegate parsing from the stream to a SequenceFormat object, and then return the resulting sequence.
nextSequence
in interface SequenceIterator
NoSuchElementException
- if the end of the stream has been hit
BioException
- if for any reason the next sequence could not be readpublic boolean hasNext()
SequenceIterator
hasNext
in interface SequenceIterator
public void BadLineParsed(ParseErrorEvent theEvent)
This method should be overwritten when different behavior is desired.
BadLineParsed
in interface ParseErrorListener
theEvent
- The event that contains the bad line and token.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |