Package org.biojava.bio.program.phred
Class PhredFormat
- java.lang.Object
-
- org.biojava.bio.program.phred.PhredFormat
-
- All Implemented Interfaces:
Serializable,EventListener,SequenceFormat,ParseErrorListener,ParseErrorSource
public class PhredFormat extends Object implements SequenceFormat, ParseErrorSource, ParseErrorListener, Serializable
Format object representing Phred Quality files. The only `sequence property' reported by this parser is PROPERTY_DESCRIPTIONLINE, which is the contents of the sequence's description line (the line starting with a '>' character). Essentially a rework of FastaFormat to cope with the quirks of Phred Quality data.Copyright (c) 2001
Company: AgResearch
- Since:
- 1.1
- Author:
- Mark Schreiber, Greg Cox, Frans Verhoef
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULTstatic StringPROPERTY_DESCRIPTIONLINEConstant string which is the property key used to notify listeners of the description lines of Phred sequences.
-
Constructor Summary
Constructors Constructor Description PhredFormat()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddParseErrorListener(ParseErrorListener theListener)Adds a parse error listener to the list of listeners if it isn't already included.voidBadLineParsed(ParseErrorEvent theEvent)This method determines the behaviour when a bad line is processed.protected StringdescribeSequence(Sequence seq)Return a suitable description line for a Sequence.StringgetDefaultFormat()Deprecated.intgetLineWidth()Retrive the current line width.protected voidnotifyParseErrorEvent(ParseErrorEvent theEvent)Passes the event on to all the listeners registered for ParseErrorEvents.booleanreadSequence(BufferedReader reader, SymbolTokenization symParser, SeqIOListener siol)Read a sequence and pass data on to a SeqIOListener.voidremoveParseErrorListener(ParseErrorListener theListener)Removes a parse error listener from the list of listeners if it is included.voidsetLineWidth(int width)Set the line width.voidwriteSequence(Sequence seq, PrintStream os)This method will print symbols to the line width followed by a new line etc.voidwriteSequence(Sequence seq, String format, PrintStream os)Deprecated.use writeSequence(Sequence seq, PrintStream os)
-
-
-
Field Detail
-
DEFAULT
public static final String DEFAULT
- See Also:
- Constant Field Values
-
PROPERTY_DESCRIPTIONLINE
public static final String PROPERTY_DESCRIPTIONLINE
Constant string which is the property key used to notify listeners of the description lines of Phred sequences.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PhredFormat
public PhredFormat()
-
-
Method Detail
-
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 boolean readSequence(BufferedReader reader, SymbolTokenization symParser, SeqIOListener siol) throws IllegalSymbolException, IOException, ParseException
Description copied from interface:SequenceFormatRead a sequence and pass data on to a SeqIOListener.- Specified by:
readSequencein interfaceSequenceFormat- Parameters:
reader- The stream of data to parse.symParser- A SymbolParser defining a mapping from character data to Symbols.siol- A listener to notify when data is extracted from the stream.- Returns:
- a boolean indicating whether or not the stream contains any more sequences.
- Throws:
IllegalSymbolException- if it is not possible to translate character data from the stream into valid BioJava symbols.IOException- if an error occurs while reading from the stream.ParseException
-
describeSequence
protected String describeSequence(Sequence seq)
Return a suitable description line for a Sequence. If the sequence's annotation bundle contains PROPERTY_DESCRIPTIONLINE, this is used verbatim. Otherwise, the sequence's name is used.
-
writeSequence
public void writeSequence(Sequence seq, PrintStream os) throws IOException
This method will print symbols to the line width followed by a new line etc. NOTE that an integer symbol does not always correspond to one character therefore a line width of sixty will print sixty characters followed by a new line. Not necessarily sixty integers.- Specified by:
writeSequencein interfaceSequenceFormat- Parameters:
seq- the sequence to write out.os- the printstream to write to.- Throws:
IOException
-
writeSequence
public void writeSequence(Sequence seq, String format, PrintStream os) throws IOException
Deprecated.use writeSequence(Sequence seq, PrintStream os)writeSequencewrites a sequence to the specifiedPrintStream, using the specified format.- Specified by:
writeSequencein interfaceSequenceFormat- Parameters:
seq- aSequenceto write out.format- aStringindicating which sub-format of those available from a particularSequenceFormatimplemention to use when writing.os- aPrintStreamobject.- Throws:
IOException- if an error occurs.
-
getDefaultFormat
public String getDefaultFormat()
Deprecated.getDefaultFormatreturns the String identifier for the default format.- Specified by:
getDefaultFormatin interfaceSequenceFormat- Returns:
- a
String.
-
addParseErrorListener
public void addParseErrorListener(ParseErrorListener theListener)
Adds a parse error listener to the list of listeners if it isn't already included.- Specified by:
addParseErrorListenerin interfaceParseErrorSource- Parameters:
theListener- Listener to be added.
-
removeParseErrorListener
public void removeParseErrorListener(ParseErrorListener theListener)
Removes a parse error listener from the list of listeners if it is included.- Specified by:
removeParseErrorListenerin interfaceParseErrorSource- Parameters:
theListener- Listener to be removed.
-
BadLineParsed
public void BadLineParsed(ParseErrorEvent theEvent)
This method determines the behaviour when a bad line is processed. Some options are to log the error, throw an exception, ignore it completely, or pass the event through.This method should be overwritten when different behavior is desired.
- Specified by:
BadLineParsedin interfaceParseErrorListener- Parameters:
theEvent- The event that contains the bad line and token.
-
notifyParseErrorEvent
protected void notifyParseErrorEvent(ParseErrorEvent theEvent)
Passes the event on to all the listeners registered for ParseErrorEvents.- Parameters:
theEvent- The event to be handed to the listeners.
-
-