org.biojava.bio.seq.io
Class FastaFormat

java.lang.Object
  |
  +--org.biojava.bio.seq.io.FastaFormat

public class FastaFormat
extends java.lang.Object
implements SequenceFormat, java.io.Serializable

Format for Fasta files.

The description lines often include complicated annotation for sequences. The parsing of these is handled by a FastaDescriptionReader object.

Author:
Matthew Pocock
See Also:
Serialized Form

Field Summary
static FastaDescriptionReader DEFAULT_DESCRIPTION_READER
          The default description reader.
 
Constructor Summary
FastaFormat()
           
 
Method Summary
 FastaDescriptionReader getDescriptionReader()
          Retrieve the current description reader.
 int getLineWidth()
          Retrive the current line width.
 Sequence readSequence(StreamReader.Context context, SymbolParser resParser, SequenceFactory sf)
          Read in a single sequence.
 void setDescriptionReader(FastaDescriptionReader fdr)
          Set the descripiton reader.
 void setLineWidth(int width)
          Set the line width.
 void writeSequence(Sequence seq, java.io.PrintStream os)
          Write out a sequence to the specified printstream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DESCRIPTION_READER

public static final FastaDescriptionReader DEFAULT_DESCRIPTION_READER
The default description reader.
Constructor Detail

FastaFormat

public FastaFormat()
Method Detail

setDescriptionReader

public void setDescriptionReader(FastaDescriptionReader fdr)
Set the descripiton reader.
Parameters:
dfr - the new description reader

getDescriptionReader

public FastaDescriptionReader getDescriptionReader()
Retrieve the current description reader.
Returns:
the current description reader

getLineWidth

public int getLineWidth()
Retrive the current line width.
Returns:
the line width

setLineWidth

public void setLineWidth(int width)
Set the line width.

When writing, the lines of sequence will never be longer than the line width.

Parameters:
width - the new line width

readSequence

public Sequence readSequence(StreamReader.Context context,
                             SymbolParser resParser,
                             SequenceFactory sf)
                      throws IllegalSymbolException,
                             java.io.IOException
Description copied from interface: SequenceFormat
Read in a single sequence.

The format is responsible for converting characters in a stream into a complete sequence. It should read from the stream contained in context, parse the symbol characters using resParser and generate a sequence from the resulting symbol list using sf. Any non-sequence information within the format should be read in either as features, or as annotation.

Specified by:
readSequence in interface SequenceFormat
Tags copied from interface: SequenceFormat
Parameters:
context - the context to parse from
resParser - the parser to parse chars to Symbol objects
sf - the sequence factory for generating a full sequence
Returns:
the resulting sequence

writeSequence

public void writeSequence(Sequence seq,
                          java.io.PrintStream os)
Description copied from interface: SequenceFormat
Write out a sequence to the specified printstream
Specified by:
writeSequence in interface SequenceFormat
Tags copied from interface: SequenceFormat
Parameters:
seq - the sequence to write out
os - the printstream to write to