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 */ 021 022package org.biojava.bio.program.ssbind; 023 024import org.biojava.bio.search.SearchContentHandler; 025import org.biojava.utils.stax.StAXContentHandler; 026import org.xml.sax.Attributes; 027import org.xml.sax.SAXException; 028 029/** 030 * <code>HSPSummaryStAXHandler</code> handles the HSPSummary element 031 * of BioJava BlastLike XML. 032 * 033 * @author Keith James 034 * @since 1.3 035 */ 036public class HSPSummaryStAXHandler extends SeqSimilarityStAXHandler 037{ 038 public static final StAXHandlerFactory HSPSUMMARY_HANDLER_FACTORY = 039 new StAXHandlerFactory() 040 { 041 public StAXContentHandler getHandler(SeqSimilarityStAXAdapter ssContext) 042 { 043 return new HSPSummaryStAXHandler(ssContext); 044 } 045 }; 046 047 HSPSummaryStAXHandler(SeqSimilarityStAXAdapter ssContext) 048 { 049 super(ssContext); 050 } 051 052 protected void handleStartElement(String nsURI, 053 String localName, 054 String qName, 055 Attributes attrs) 056 throws SAXException 057 { 058 SearchContentHandler sch = ssContext.getSearchContentHandler(); 059 060 // score, expectValue, numberOfIdentities, alignmentSize and 061 // percentageIdentity always present in valid XML 062 sch.addSubHitProperty("score", attrs.getValue("score")); 063 sch.addSubHitProperty("expectValue", attrs.getValue("expectValue")); 064 sch.addSubHitProperty("numberOfIdentities", 065 attrs.getValue("numberOfIdentities")); 066 sch.addSubHitProperty("alignmentSize", 067 attrs.getValue("alignmentSize")); 068 sch.addSubHitProperty("percentageIdentity", 069 attrs.getValue("percentageIdentity")); 070 071 String attr; 072 attr = attrs.getValue("bitScore"); 073 if (attr != null) 074 sch.addSubHitProperty("bitScore", attr); 075 076 attr = attrs.getValue("pValue"); 077 if (attr != null) 078 sch.addSubHitProperty("pValue", attr); 079 080 attr = attrs.getValue("numberOfIdentities"); 081 if (attr != null) 082 sch.addSubHitProperty("numberOfIdentities", attr); 083 084 attr = attrs.getValue("numberOfPositives"); 085 if (attr != null) 086 sch.addSubHitProperty("numberOfPositives", attr); 087 088 attr = attrs.getValue("querySequenceType"); 089 if (attr != null) 090 sch.addSubHitProperty("querySequenceType", attr); 091 092 attr = attrs.getValue("hitSequenceType"); 093 if (attr != null) 094 sch.addSubHitProperty("subjectSequenceType", attr); 095 096 // These are not explicitly set by BLASTP 097 attr = attrs.getValue("queryStrand"); 098 if (attr != null) 099 sch.addSubHitProperty("queryStrand", attr); 100 101 attr = attrs.getValue("hitStrand"); 102 if (attr != null) 103 sch.addSubHitProperty("subjectStrand", attr); 104 105 attr = attrs.getValue("queryFrame"); 106 if (attr != null) 107 sch.addSubHitProperty("queryFrame", attr); 108 109 attr = attrs.getValue("hitFrame"); 110 if (attr != null) 111 sch.addSubHitProperty("subjectFrame", attr); 112 } 113}