From: <gk...@us...> - 2010-01-08 17:12:22
|
Revision: 22510 http://gmod.svn.sourceforge.net/gmod/?rev=22510&view=rev Author: gk_fan Date: 2010-01-08 17:12:13 +0000 (Fri, 08 Jan 2010) Log Message: ----------- Changed XML parsing of BLAST results to use URIs instead of InputStreams, as it was causing errors in Java Web Start mode. Modified Paths: -------------- apollo/trunk/src/java/apollo/analysis/BlastXMLParser.java apollo/trunk/src/java/apollo/analysis/BlastXMLParserTest.java apollo/trunk/src/java/apollo/analysis/RemoteBlastNCBI.java Modified: apollo/trunk/src/java/apollo/analysis/BlastXMLParser.java =================================================================== --- apollo/trunk/src/java/apollo/analysis/BlastXMLParser.java 2010-01-08 16:53:07 UTC (rev 22509) +++ apollo/trunk/src/java/apollo/analysis/BlastXMLParser.java 2010-01-08 17:12:13 UTC (rev 22510) @@ -1,8 +1,6 @@ package apollo.analysis; import java.io.IOException; -import java.io.InputStream; -import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -12,8 +10,6 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; import org.xml.sax.SAXException; import apollo.datamodel.FeaturePair; @@ -44,23 +40,17 @@ { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); db = dbf.newDocumentBuilder(); - db.setEntityResolver(new EntityResolver() { - public InputSource resolveEntity(String publicId, String systemId) - { - return new InputSource(new StringReader("")); - } - }); } - public String parse(InputStream is, StrandedFeatureSetI results) throws SAXException, IOException, BlastXMLParserException + public String parse(String uri, StrandedFeatureSetI results) throws SAXException, IOException, BlastXMLParserException { - return parse(is, results, 1, 0, 0); + return parse(uri, results, 1, 0, 0); } - public String parse(InputStream is, StrandedFeatureSetI results, int strand, int genomicLength, int offset) throws + public String parse(String uri, StrandedFeatureSetI results, int strand, int genomicLength, int offset) throws SAXException, IOException, BlastXMLParserException { - Document doc = db.parse(is); + Document doc = db.parse(uri); String blast = getTextContent(doc.getElementsByTagName("BlastOutput_program").item(0)); String db = getTextContent(doc.getElementsByTagName("BlastOutput_db").item(0)); String type = blast + ":" + db; Modified: apollo/trunk/src/java/apollo/analysis/BlastXMLParserTest.java =================================================================== --- apollo/trunk/src/java/apollo/analysis/BlastXMLParserTest.java 2010-01-08 16:53:07 UTC (rev 22509) +++ apollo/trunk/src/java/apollo/analysis/BlastXMLParserTest.java 2010-01-08 17:12:13 UTC (rev 22510) @@ -1,13 +1,7 @@ package apollo.analysis; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; +import java.io.File; -import javax.xml.parsers.ParserConfigurationException; - -import org.xml.sax.SAXException; - import apollo.datamodel.StrandedFeatureSet; import junit.framework.TestCase; @@ -16,10 +10,10 @@ public void testParse() throws Exception { - FileInputStream fis = new FileInputStream("/Users/elee/blah/blast_3.xml"); + File f = new File("/Users/elee/blah/blast_3.xml"); BlastXMLParser parser = new BlastXMLParser(); StrandedFeatureSet results = new StrandedFeatureSet(); - parser.parse(fis, results); + parser.parse(f.toURL().toString(), results); } } Modified: apollo/trunk/src/java/apollo/analysis/RemoteBlastNCBI.java =================================================================== --- apollo/trunk/src/java/apollo/analysis/RemoteBlastNCBI.java 2010-01-08 16:53:07 UTC (rev 22509) +++ apollo/trunk/src/java/apollo/analysis/RemoteBlastNCBI.java 2010-01-08 17:12:13 UTC (rev 22510) @@ -30,6 +30,7 @@ private static final String ENCODING = "UTF-8"; private static final String BLAST_URL = "http://www.ncbi.nlm.nih.gov/blast/Blast.cgi?"; + //private static final String BLAST_URL = "http://130.14.29.110/blast/Blast.cgi?"; private static final int SLEEP = 3000; private static final Pattern RID_PATTERN = Pattern.compile("^\\s*RID\\s*=\\s*(\\w+)$"); private static final Pattern RTOE_PATTERN = Pattern.compile("^\\s*RTOE\\s*=\\s*(\\d+)$"); @@ -285,13 +286,14 @@ } is.close(); getUrl = new URL(createGetUrl(req, false)); - is = getUrl.openStream(); + + //is = getUrl.openStream(); BlastXMLParser parser = new BlastXMLParser(); - String type = parser.parse(is, cs.getResults(), strand, genomicLength, offset); + String type = parser.parse(getUrl.toString(), cs.getResults(), strand, genomicLength, offset); - is.close(); + //is.close(); if (cs.getResults().getForwardSet() != null) { System.out.println("forward hits: " + cs.getResults().getForwardSet().size()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |