[Bioperl-l] Parsing Blast Output

Wiepert, Mathieu Wiepert.Mathieu@mayo.edu
Tue, 11 Jun 2002 08:12:21 -0500


I got a bounce message, if this shows up twice, I apologize.


Hi,

I see that you copied the example from the RemoteBlast.pm, and it isn't
working.  I modified your code, and got an error from BPLite myself:

Can't locate object method "next_result" via package "Bio::Tools::BPlite" at
testremoteblast.pl line 32

Which is true (according to the documentation, I didn't look at the code for
the module).  But, the docs say basically say that your line of code:

my $rc = $factory->retrieve_blast($rid);

is already returning the BPLite object, so you don't need the line:

my $result = $rc->next_result (you already have it in $rc)

I modified the code to work (there were other errors in the script, the POD
should be fixed perhaps, to have working code).  My command line was
(because I don't have 1.0 bioperl installed):

perl -I  ~/bioperl_latest/lib/site_perl/5.6.0 testremoteblast.pl


#!/usr/bin/perl -w
use Bio::Tools::Run::RemoteBlast;
use strict;
my $v = 1;

my $prog = 'blastn';
my $db   = 'nr';
my $e_val= '1e-10';

my @params = ( '-prog' => $prog,
  		 '-data' => $db,
  		 '-expect' => $e_val );

  my $factory = Bio::Tools::Run::RemoteBlast->new(@params);
  $v = 1;
  my $str = Bio::SeqIO->new(-file=>'comt.cdna.fa' , '-format' => 'fasta' );
  my $input = $str->next_seq();
  #  Blast a sequence against a database:
  my $r = $factory->submit_blast($input);
  print STDERR "waiting..." if( $v > 0 );
  while ( my @rids = $factory->each_rid ) {
      foreach my $rid ( @rids ) {
  	  my $rc = $factory->retrieve_blast($rid);
  	  if( !ref($rc) ) {
  	      if( $rc < 0 ) { 		
  		      $factory->remove_rid($rid);
  		  }
  	      print STDERR "." if ( $v > 0 );
  	      sleep 5;
  	  } else { 
  	      $factory->remove_rid($rid);
#  	      my $result = $rc->nextSbjct;
  	      print "db is ", $rc->database(), "\n";
  	      print "query is ", $rc->query(), "\n";
  	      my $count = 0;
  	      while( my $hit = $rc->nextSbjct ) {		
	  		  $count++;
  			  next unless ( $v > 0);
  			  print "hit name is ", $hit->name, "\n";
  		  	while( my $hsp = $hit->nextHSP ) {
  		    	  print "score is ", $hsp->score, "\n";
  		  	} 
  	      }
  	  }
      }
  }


If there are errors in my code, I apologize, I am not the best at this
either :-)

-Mat