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; 022//import org.biojava.utils.stax.*; 023import org.xml.sax.Attributes; 024import org.xml.sax.SAXException; 025 026/** 027 * 028 * Handles the AGAVE <cds> element 029 * 030 * @author Hanning Ni Doubletwist Inc 031 */ 032public class AGAVECdsHandler 033 extends StAXFeatureHandler 034 035{ 036 public static final StAXHandlerFactory AGAVE_CDS_HANDLER_FACTORY 037 = new StAXHandlerFactory() { 038 public StAXContentHandler getHandler(StAXFeatureHandler staxenv) { 039 return new AGAVECdsHandler(staxenv); 040 } 041 }; 042 043 044 AGAVECdsHandler(StAXFeatureHandler staxenv) { 045 // setup up environment stuff 046 super( staxenv ); 047 featureListener = staxenv.featureListener; 048 setHandlerCharacteristics("cds", true); 049 050 super.addHandler(new ElementRecognizer.ByLocalName("bio_sequence"), 051 AGAVEBioSequenceHandler.AGAVE_BIO_SEQUENCE_HANDLER_FACTORY); 052 } 053 054 055 public void startElementHandler( 056 String nsURI, 057 String localName, 058 String qName, 059 Attributes attrs) 060 throws SAXException 061 { 062 featureTemplate.type = "cDNA" ; 063 } 064 065 066 /** 067 protected Feature.Template createTemplate() { 068 // create Gene Template for this 069 StrandedFeature.Template st = new StrandedFeature.Template(); 070 071 // assume feature set to describe a transcript 072 st.type = "cds"; 073 st.strand = StrandedFeature.UNKNOWN; 074 // set up annotation bundle 075 st.annotation = new SmallAnnotation(); 076 st.location = new Location.EmptyLocation(); 077 078 if( staxenv != null ) 079 staxenv. subFeatures .add( this ) ; 080 081 return st; 082 } 083 **/ 084} 085