[Biojava-dev] How to use SimilarityPairBuilder?

Tim Troup troup at dcs.gla.ac.uk
Tue Aug 5 04:56:48 EDT 2003


Hi,

I am still wrestling with the SimilarityPairBuilder class. As mentioned 
earlier in this thread you cannot setQueryHolder with a DummySequenceDB or 
setSubjectDBInstallation with DummySequenceDBInstallation which makes 
sense as you need the real sequences to build the features.

In my particular case I retrieve Blast output over the web (from NCBI) as 
i do not have the target database held locally. So i thought i would try 
to set the SequenceDBInstallation to be a SimpleSequenceDBInstallation 
holding an instance of NCBISequenceDB as shown below.

However when i try this approach a null pointer gets thrown as shown in
the stack trace. From looking at the BioJava source code it would appear 
that the subHitData Map in class SimilarityPairBuilder does not have a key 
called HitId OR if it does its value is null.

Any suggestions as to what i am doing wrong in this case would be greatly
appreciated.


Thanks again,

Tim Troup


***********
Code snipet
***********

InputStream is =input;
BlastLikeSAXParser spparser = new BlastLikeSAXParser();
//make the SAX event adapter that will pass events to a Handler.
SeqSimilarityAdapter spadapter = new SeqSimilarityAdapter();
//set the parsers SAX event adapter
spparser.setContentHandler(spadapter);

SimilarityPairBuilder spbuilder = new SimilarityPairBuilder();
spbuilder.setDatabaseID(databaseId);
spbuilder.setQueryID(queryId);

HashSequenceDB hsdb = new HashSequenceDB();
hsdb.addSequence(queryId, querySeq);
spbuilder.setQuerySeqHolder(hsdb);

SimpleSequenceDBInstallation ssdbi = new SimpleSequenceDBInstallation();
Set s = new HashSet();
NCBISequenceDB ncbiSDB = new NCBISequenceDB();
ssdbi.addSequenceDB(ncbiSDB, s);

System.out.println(ncbiSDB.getName());

spbuilder.setSubjectDBInstallation(ssdbi);
spbuilder.setDatabaseID(ncbiSDB.getName());

//register builder with adapter
spadapter.setSearchContentHandler(spbuilder);
//parse the file, after this the result List will be populated with
//SeqSimilaritySearchResults
spparser.parse(new InputSource(is));




*************
Stack Trace
*************


java.lang.IllegalArgumentException: identifier was null
        at
org.biojava.bio.seq.db.SimpleSequenceDBInstallation.getSequenceDB(SimpleSequenceDBInstallation.java:187)
        at
org.biojava.bio.program.ssbind.ViewSequenceFactory.makeSubjectViewSequence(ViewSequenceFactory.java:138)
        at
org.biojava.bio.program.ssbind.SimilarityPairBuilder.makeSimilarity(SimilarityPairBuilder.java:279)
        at
org.biojava.bio.program.ssbind.SimilarityPairBuilder.endSubHit(SimilarityPairBuilder.java:180)
        at
org.biojava.bio.program.ssbind.HSPStAXHandler.handleEndElement(HSPStAXHandler.java:79)
        at
org.biojava.bio.program.ssbind.SeqSimilarityStAXHandler.endElement(SeqSimilarityStAXHandler.java:104)
        at
org.biojava.utils.stax.SAX2StAXAdaptor.endElement(SAX2StAXAdaptor.java:153)
        at
org.biojava.bio.program.ssbind.SeqSimilarityAdapter.endElement(SeqSimilarityAdapter.java:136)
        at
org.biojava.bio.program.sax.AbstractNativeAppSAXParser.endElement(AbstractNativeAppSAXParser.java:301)
        at
org.biojava.bio.program.sax.HitSectionSAXParser.interpretHSP(HitSectionSAXParser.java:360)
        at
org.biojava.bio.program.sax.HitSectionSAXParser.firstHSPEvent(HitSectionSAXParser.java:280)
        at
org.biojava.bio.program.sax.HitSectionSAXParser.interpret(HitSectionSAXParser.java:251)
        at
org.biojava.bio.program.sax.HitSectionSAXParser.parse(HitSectionSAXParser.java:118)
        at
org.biojava.bio.program.sax.BlastSAXParser.hitsSectionReached(BlastSAXParser.java:607)
	at
org.biojava.bio.program.sax.BlastSAXParser.interpret(BlastSAXParser.java:316)
        at
org.biojava.bio.program.sax.BlastSAXParser.parse(BlastSAXParser.java:165)
        at
org.biojava.bio.program.sax.BlastLikeSAXParser.onNewDataSet(BlastLikeSAXParser.java:311)
        at
org.biojava.bio.program.sax.BlastLikeSAXParser.interpret(BlastLikeSAXParser.java:274)
        at
org.biojava.bio.program.sax.BlastLikeSAXParser.parse(BlastLikeSAXParser.java:160)
        at
BlastParserImpl.parseWithSimilarityPairBuilder(BlastParserImpl.java:176)
        at BlastParser.main(BlastParser.java:27)



More information about the biojava-dev mailing list