Class BlastXMLParser
- All Implemented Interfaces:
StAXContentHandler
It has two modes:- i) single output document mode: this takes a document containing a single BlastOutput element and parses it. This is generated when a single query is searched against a sequence database.
ii) multiple query document mode: unfortunately, NCBI BLAST concatenates the results of multiple searches in one file. This leads to an ill-formed document that violates every XML format known to the human race and other nearby civilisations. This parser will take a bowdlerised version of this output that is wrapped in a blast_aggregate element.
The massaged form is generated by stripping the XML element and DOCTYPE elements and wrapping all the classes in a single blast_aggregate element. In Linux, this can be done with:-
#!/bin/sh # Converts a Blast XML output to something vaguely well-formed # for parsing. # Use: blast_aggregate# strips all <?xml> and <!DOCTYPE> tags # encapsulates the multiple <BlastOutput> elements into <blast_aggregator> sed '/>?xml/d' $1 | sed '/<!DOCTYPE/d' | sed '1i\ <blast_aggregate> $a\ </blast_aggregate>' > $2
- Author:
- David Huen
-
Field Summary
FieldsModifier and TypeFieldDescriptionorg.biojava.bio.program.sax.blastxml.StAXFeatureHandler
Nesting class that provides callback interfaces to nested class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addHandler
(ElementRecognizer rec, org.biojava.bio.program.sax.blastxml.StAXHandlerFactory handler) Adds a feature to the Handler attribute of the StAXFeatureHandler objectvoid
endElement
(String nsURI, String localName, String qName, StAXContentHandler handler) Handles basic exit processing.void
endElementHandler
(String nsURI, String localName, String qName, StAXContentHandler handler) get the SeqIOListener for this parservoid
setContentHandler
(ContentHandler listener) sets the ContentHandler for this objectvoid
startElement
(String nsURI, String localName, String qName, Attributes attrs, DelegationManager dm) we override the superclass startElement method so we can determine the the start tag type and use it to set up delegation for the superclass.Methods inherited from class org.biojava.utils.stax.StAXContentHandlerBase
characters, endPrefixMapping, endTree, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping, startTree
-
Field Details
-
staxenv
public org.biojava.bio.program.sax.blastxml.StAXFeatureHandler staxenvNesting class that provides callback interfaces to nested class
-
-
Constructor Details
-
BlastXMLParser
public BlastXMLParser()
-
-
Method Details
-
setContentHandler
sets the ContentHandler for this object -
startElement
public void startElement(String nsURI, String localName, String qName, Attributes attrs, DelegationManager dm) throws SAXException we override the superclass startElement method so we can determine the the start tag type and use it to set up delegation for the superclass.- Specified by:
startElement
in interfaceStAXContentHandler
- Parameters:
nsURI
- Description of the ParameterlocalName
- Description of the ParameterqName
- Description of the Parameterattrs
- Description of the Parameterdm
- Description of the Parameter- Throws:
SAXException
- Description of the Exception
-
endElementHandler
public void endElementHandler(String nsURI, String localName, String qName, StAXContentHandler handler) throws SAXException - Throws:
SAXException
-
addHandler
protected void addHandler(ElementRecognizer rec, org.biojava.bio.program.sax.blastxml.StAXHandlerFactory handler) Adds a feature to the Handler attribute of the StAXFeatureHandler object- Parameters:
rec
- The feature to be added to the Handler attributehandler
- The feature to be added to the Handler attribute
-
getListener
get the SeqIOListener for this parser -
endElement
public void endElement(String nsURI, String localName, String qName, StAXContentHandler handler) throws SAXException Handles basic exit processing.- Specified by:
endElement
in interfaceStAXContentHandler
- Overrides:
endElement
in classStAXContentHandlerBase
- Parameters:
nsURI
- Description of the ParameterlocalName
- Description of the ParameterqName
- Description of the Parameterhandler
- Description of the Parameter- Throws:
SAXException
- Description of the Exception
-