[Bioperl-l] Not catching an error in EUtilities

Warren Gallin wgallin at ualberta.ca
Mon Oct 29 04:03:24 UTC 2007


I've been having an intermittent problem, when the NCBI service that  
is accessed by EUtilities (in particular efetch) is not available.

I have the calls enclosed in eval statements, but an exception is not  
thrown.  Instead I find that the  file that should contain the  
results of the efetch only has the following text:

Error: The resource is temporarily unavailable

So it appears that this is not generating an exception (maybe that is  
not desireable in general, but it would be useful in my case).

The result is that my script tries to access the file using  
Bio::Seq::IO, and the expected text is not there.

The relevant snippet of code and the output are copied below.

The only way that I can think of to catch this outcome is to open the  
file and check the firt three lines for this text, and then go back  
and redo the efetch if this particular text is found.

Is this behaviour considered a bug, or just an outcome that needs to  
be checked for when code is written using efetch?

If so, is there a standard way of checking for this?

Thanks,

Warren Gallin

[Code that successfully executes an epost and retrieves the history]

   RETRIEVE_LIST: eval {$prot_eutil->reset_parameters(
         -eutil   => 'efetch',
         -rettype => 'genbank',
         -db      => 'protein',
         -history => $history
     );};
     if ($@){
     	print "efetch error trapped\n$@\n";
     	goto RETRIEVE_LIST;

     }

     $file1 = ">" . $file1;
     $retry = 0;
     eval { $prot_eutil->get_Response( -file => $file1 ); };
     if ($@) {
         die "Server error: $@.  Try again later" if $retry == 5;
         print STDERR "$@\n";
         print STDERR "Server error, redo #$retry\n";
         $retry++;
         sleep(5);
         goto RETRIEVE_LIST;
     }
     else {
         print "efetch ran on $loop_bottom through $loop_top.\n";
     }

The output to the terminal from this part of the code is:

efetch ran on 0 through 300.




More information about the Bioperl-l mailing list