[Biojava-l] Extending the default SAX handlers

Tracy, Adam Adam_Tracy at affymetrix.com
Fri May 14 13:59:26 EDT 2004


hello -

I'm working with the SAX based BLAST parsing kit here, and have run into a
problem that seems to have been noted by some other posts, namely that the
"MatchConsensus" fragment of the HSP's is not kept in the
SeqSimilaritySearchSubHit item after parsing.  I need that.  

After perusing the framework, I came across AlignmentStAXHanlder, and
extended it with another call to addHandler() in the creator method for
another private inner class that I added to the class, much in the same
pattern as how it was adding it's hitSequence,and subjectSequence fragments:

  private class MatchConsensusStAXHandler extends StringElementHandlerBase {
    private SearchContentHandler sch;
    public void startElement(
      String nsURI,
      String localName,
      String qName,
      Attributes attrs,
      DelegationManager dm)
      throws SAXException {
      super.startElement(nsURI, localName, qName, attrs, dm);
    }
    protected void setStringValue(String s) throws SAXException {
       sch = ssContext.getSearchContentHandler();
       sch.addSubHitProperty("matchConsensus", s);
    }
  }

Now, when I iterate over the SeqSimilaritySearchSubHit items, I can get at
the match consensus, simply by calling
sh.getAnnotation().getProperty("matchConsensus");

HOWEVER, I don't want to modify kernel code in order to get this behavior.
I've been looking for a way to easily plug in my own extension here, either
by subclassing the right class, or registering the above handler somehow,
but I cannot seem to get at that without subclassing all the classes above
the alignment handler in the data structure hierarchy, and initializing them
myself.  I believe, if AlignmentStAXHandler.ALIGNMENT_HANDLER_FACTORY was
not declared as final, I would probably be able to register my own subclass
of AlignmentStAXHandler there, with this extended behavior.  But darn, I
can't.

Thanks in advance for any help.

ant



--------
Adam Tracy | Staff Software Engineer | CIS Software Operations AFFYMETRIX,
INC. | 6550 Vallejo St. Suite 100 | Emeryville, CA 94608 | Tel: 510-428-8536




More information about the Biojava-l mailing list