001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021package org.biojava.bio.seq.io.agave;
022import org.xml.sax.Attributes;
023import org.xml.sax.SAXException;
024
025 /**
026  * sequence_map
027  *
028  * @author Hanning Ni    Doubletwist Inc
029  */
030public class AGAVESeqMapHandler
031               extends StAXFeatureHandler
032
033{
034  public static final StAXHandlerFactory AGAVE_SEQ_MAP_HANDLER_FACTORY
035    = new StAXHandlerFactory() {
036    public StAXContentHandler getHandler(StAXFeatureHandler staxenv) {
037      return new AGAVESeqMapHandler(staxenv);
038    }
039  };
040
041
042  AGAVESeqMapHandler(StAXFeatureHandler staxenv) {
043    // setup up environment stuff
044    super( staxenv );
045    featureListener = staxenv.featureListener;
046    setHandlerCharacteristics("sequence_map", true);
047
048    // setup handlers
049       //
050       super.addHandler(new ElementRecognizer.ByLocalName("note"),
051         AGAVENotePropHandler.AGAVE_NOTE_PROP_HANDLER_FACTORY);
052       //
053     //  super.addHandler(new ElementRecognizer.ByLocalName("computation"),
054     //    AGAVEComputationHandler.AGAVE_COMPUTATION_HANDLER_FACTORY);
055      super.addHandler(new ElementRecognizer.ByLocalName("annotations"),
056         AGAVEAnnotationsHandler.AGAVE_ANNOTATIONS_HANDLER_FACTORY);
057
058  }
059
060
061
062  public void startElementHandler(
063                String nsURI,
064                String localName,
065                String qName,
066                Attributes attrs)
067                throws SAXException
068  {
069      try{
070      featureListener.startSequence();
071      boolean forFeature = false ;
072      setProperty( "label",  attrs.getValue("label") , forFeature) ;
073      }catch(Exception e){
074         throw new SAXException( e.getMessage() ) ;
075      }
076  }
077
078  /**
079   protected Feature.Template createTemplate() {
080    // create Gene Template for this
081    StrandedFeature.Template st = new StrandedFeature.Template();
082
083    // assume feature set to describe a transcript
084    st.type = "sequence_map";
085    st.strand = StrandedFeature.UNKNOWN;
086    // set up annotation bundle
087    st.annotation = annot;
088    st.location = new  Location.EmptyLocation();
089    if( staxenv != null )
090        staxenv. subFeatures .add( this ) ;
091
092    return st;
093  }**/
094
095
096
097}
098