Package org.biojava.bio.program.sax
Class FastaSearchSAXParser
java.lang.Object
org.biojava.bio.program.sax.FastaSearchSAXParser
- All Implemented Interfaces:
SearchContentHandler
,XMLReader
FastaSearchSAXParser
is a SAX2 compliant parser for
'-m 10' format output from the the Fasta search program (see the
Fasta documentation for details of this format).
Versions of Fasta supported are as follows. Note that the compile time option -DM10_CONS should be used to allow correct reporting of the number of matches in HSPSummary elements
- 33t07
- 33t08 (current tests are against output from this version)
The SAX2 events produced are as if the input to the parser was an XML file validating against the BioJava BlastLikeDataSetCollection DTD. There is no requirement for an intermediate conversion of native output to XML format.
- Since:
- 1.2
- Author:
- Keith James
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
protected String
protected ContentHandler
protected String
protected boolean
protected boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHitProperty
(Object key, Object value) TheaddHitProperty
method adds a key/value pair containing some property of a particular hit.void
addPrefixMapping
(String poPrefix, String poURI) Adds a namespace prefix to URI mapping as (key,value) pairs.void
addSearchProperty
(Object key, Object value) TheaddSearchProperty
method adds a key/value pair containing some property of the overall search result.void
addSubHitProperty
(Object key, Object value) TheaddSubHitProperty
method adds a key/value pair containing some property of a particular subhit.protected void
changeState
(int piState) Centralise chaining of iState field to help with debugging.protected void
characters
(char[] ch, int start, int length) Utility method to centralize the sending of a SAX characters message a document handler.protected void
endElement
(org.biojava.bio.program.sax.QName poQName) Utility method to centralize the sending of a SAX endElement message a document handler.void
TheendHeader
method indicates the end of a formatted header.void
endHit()
TheendHit
method indicates the end of a formatted hit.void
TheendSearch
method indicates the end of useful search information.void
TheendSubHit
method indicates the end of a formatted subhit.Return the content handler.protected BufferedReader
getContentStream
(InputSource poSource) Create a stream from an an InputSource, picking the correct stream according to order of precedance.Do-nothing implementation of interface methodDo-nothing implementation of interface methodDo-nothing implementation of interface methodboolean
getFeature
(String poName) Do-nothing implementation of interface methodboolean
getMoreSearches
returns the state of theSearchContentHandler
with respect to further searches from its data source.DescribegetNamespacePrefix
method here.boolean
Support SAX2 configuration of namespace support of parser.boolean
Support SAX2 configuration of namespace support of parser.getProperty
(String name) Do-nothing implementation of interface methodgetURIFromPrefix
(String poPrefix) Gets the URI for a namespace prefix, given that prefix, or null if the prefix is not recognised.void
Full implementation of interface method.void
parse
(InputSource source) Do-nothing implementation of interface methodGiven an unprefixed element name, returns a new element name with a namespace prefixvoid
setContentHandler
(ContentHandler poHandler) Allow an application to register a content event handler.void
setDatabaseID
(String databaseID) setDatabaseID
identifies the database searched by a name, ID or URN.void
setDTDHandler
(DTDHandler handler) Do-nothing implementation of interface methodvoid
setEntityResolver
(EntityResolver resolver) Do-nothing implementation of interface methodvoid
setErrorHandler
(ErrorHandler handler) Do-nothing implementation of interface methodvoid
setFeature
(String poName, boolean value) Handles support for ReasoningDomain and Namespace-prefixesvoid
setMoreSearches
(boolean value) setMoreSearches
sets the state of theSearchContentHandler
's expectation of receiving more results.void
setNamespacePrefix
(String poPrefix) void
setProperty
(String name, Object value) Do-nothing implementation of interface methodvoid
setQueryID
(String queryID) setQueryID
identifies the query sequence by a name, ID or URN.void
setQuerySeq
(String identifier) Deprecated.void
setSubjectDB
(String identifier) Deprecated.usesetDatabaseID
instead.protected void
startElement
(org.biojava.bio.program.sax.QName poQName, Attributes atts) Utility method to centralize sending of a SAX startElement message to document handlervoid
ThestartHeader
method indicates the start of a formatted header.void
startHit()
ThestartHit
method indicates the start of a formatted hit.void
ThestartSearch
method indicates the start of useful search information.void
ThestartSubHit
method indicates the start of a formatted subhit.
-
Field Details
-
oHandler
-
tNamespaces
protected boolean tNamespaces -
tNamespacePrefixes
protected boolean tNamespacePrefixes -
oNamespacePrefix
-
oFullNamespacePrefix
-
iState
protected int iState
-
-
Constructor Details
-
FastaSearchSAXParser
public FastaSearchSAXParser()Creates a newFastaSearchSAXParser
instance.
-
-
Method Details
-
parse
Do-nothing implementation of interface method- Specified by:
parse
in interfaceXMLReader
- Throws:
IOException
SAXException
-
getMoreSearches
Description copied from interface:SearchContentHandler
getMoreSearches
returns the state of theSearchContentHandler
with respect to further searches from its data source. Used for handling streams of search results.- Specified by:
getMoreSearches
in interfaceSearchContentHandler
- Returns:
- a
boolean
value.
-
setMoreSearches
Description copied from interface:SearchContentHandler
setMoreSearches
sets the state of theSearchContentHandler
's expectation of receiving more results. Used for handling streams of search results.- Specified by:
setMoreSearches
in interfaceSearchContentHandler
- Parameters:
value
- aboolean
value.
-
setQuerySeq
Deprecated.usesetQueryID
instead.setQuerySeq
identifies the query sequence by a name, ID or URN.- Parameters:
identifier
- aString
which should be an unique identifer for the sequence.
-
setQueryID
Description copied from interface:SearchContentHandler
setQueryID
identifies the query sequence by a name, ID or URN.- Specified by:
setQueryID
in interfaceSearchContentHandler
- Parameters:
queryID
- aString
which should be an unique identifer for the sequence.
-
setSubjectDB
Deprecated.usesetDatabaseID
instead.setSubjectDB
identifies the database searched by a name, ID or URN.- Parameters:
identifier
- aString
which should be an unique identifier for the database searched.
-
setDatabaseID
Description copied from interface:SearchContentHandler
setDatabaseID
identifies the database searched by a name, ID or URN.- Specified by:
setDatabaseID
in interfaceSearchContentHandler
- Parameters:
databaseID
- aString
which should be an unique identifier for the database searched.
-
startSearch
Description copied from interface:SearchContentHandler
ThestartSearch
method indicates the start of useful search information.- Specified by:
startSearch
in interfaceSearchContentHandler
-
addSearchProperty
Description copied from interface:SearchContentHandler
TheaddSearchProperty
method adds a key/value pair containing some property of the overall search result.- Specified by:
addSearchProperty
in interfaceSearchContentHandler
- Parameters:
key
- anObject
.value
- anObject
.
-
endSearch
Description copied from interface:SearchContentHandler
TheendSearch
method indicates the end of useful search information.- Specified by:
endSearch
in interfaceSearchContentHandler
-
startHeader
Description copied from interface:SearchContentHandler
ThestartHeader
method indicates the start of a formatted header. This usually contains information relevant to the search as a whole.- Specified by:
startHeader
in interfaceSearchContentHandler
-
endHeader
Description copied from interface:SearchContentHandler
TheendHeader
method indicates the end of a formatted header.- Specified by:
endHeader
in interfaceSearchContentHandler
-
startHit
Description copied from interface:SearchContentHandler
ThestartHit
method indicates the start of a formatted hit. This could be a single line, or a block of lines.- Specified by:
startHit
in interfaceSearchContentHandler
-
addHitProperty
Description copied from interface:SearchContentHandler
TheaddHitProperty
method adds a key/value pair containing some property of a particular hit.- Specified by:
addHitProperty
in interfaceSearchContentHandler
- Parameters:
key
- anObject
.value
- anObject
.
-
endHit
Description copied from interface:SearchContentHandler
TheendHit
method indicates the end of a formatted hit.- Specified by:
endHit
in interfaceSearchContentHandler
-
startSubHit
Description copied from interface:SearchContentHandler
ThestartSubHit
method indicates the start of a formatted subhit. There may be zero or more of these per hit.- Specified by:
startSubHit
in interfaceSearchContentHandler
-
addSubHitProperty
Description copied from interface:SearchContentHandler
TheaddSubHitProperty
method adds a key/value pair containing some property of a particular subhit.- Specified by:
addSubHitProperty
in interfaceSearchContentHandler
- Parameters:
key
- anObject
.value
- anObject
.
-
endSubHit
Description copied from interface:SearchContentHandler
TheendSubHit
method indicates the end of a formatted subhit.- Specified by:
endSubHit
in interfaceSearchContentHandler
-
setContentHandler
Allow an application to register a content event handler. If the application does not register a content handler, all content events reported by the SAX parser will be silently ignored.Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
- Specified by:
setContentHandler
in interfaceXMLReader
- Parameters:
poHandler
- aContentHandler
The XML content handler- Throws:
NullPointerException
- If the handler argument is null
-
getContentHandler
Return the content handler.- Specified by:
getContentHandler
in interfaceXMLReader
- Returns:
- a
ContentHandler
The current content handler, or null if none has been registered.
-
parse
Full implementation of interface method.- Specified by:
parse
in interfaceXMLReader
- Throws:
IOException
SAXException
-
getFeature
Do-nothing implementation of interface method- Specified by:
getFeature
in interfaceXMLReader
- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
setFeature
public void setFeature(String poName, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException Handles support for ReasoningDomain and Namespace-prefixes- Specified by:
setFeature
in interfaceXMLReader
- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
getProperty
Do-nothing implementation of interface method- Specified by:
getProperty
in interfaceXMLReader
- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
setProperty
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException Do-nothing implementation of interface method- Specified by:
setProperty
in interfaceXMLReader
- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
setEntityResolver
Do-nothing implementation of interface method- Specified by:
setEntityResolver
in interfaceXMLReader
-
getEntityResolver
Do-nothing implementation of interface method- Specified by:
getEntityResolver
in interfaceXMLReader
-
setDTDHandler
Do-nothing implementation of interface method- Specified by:
setDTDHandler
in interfaceXMLReader
-
getDTDHandler
Do-nothing implementation of interface method- Specified by:
getDTDHandler
in interfaceXMLReader
-
setErrorHandler
Do-nothing implementation of interface method- Specified by:
setErrorHandler
in interfaceXMLReader
-
getErrorHandler
Do-nothing implementation of interface method- Specified by:
getErrorHandler
in interfaceXMLReader
-
startElement
protected void startElement(org.biojava.bio.program.sax.QName poQName, Attributes atts) throws SAXException Utility method to centralize sending of a SAX startElement message to document handler- Parameters:
poQName
- aQName
valueatts
- anAttributes
value- Throws:
SAXException
- if an error occurs
-
endElement
Utility method to centralize the sending of a SAX endElement message a document handler.- Parameters:
poQName
- -
-
characters
Utility method to centralize the sending of a SAX characters message a document handler.- Parameters:
ch
- -start
- -length
- -
-
getNamespaces
public boolean getNamespaces()Support SAX2 configuration of namespace support of parser. -
getNamespacePrefixes
public boolean getNamespacePrefixes()Support SAX2 configuration of namespace support of parser. -
addPrefixMapping
Adds a namespace prefix to URI mapping as (key,value) pairs. This mapping can be looked up later to get URIs on request using the getURIFromPrefix method.- Parameters:
poPrefix
- aString
representation of the namespace prefixpoURI
- aString
representation of the URI for the namespace prefix.
-
getURIFromPrefix
Gets the URI for a namespace prefix, given that prefix, or null if the prefix is not recognised.- Parameters:
poPrefix
- aString
The namespace prefix.
-
setNamespacePrefix
- Parameters:
poPrefix
- aString
value
-
getNamespacePrefix
DescribegetNamespacePrefix
method here.- Returns:
- a
String
value
-
prefix
Given an unprefixed element name, returns a new element name with a namespace prefix- Returns:
- a
String
value
-
getContentStream
Create a stream from an an InputSource, picking the correct stream according to order of precedance.- Parameters:
poSource
- anInputSource
value- Returns:
- a
BufferedReader
value
-
changeState
protected void changeState(int piState) Centralise chaining of iState field to help with debugging. E.g. printing out value etc. All changes to iState should be made through this method.- Parameters:
piState
- anint
value
-
setQueryID
instead.