terriblue has asked for the wisdom of the Perl Monks concerning the following question:

I'm having a problem nailing down a problem trying to send a query to a web server and retrieving the results. I'm working with the Bio::Tools::Run::RemoteBlast bioperl module.

This is the portion of script where I believe the problem is coming from:

#create remote blast factory object and initialize blast parameters my $blast_factory = Bio::Tools::Run::RemoteBlast -> new ( '-prog' => 'blastn', '-data' => 'nr', '-expect' => '1e-10', '-readmethod' => 'SearchIO'); #loop over all sequences input and count how many sequences are found my $count = 0; while (my $seq = $seqio -> next_seq) { $count++; #loop to blast each sequence against the database my $job = $blast_factory -> submit_blast ($seq); print "Blasting sequence number $count\n"; #loop to load rids returned for the blast job submitted while (my @rids = $blast_factory -> each_rid) { #loop over rids to check server for a result foreach my $rid (@rids) { my $blast_results = $blast_factory -> retrieve_blast($rid); #check to see if a result object is returned if ( !ref($blast_results) ) { #if error returned remove rid from stack if ($blast_results == 0) { print STDERR "retrieve_blast returns 0\n"; #watch dots sleep 5; #pause between submitting requests to genbank server } elsif ($blast_results == (-1)) { print STDERR "retrieve_blast returns -1\n"; $blast_factory -> remove_rid($rid); } last if $blast_results == (-1); } #if result, use Bio::SearchIO to return Bio::SeqIO result object if ( ref($blast_results)) { print "Receiving blast results...\n"; my $result = $blast_results -> next_result(); $blast_factory -> remove_rid($rid); #remove rid from stack


The error message I get is this:

Blasting sequence number 1
-----WARNING-----
MSG:
-----------------------
retrieve_blast returns -1

Any ideas?

Replies are listed 'Best First'.
Re: Problem retrieving results from web server
by Plankton (Vicar) on Apr 01, 2004 at 17:04 UTC
    Hi terriblue,

    I assume you have tried to use the resources mentioned here
    I don't know much about this module but the term remote suggest to me that something is attempting to contact another computer over a network. You might what to make sure you can "ping" this remote system. Sorry for being a smart-ass yesterday, but you need to start your trouble shooting with the obvious things. After you have verified there is nothing wrong with your network you might want to use Data::Dumper to see what is going ... like so ...
    ... use Data::Dumper; ... #create remote blast factory object and initialize blast parameters my $blast_factory = Bio::Tools::Run::RemoteBlast -> new ( '-prog' => 'blastn', '-data' => 'nr', '-expect' => '1e-10', '-readmethod' => 'SearchIO'); print Dumper( $blast_factory ); #loop over all sequences input and count how many sequences are found my $count = 0; while (my $seq = $seqio -> next_seq) { $count++; #loop to blast each sequence against the database my $job = $blast_factory -> submit_blast ($seq); print "Blasting sequence number $count\n"; print Dumper( $job ); #loop to load rids returned for the blast job submitted while (my @rids = $blast_factory -> each_rid) { #loop over rids to check server for a result foreach my $rid (@rids) { print Dumper( $rid ); my $blast_results = $blast_factory -> retrieve_blast($rid); print Dumper( $blast_results ); ...
    And then maybe post the output here. Just a suggestion. I hope it helps :)

    Plankton: 1% Evil, 99% Hot Gas.
      Thanks for the suggestion...much appreciated.

      I've verified there's nothing wrong with the network and I've incorporated Data::Dumper so see what's going on:

      my $blast_factory = Bio::Tools::Run::RemoteBlast -> new ( '-prog' => 'blastn', '-data' => 'nr', '-expect' => '1e-10', '-readmethod' => 'SearchIO'); print Dumper ($blast_factory); #ok #loop over all sequences input and count how many sequences are found my $count = 0; while (my $seq = $seqio -> next_seq) { $count++; #loop to blast each sequence against the database my $job = $blast_factory -> submit_blast ($seq); print "Blasting sequence number $count\n"; print Dumper($job); #returns 1, ok #loop to load rids returned for the blast job submitted while (my @rids = $blast_factory -> each_rid) { #loop over rids to check server for a result foreach my $rid (@rids) { print Dumper ($rid); #returns rid#, ok my $blast_results = $blast_factory -> retrieve_blast($rid); print Dumper ($blast_results); #returns -1, PROBLEM #check to see if a result object is returned if ( !ref($blast_results) ) { #if error returned remove rid from stack if ($blast_results == 0) { print STDERR "retrieve_blast returns 0\n"; #watch dots sleep 5; #pause between submitting requests to genbank server } elsif ($blast_results == (-1)) { print STDERR "retrieve_blast returns -1\n"; $blast_factory -> remove_rid($rid); } last if $blast_results == (-1); } #if result, use Bio::SearchIO to return a Bio::SeqIO result object if ( ref($blast_results)) { print "Receiving blast results...\n"; my $result = $blast_results -> next_result(); $blast_factory -> remove_rid($rid); #remove rid from stack

      This is the output:

      $VAR1 = bless( { '_root_cleanup_methods' => [ sub { "DUMMY" } ], '_readmethod' => 'SearchIO', '_flush_on_write' => 1, '_root_verbose' => 0 }, 'Bio::Tools::Run::RemoteBlast' ); Blasting sequence number 1 $VAR1 = '1'; $VAR1 = '1080865802-2043-175938892824'; -------------------- WARNING --------------------- MSG: --------------------------------------------------- $VAR1 = -1; retrieve_blast returns -1
      Looks like it's able to use the $blast_factory settings to obtain an rid# from the queue, but once it's done that, throws an error when trying to retrieve the result object.