Package org.biojava.bio.program.sax
Class ClustalWAlignmentSAXParser
- java.lang.Object
-
- org.biojava.bio.program.sax.ClustalWAlignmentSAXParser
-
- All Implemented Interfaces:
org.xml.sax.XMLReader
public class ClustalWAlignmentSAXParser extends java.lang.ObjectA SAX2 parser for dealing with a multiple sequence alignment as produced by ClustalW outputing .aln format. For example,K1C0_XENLA/125-441 DKVHALETANTELERKIKEWYEKQRPGSSSGDGAKDYSKYYT K1C4_XENLA/81-396 EKVRALEAANADLELKIREWYEKQK-GSGIGAGSKDFSKYFE K1C5_XENLA/73-384 DRVRSLEQANHELELKIREYLDKK-----AAVGSLDYSGYYN keratin15 DKVRALEEANADLEVKIHDWYQKQTP----ASPECDYSQYFK K1C0_XENLA/125-441 -----AKFLLQNDNARLAADDFKMKFEN-------------- K1C4_XENLA/81-396 -----SRVVLQIDNAKLAADDFRLKFEN-------------- K1C5_XENLA/73-384 -----TRLVLSIDNAKLAADDFKIKYES-------------- keratin15 -----SRVILEIDNARLAADDFRLKYEN--------------
Please note, this parser reads the whole alignment in to core memory and thus does not scale to work with very large alignments on low-end hardware.
Please also note that this class has not been tested with many version of CLUSTAL W. Copyright © 2000,2001 Cambridge Antibody Technology.
Primary author -
- Simon Brocklehurst (CAT)
- Neil Benn (CAT)
- Lawrence Bower (CAT)
- Derek Crockford (CAT)
- Tim Dilks (CAT)
- Colin Hardman (CAT)
- Stuart Johnston (CAT)
- Version:
- 1.0
- Author:
- Cambridge Antibody Technology (CAT), Greg Cox
-
-
Field Summary
Fields Modifier and Type Field Description protected intiStateprotected java.lang.StringoFullNamespacePrefixprotected org.xml.sax.ContentHandleroHandlerprotected java.lang.StringoNamespacePrefixprotected booleantNamespacePrefixesprotected booleantNamespaces
-
Constructor Summary
Constructors Constructor Description ClustalWAlignmentSAXParser()Initialises internal state Sets namespace prefix to "biojava"
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPrefixMapping(java.lang.String poPrefix, java.lang.String poURI)Adds a namespace prefix to URI mapping as (key,value) pairs.protected voidchangeState(int piState)Centralise chaining of iState field to help with debugging.protected voidcharacters(char[] ch, int start, int length)Utility method to centralize the sending of a SAX characters message a document handler.protected voidendElement(org.biojava.bio.program.sax.QName poQName)Utility method to centralize the sending of a SAX endElement message a document handler.org.xml.sax.ContentHandlergetContentHandler()Return the content handler.protected java.io.BufferedReadergetContentStream(org.xml.sax.InputSource poSource)Create a stream from an an InputSource, picking the correct stream according to order of precedance.org.xml.sax.DTDHandlergetDTDHandler()Do-nothing implementation of interface methodorg.xml.sax.EntityResolvergetEntityResolver()Do-nothing implementation of interface methodorg.xml.sax.ErrorHandlergetErrorHandler()Do-nothing implementation of interface methodbooleangetFeature(java.lang.String poName)Do-nothing implementation of interface methodjava.lang.StringgetNamespacePrefix()DescribegetNamespacePrefixmethod here.booleangetNamespacePrefixes()Support SAX2 configuration of namespace support of parser.booleangetNamespaces()Support SAX2 configuration of namespace support of parser.java.lang.ObjectgetProperty(java.lang.String name)Do-nothing implementation of interface methodjava.lang.StringgetURIFromPrefix(java.lang.String poPrefix)Gets the URI for a namespace prefix, given that prefix, or null if the prefix is not recognised.voidparse(java.lang.String poSystemId)Full implementation of interface method.voidparse(org.xml.sax.InputSource poSource)Describe 'parse' method here.java.lang.Stringprefix(java.lang.String poElementName)Given an unprefixed element name, returns a new element name with a namespace prefixvoidsetContentHandler(org.xml.sax.ContentHandler poHandler)Allow an application to register a content event handler.voidsetDTDHandler(org.xml.sax.DTDHandler handler)Do-nothing implementation of interface methodvoidsetEntityResolver(org.xml.sax.EntityResolver resolver)Do-nothing implementation of interface methodvoidsetErrorHandler(org.xml.sax.ErrorHandler handler)Do-nothing implementation of interface methodvoidsetFeature(java.lang.String poName, boolean value)Handles support for ReasoningDomain and Namespace-prefixesvoidsetNamespacePrefix(java.lang.String poPrefix)voidsetProperty(java.lang.String name, java.lang.Object value)Do-nothing implementation of interface methodprotected voidstartElement(org.biojava.bio.program.sax.QName poQName, org.xml.sax.Attributes atts)Utility method to centralize sending of a SAX startElement message to document handler
-
-
-
Field Detail
-
oHandler
protected org.xml.sax.ContentHandler oHandler
-
tNamespaces
protected boolean tNamespaces
-
tNamespacePrefixes
protected boolean tNamespacePrefixes
-
oNamespacePrefix
protected java.lang.String oNamespacePrefix
-
oFullNamespacePrefix
protected java.lang.String oFullNamespacePrefix
-
iState
protected int iState
-
-
Method Detail
-
parse
public void parse(org.xml.sax.InputSource poSource) throws java.io.IOException, org.xml.sax.SAXExceptionDescribe 'parse' method here.- Specified by:
parsein interfaceorg.xml.sax.XMLReader- Parameters:
poSource- -- Throws:
java.io.IOExceptionorg.xml.sax.SAXException
-
setContentHandler
public void setContentHandler(org.xml.sax.ContentHandler poHandler)
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:
setContentHandlerin interfaceorg.xml.sax.XMLReader- Parameters:
poHandler- aContentHandlerThe XML content handler- Throws:
java.lang.NullPointerException- If the handler argument is null
-
getContentHandler
public org.xml.sax.ContentHandler getContentHandler()
Return the content handler.- Specified by:
getContentHandlerin interfaceorg.xml.sax.XMLReader- Returns:
- a
ContentHandlerThe current content handler, or null if none has been registered.
-
parse
public void parse(java.lang.String poSystemId) throws java.io.IOException, org.xml.sax.SAXExceptionFull implementation of interface method.- Specified by:
parsein interfaceorg.xml.sax.XMLReader- Throws:
java.io.IOExceptionorg.xml.sax.SAXException
-
getFeature
public boolean getFeature(java.lang.String poName) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionDo-nothing implementation of interface method- Specified by:
getFeaturein interfaceorg.xml.sax.XMLReader- Throws:
org.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedException
-
setFeature
public void setFeature(java.lang.String poName, boolean value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionHandles support for ReasoningDomain and Namespace-prefixes- Specified by:
setFeaturein interfaceorg.xml.sax.XMLReader- Throws:
org.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedException
-
getProperty
public java.lang.Object getProperty(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionDo-nothing implementation of interface method- Specified by:
getPropertyin interfaceorg.xml.sax.XMLReader- Throws:
org.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedException
-
setProperty
public void setProperty(java.lang.String name, java.lang.Object value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionDo-nothing implementation of interface method- Specified by:
setPropertyin interfaceorg.xml.sax.XMLReader- Throws:
org.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedException
-
setEntityResolver
public void setEntityResolver(org.xml.sax.EntityResolver resolver)
Do-nothing implementation of interface method- Specified by:
setEntityResolverin interfaceorg.xml.sax.XMLReader
-
getEntityResolver
public org.xml.sax.EntityResolver getEntityResolver()
Do-nothing implementation of interface method- Specified by:
getEntityResolverin interfaceorg.xml.sax.XMLReader
-
setDTDHandler
public void setDTDHandler(org.xml.sax.DTDHandler handler)
Do-nothing implementation of interface method- Specified by:
setDTDHandlerin interfaceorg.xml.sax.XMLReader
-
getDTDHandler
public org.xml.sax.DTDHandler getDTDHandler()
Do-nothing implementation of interface method- Specified by:
getDTDHandlerin interfaceorg.xml.sax.XMLReader
-
setErrorHandler
public void setErrorHandler(org.xml.sax.ErrorHandler handler)
Do-nothing implementation of interface method- Specified by:
setErrorHandlerin interfaceorg.xml.sax.XMLReader
-
getErrorHandler
public org.xml.sax.ErrorHandler getErrorHandler()
Do-nothing implementation of interface method- Specified by:
getErrorHandlerin interfaceorg.xml.sax.XMLReader
-
startElement
protected void startElement(org.biojava.bio.program.sax.QName poQName, org.xml.sax.Attributes atts) throws org.xml.sax.SAXExceptionUtility method to centralize sending of a SAX startElement message to document handler- Parameters:
poQName- aQNamevalueatts- anAttributesvalue- Throws:
org.xml.sax.SAXException- if an error occurs
-
endElement
protected void endElement(org.biojava.bio.program.sax.QName poQName) throws org.xml.sax.SAXExceptionUtility method to centralize the sending of a SAX endElement message a document handler.- Parameters:
poQName- -- Throws:
org.xml.sax.SAXException- thrown ifthrown- if
-
characters
protected void characters(char[] ch, int start, int length) throws org.xml.sax.SAXExceptionUtility method to centralize the sending of a SAX characters message a document handler.- Parameters:
ch- -start- -length- -- Throws:
org.xml.sax.SAXException- thrown ifthrown- if
-
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
public void addPrefixMapping(java.lang.String poPrefix, java.lang.String poURI)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- aStringrepresentation of the namespace prefixpoURI- aStringrepresentation of the URI for the namespace prefix.
-
getURIFromPrefix
public java.lang.String getURIFromPrefix(java.lang.String poPrefix)
Gets the URI for a namespace prefix, given that prefix, or null if the prefix is not recognised.- Parameters:
poPrefix- aStringThe namespace prefix.
-
setNamespacePrefix
public void setNamespacePrefix(java.lang.String poPrefix)
- Parameters:
poPrefix- aStringvalue
-
getNamespacePrefix
public java.lang.String getNamespacePrefix()
DescribegetNamespacePrefixmethod here.- Returns:
- a
Stringvalue
-
prefix
public java.lang.String prefix(java.lang.String poElementName)
Given an unprefixed element name, returns a new element name with a namespace prefix- Returns:
- a
Stringvalue
-
getContentStream
protected java.io.BufferedReader getContentStream(org.xml.sax.InputSource poSource)
Create a stream from an an InputSource, picking the correct stream according to order of precedance.- Parameters:
poSource- anInputSourcevalue- Returns:
- a
BufferedReadervalue
-
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- anintvalue
-
-