[Biojava-l] Re: Biojava query

mark.schreiber at group.novartis.com mark.schreiber at group.novartis.com
Thu Nov 25 20:04:47 EST 2004


Hi Russell -

This is a script I use to see which blast items are treated as what kind 
of events. Note that the object model doesn't capture everything from a 
report but you can always extend or write your own listener that gets what 
you want. Use the EchoBlast program to figure out which events you need to 
listen for...

import org.xml.sax.*;
import java.io.*;
import org.biojava.bio.program.sax.*;
import org.biojava.bio.program.ssbind.*;
import org.biojava.bio.search.*;

/**
 * <p> Echo's events from a blast like sax parser</p>
 * @author Mark Schreiber
 * @version 1.0
 */

public class BlastEcho {
  public BlastEcho() {
  }

  private void echo (InputSource source) throws IOException, SAXException{
    //make a BlastLikeSAXParser
    BlastLikeSAXParser parser = new BlastLikeSAXParser();
    parser.setModeLazy();

    ContentHandler handler = new SeqSimilarityAdapter();
    SearchContentHandler scHandler = new EchoSCHandler();
    ((SeqSimilarityAdapter)handler).setSearchContentHandler(scHandler);

    parser.setContentHandler(handler);
    parser.parse(source);
  }

  private class EchoSCHandler extends SearchContentAdapter{
    public void startHit(){
      System.out.println("startHit()");
    }
    public void endHit(){
      System.out.println("endHit()");
    }
    public void startSubHit(){
      System.out.println("startSubHit()");
    }
    public void endSubHit(){
      System.out.println("endSubHit()");
    }
    public void startSearch(){
      System.out.println("startSearch");
    }
    public void endSearch(){
      System.out.println("endSearch");
    }
    public void addHitProperty(Object key, Object val){
      System.out.println("\tHitProp:\t"+key+": "+val);
    }
    public void addSearchProperty(Object key, Object val){
      System.out.println("\tSearchProp:\t"+key+": "+val);
    }
    public void addSubHitProperty(Object key, Object val){
      System.out.println("\tSubHitProp:\t"+key+": "+val);
    }
  }

  public static void main(String[] args) throws Exception{
    InputSource is = new InputSource(new FileInputStream(args[0]));
    BlastEcho blastEcho = new BlastEcho();
    blastEcho.echo(is);
  }

}

Mark Schreiber
Principal Scientist (Bioinformatics)

Novartis Institute for Tropical Diseases (NITD)
10 Biopolis Road
#05-01 Chromos
Singapore 138670
www.nitd.novartis.com

phone +65 6722 2973
fax  +65 6722 2910





"Smithies, Russell" <Russell.Smithies at agresearch.co.nz>
11/26/2004 08:42 AM

 
        To:     Mark Schreiber/GP/Novartis at PH
        cc: 
        Subject:        Biojava query



Hi Mark,

Just a quick question about Blast parsing,
How do you get the length of the query sequence with the parser example
on BJinA?
It's not in the annotations of the SeqSimilaritySearchResult. 
That only has databaseId, queryId, program, and version :-(
 


Russell 
=======================================================================
Attention: The information contained in this message and/or attachments
from AgResearch Limited is intended only for the persons or entities
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipients is prohibited by AgResearch
Limited. If you have received this message in error, please notify the
sender immediately.
=======================================================================





More information about the Biojava-l mailing list