Package org.biojavax.bio.seq.io
Class EMBLxmlFormat
java.lang.Object
org.biojavax.bio.seq.io.RichSequenceFormat.BasicFormat
org.biojavax.bio.seq.io.EMBLxmlFormat
- All Implemented Interfaces:
SequenceFormat,RichSequenceFormat
Format reader for EMBLxml files. This version of EMBLxml format will generate
and write RichSequence objects. Loosely Based on code from the old, deprecated,
org.biojava.bio.seq.io.GenbankXmlFormat object.
Understands http://www.ebi.ac.uk/embl/dtd/EMBL_Services_V1.1.dtd
- Since:
- 1.5
- Author:
- Alan Li (code based on his work), Richard Holland, Mark Schreiber
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classImplements some EMBLxml-specific terms.Nested classes/interfaces inherited from interface org.biojavax.bio.seq.io.RichSequenceFormat
RichSequenceFormat.BasicFormat, RichSequenceFormat.HeaderlessFormat -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringstatic final StringThe name of this formatprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Pattern -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInforms the writer that we want to start writing.booleancanRead(BufferedInputStream stream) Check to see if a given stream is in our format.booleanCheck to see if a given file is in our format.voidInforms the writer that are done writing.getDefaultFormatreturns the String identifier for the default sub-format written by aSequenceFormatimplementation.On the assumption that the stream is readable by this format (not checked), attempt to guess which symbol tokenization we should use to read it.guessSymbolTokenization(File file) On the assumption that the file is readable by this format (not checked), attempt to guess which symbol tokenization we should use to read it.booleanreadRichSequence(BufferedReader reader, SymbolTokenization symParser, RichSeqIOListener rlistener, Namespace ns) Reads a sequence from the given buffered reader using the given tokenizer to parse sequence symbols.booleanreadSequence(BufferedReader reader, SymbolTokenization symParser, SeqIOListener listener) Read a sequence and pass data on to a SeqIOListener.voidwriteSequence(Sequence seq, PrintStream os) writeSequencewrites a sequence to the specified PrintStream, using the default format.voidwriteSequence(Sequence seq, String format, PrintStream os) writeSequencewrites a sequence to the specifiedPrintStream, using the specified format.voidwriteSequence(Sequence seq, Namespace ns) Writes a sequence out to the outputstream given by beginWriting() using the default format of the implementing class.Methods inherited from class org.biojavax.bio.seq.io.RichSequenceFormat.BasicFormat
getElideComments, getElideFeatures, getElideReferences, getElideSymbols, getLineWidth, getPrintStream, setElideComments, setElideFeatures, setElideReferences, setElideSymbols, setLineWidth, setPrintStream
-
Field Details
-
EMBLXML_FORMAT
The name of this format- See Also:
-
ENTRY_GROUP_TAG
- See Also:
-
ENTRY_TAG
- See Also:
-
ENTRY_ACCESSION_ATTR
- See Also:
-
ENTRY_TAX_DIVISION_ATTR
- See Also:
-
ENTRY_DATACLASS_ATTR
- See Also:
-
ENTRY_CREATED_ATTR
- See Also:
-
ENTRY_RELCREATED_ATTR
- See Also:
-
ENTRY_UPDATED_ATTR
- See Also:
-
ENTRY_RELUPDATED_ATTR
- See Also:
-
ENTRY_VER_ATTR
- See Also:
-
ENTRY_SUBACC_ATTR
- See Also:
-
ENTRY_SUBVER_ATTR
- See Also:
-
ENTRY_SUBWGSVER_ATTR
- See Also:
-
ENTRY_STATUS_ATTR
- See Also:
-
ENTRY_STATUS_DATE_ATTR
- See Also:
-
SEC_ACC_TAG
- See Also:
-
PROJ_ACC_TAG
- See Also:
-
DESC_TAG
- See Also:
-
KEYWORD_TAG
- See Also:
-
REFERENCE_TAG
- See Also:
-
CITATION_TAG
- See Also:
-
CITATION_ID_ATTR
- See Also:
-
CITATION_TYPE_ATTR
- See Also:
-
CITATION_DATE_ATTR
- See Also:
-
CITATION_NAME_ATTR
- See Also:
-
CITATION_VOL_ATTR
- See Also:
-
CITATION_ISSUE_ATTR
- See Also:
-
CITATION_FIRST_ATTR
- See Also:
-
CITATION_LAST_ATTR
- See Also:
-
CITATION_PUB_ATTR
- See Also:
-
CITATION_PATENT_ATTR
- See Also:
-
CITATION_INSTITUTE_ATTR
- See Also:
-
CITATION_YEAR_ATTR
- See Also:
-
DBREFERENCE_TAG
- See Also:
-
DBREF_DB_ATTR
- See Also:
-
DBREF_PRIMARY_ATTR
- See Also:
-
DBREF_SEC_ATTR
- See Also:
-
CONSORTIUM_TAG
- See Also:
-
TITLE_TAG
- See Also:
-
EDITOR_TAG
- See Also:
-
AUTHOR_TAG
- See Also:
-
PATENT_TAG
- See Also:
-
LOCATOR_TAG
- See Also:
-
CITATION_LOCATION_TAG
- See Also:
-
REF_POS_BEGIN_ATTR
- See Also:
-
REF_POS_END_ATTR
- See Also:
-
COMMENT_TAG
- See Also:
-
FEATURE_TAG
- See Also:
-
FEATURE_NAME_ATTR
- See Also:
-
ORGANISM_TAG
- See Also:
-
SCINAME_TAG
- See Also:
-
COMNAME_TAG
- See Also:
-
TAXID_TAG
- See Also:
-
LINEAGE_TAG
- See Also:
-
TAXON_TAG
- See Also:
-
ORGANELLE_TAG
- See Also:
-
QUALIFIER_TAG
- See Also:
-
QUALIFIER_NAME_ATTR
- See Also:
-
LOCATION_TAG
- See Also:
-
LOCATION_TYPE_ATTR
- See Also:
-
LOCATION_COMPL_ATTR
- See Also:
-
LOCATION_ELEMENT_TAG
- See Also:
-
LOC_ELEMENT_TYPE_ATTR
- See Also:
-
LOC_ELEMENT_ACC_ATTR
- See Also:
-
LOC_ELEMENT_VER_ATTR
- See Also:
-
LOC_ELEMENT_COMPL_ATTR
- See Also:
-
BASEPOSITION_TAG
- See Also:
-
BASEPOSITION_TYPE_ATTR
- See Also:
-
CONTIG_TAG
- See Also:
-
SEQUENCE_TAG
- See Also:
-
SEQUENCE_TYPE_ATTR
- See Also:
-
SEQUENCE_LENGTH_ATTR
- See Also:
-
SEQUENCE_TOPOLOGY_ATTR
- See Also:
-
SEQUENCE_VER_ATTR
- See Also:
-
xmlSchema
-
-
Constructor Details
-
EMBLxmlFormat
public EMBLxmlFormat()
-
-
Method Details
-
canRead
Check to see if a given file is in our format. Some formats may be able to determine this by filename, whilst others may have to open the file and read it to see what format it is in. A file is in EMBLxml format if the second XML line contains the phrase "http://www.ebi.ac.uk/schema/EMBL_schema.xsd".- Specified by:
canReadin interfaceRichSequenceFormat- Overrides:
canReadin classRichSequenceFormat.BasicFormat- Parameters:
file- theFileto check.- Returns:
- true if the file is readable by this format, false if not.
- Throws:
IOException- in case the file is inaccessible.
-
guessSymbolTokenization
On the assumption that the file is readable by this format (not checked), attempt to guess which symbol tokenization we should use to read it. For formats that only accept one tokenization, just return it without checking the file. For formats that accept multiple tokenizations, its up to you how you do it. Always returns a DNA tokenizer.- Specified by:
guessSymbolTokenizationin interfaceRichSequenceFormat- Overrides:
guessSymbolTokenizationin classRichSequenceFormat.BasicFormat- Parameters:
file- theFileobject to guess the format of.- Returns:
- a
SymbolTokenizationto read the file with. - Throws:
IOException- if the file is unrecognisable or inaccessible.
-
canRead
Check to see if a given stream is in our format. A stream is in EMBLxml format if the second XML line contains the phrase "http://www.ebi.ac.uk/schema/EMBL_schema.xsd".- Parameters:
stream- theBufferedInputStreamto check.- Returns:
- true if the stream is readable by this format, false if not.
- Throws:
IOException- in case the stream is inaccessible.
-
guessSymbolTokenization
On the assumption that the stream is readable by this format (not checked), attempt to guess which symbol tokenization we should use to read it. For formats that only accept one tokenization, just return it without checking the stream. For formats that accept multiple tokenizations, its up to you how you do it. Always returns a DNA tokenizer.- Parameters:
stream- theBufferedInputStreamobject to guess the format of.- Returns:
- a
SymbolTokenizationto read the stream with. - Throws:
IOException- if the stream is unrecognisable or inaccessible.
-
readSequence
public boolean readSequence(BufferedReader reader, SymbolTokenization symParser, SeqIOListener listener) throws IllegalSymbolException, IOException, ParseException Read a sequence and pass data on to a SeqIOListener.- Parameters:
reader- The stream of data to parse.symParser- A SymbolParser defining a mapping from character data to Symbols.listener- 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
-
readRichSequence
public boolean readRichSequence(BufferedReader reader, SymbolTokenization symParser, RichSeqIOListener rlistener, Namespace ns) throws IllegalSymbolException, IOException, ParseException Reads a sequence from the given buffered reader using the given tokenizer to parse sequence symbols. Events are passed to the listener, and the namespace used for sequences read is the one given. If the namespace is null, then the default namespace for the parser is used, which may depend on individual implementations of this interface.- Parameters:
reader- the input sourcesymParser- the tokenizer which understands the sequence being readrlistener- the listener to send sequence events tons- the namespace to read sequences into.- Returns:
- true if there is more to read after this, false otherwise.
- Throws:
IllegalSymbolException- if the tokenizer couldn't understand one of the sequence symbols in the file.IOException- if there was a read error.ParseException
-
beginWriting
Informs the writer that we want to start writing. This will do any initialisation required, such as writing the opening tags of an XML file that groups sequences together.- Throws:
IOException- if writing fails.
-
finishWriting
Informs the writer that are done writing. This will do any finalisation required, such as writing the closing tags of an XML file that groups sequences together.- Throws:
IOException- if writing fails.
-
writeSequence
writeSequencewrites a sequence to the specified PrintStream, using the default format.- Parameters:
seq- the sequence to write out.os- the printstream to write to.- Throws:
IOException
-
writeSequence
writeSequencewrites a sequence to the specifiedPrintStream, using the specified format.- 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.
-
writeSequence
Writes a sequence out to the outputstream given by beginWriting() using the default format of the implementing class. If namespace is given, sequences will be written with that namespace, otherwise they will be written with the default namespace of the implementing class (which is usually the namespace of the sequence itself). If you pass this method a sequence which is not a RichSequence, it will attempt to convert it using RichSequence.Tools.enrich(). Obviously this is not going to guarantee a perfect conversion, so it's better if you just use RichSequences to start with! Namespace is ignored as EMBLxml has no concept of it.- Parameters:
seq- the sequence to writens- the namespace to write it with- Throws:
IOException- in case it couldn't write something
-
getDefaultFormat
getDefaultFormatreturns the String identifier for the default sub-format written by aSequenceFormatimplementation.- Returns:
- a
String.
-