public class BlastXMLParser extends StAXContentHandlerBase
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
Modifier and Type | Field and Description |
---|---|
org.biojava.bio.program.sax.blastxml.StAXFeatureHandler |
staxenv
Nesting class that provides callback interfaces to nested class
|
Constructor and Description |
---|
BlastXMLParser() |
Modifier and Type | Method and Description |
---|---|
protected void |
addHandler(ElementRecognizer rec,
org.biojava.bio.program.sax.blastxml.StAXHandlerFactory handler)
Adds a feature to the Handler attribute of the StAXFeatureHandler object
|
void |
endElement(String nsURI,
String localName,
String qName,
StAXContentHandler handler)
Handles basic exit processing.
|
void |
endElementHandler(String nsURI,
String localName,
String qName,
StAXContentHandler handler)
Element specific exit handler Subclass to do anything useful.
|
ContentHandler |
getListener()
get the SeqIOListener for this parser
|
void |
setContentHandler(ContentHandler listener)
sets the ContentHandler for this object
|
void |
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.
|
characters, endPrefixMapping, endTree, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping, startTree
public org.biojava.bio.program.sax.blastxml.StAXFeatureHandler staxenv
public BlastXMLParser()
public void setContentHandler(ContentHandler listener)
public void startElement(String nsURI, String localName, String qName, Attributes attrs, DelegationManager dm) throws SAXException
startElement
in interface StAXContentHandler
nsURI
- Description of the ParameterlocalName
- Description of the ParameterqName
- Description of the Parameterattrs
- Description of the Parameterdm
- Description of the ParameterSAXException
- Description of the Exceptionpublic void endElementHandler(String nsURI, String localName, String qName, StAXContentHandler handler) throws SAXException
nsURI
- Description of the ParameterlocalName
- Description of the ParameterqName
- Description of the Parameterhandler
- Description of the ParameterSAXException
- Description of the Exceptionprotected void addHandler(ElementRecognizer rec, org.biojava.bio.program.sax.blastxml.StAXHandlerFactory handler)
rec
- The feature to be added to the Handler attributehandler
- The feature to be added to the Handler attributepublic ContentHandler getListener()
public void endElement(String nsURI, String localName, String qName, StAXContentHandler handler) throws SAXException
endElement
in interface StAXContentHandler
endElement
in class StAXContentHandlerBase
nsURI
- Description of the ParameterlocalName
- Description of the ParameterqName
- Description of the Parameterhandler
- Description of the ParameterSAXException
- Description of the ExceptionCopyright © 2014 BioJava. All rights reserved.