Bild eines Drachen Homepage von Jörg Rüdenauer Bild eines Raben

Studium Software Worte Ich
Zurück Home

How to parse the search results

The final step is to parse the results of the search and use them within the Biojava frame work - i.e., to create a SeqSimilaritySearchResults. Biojava provides some handy classes that do the work for you if you plug them together in the right way.

Firstly, there's a class called BlastLikeSAXParser in the package org.biojava.bio.program.sax. This class parses the search results and generates SAX events. These events can be used by a BlastLikeSearchBuilder in the package org.biojava.bio.program.ssbind to generate the SearchResults.

I'll admit that this is not the direct solution that I'd have liked, but I found no other. I suspect that this solution is quite a bit slower than Bioperl (especially since it uses the SequenceDB internally, and my implementation of that is quite slow, as you saw). It also has the disadvantage that it can only parse one special form of the BLAST output, and it even doesn't officially support the latest version of BLAST. But it works, and that's the main point ;-)

At first, there are some preparations do be done for all these classes. The SearchBuilder needs a SubjectDB and a QuerySeqHolder, which are both SequenceDBs, and in this case, are both the same DB. It also needs the ID of the query sequence (though the method is called setQuerySeq, not setQuerySeqID...). The SAXParser itself must be set to 'lazy', otherwise it cannot handle the newest BLAST versions output. To connect the SearchBuilder and the SAXParser, an Adapter class is needed.

java.util.LinkedList resultList = new java.util.LinkedList(); BlastLikeSearchBuilder blsb = new BlastLikeSearchBuilder(resultList); blsb.setSubjectDBInstallation(this.seqDBs); blsb.setSubjectDB(db.getName()); blsb.setQuerySeqHolder(db); blsb.setQuerySeq(qSeqID); BlastLikeSAXParser blsp = new BlastLikeSAXParser(); blsp.setModeLazy(); SeqSimilarityAdapter adapter = new SeqSimilarityAdapter(); adapter.setSearchContentHandler(blsb); blsp.setContentHandler(adapter);

Now we can connect the output stream of the BLAST program with the BlastLikeSAXParser, and parse it to get the results. The SearchBuilder has a public method makeSearchResult(), but that is the wrong method. The results are really in the List that was given to the Builder at creation time. In my case, there always seems to be only one element in that list, but you never know, so I construct an extra list with all SearchHits, and a new SearchResult out of that list.

blsp.parse(new InputSource(blast.getInputStream())); SeqSimilaritySearchResult result = null; LinkedList hitList = new LinkedList(); if (resultList.size() > 0) { Iterator it = resultList.iterator(); while (it.hasNext()) { SeqSimilaritySearchResult sssr = (SeqSimilaritySearchResult) it.next(); hitList.addAll(sssr.getHits()); } it = resultList.iterator(); SequenceDBSearchResult sr = (SequenceDBSearchResult) it.next(); result = new SequenceDBSearchResult(sr.getSequenceDB(), sr.getSearchParameters(), sr.getQuerySequence(), sr.getAnnotation(), hitList); } return result;

How to execute a BLAST search
How to implement a SequenceDB
The general idea
Download the complete code


URL dieser Seite: http://www.joerg-ruedenauer.de/Software/blast/blast3.html
Autor dieser Seite: Jörg Rüdenauer
Letzte Änderung am: 14.07.2002
Haftungsausschluss


L-Space now!     Valid XHTML 1.0!     Valid CSS!