Shailesh Maurya - Network | 9 Oct 15:02 2012

Please help me on the piece of code throwing exception


I'm trying to execute a script for downloading rna sequences of Cricetulus griseus from NCBI site using
eutils. But while execution I'm stuck up with the exceptions. Here's the script and the exception it is
throwing -


use Bio::DB::EUtilities;
use Error qw(:try);

try {
# set optional history queue
my $factory = Bio::DB::EUtilities->new(-eutil      => 'esearch',
                                       -email      => 'maurya_shailesh <at>'<mailto:'maurya_shailesh <at>'>,
                                       -db         => 'nuccore',
                                       -term       => 'Cricetulus griseus[porgn:__txid10029] AND mrna',
                                       -usehistory => 'y');

my $count = $factory->get_count;
# get history from queue
my $hist  = $factory->next_History || die 'No history data returned';
print "History returned\n";
# note db carries over from above
$factory->set_parameters(-eutil   => 'efetch',
                         -rettype => 'fasta',
                         -history => $hist);

my $retry = 0;
my ($retmax, $retstart) = (500,0);

open (my $out, '>', 'seqs_rna') || die "Can't open file:$!";

while ($retstart < $count) {
    $factory->set_parameters(-retmax   => $retmax,
                             -retstart => $retstart);
        $factory->get_Response(-cb => sub {my ($data) =  <at> _; print $out $data} );
    if ($ <at> ) {
        die "Server error: $ <at> .  Try again later" if $retry == 5;
        print STDERR "Server error, redo #$retry\n";
        $retry++ && redo RETRIEVE_SEQS;
    print "Retrieved $retstart";
    $retstart += $retmax;

close $out;
catch Bio::Root::Exception with {
        my $err = shift;
        print "A Bioperl exception has occured:\n$err\n";


And the exception is -

A Bioperl exception has occured:

------------- EXCEPTION: Bio::Root::Exception -------------
MSG: Response Error
Can't connect to (timeout)
STACK: Error::throw
STACK: Bio::Root::Root::throw /usr/local/perl-5.12.1/lib/site_perl/5.12.1/Bio/Root/
STACK: Bio::DB::GenericWebAgent::get_Response /usr/local/perl-5.12.1/lib/site_perl/5.12.1/Bio/DB/
STACK: Bio::DB::EUtilities::get_Parser /usr/local/perl-5.12.1/lib/site_perl/5.12.1/Bio/DB/
STACK: Bio::DB::EUtilities::get_count /usr/local/perl-5.12.1/lib/site_perl/5.12.1/Bio/DB/

Please help me on this piece of code. Also there is humble request to suggest some other logic or script to
perform the task.

Hope for a positive response.


Thanks and Regards,

Shailesh Maurya
Eli Lilly ODC  <at>  TCS, Noida 2, India
Work :+91-9911666572
EMail: maurya_shailesh <at><mailto:maurya_shailesh <at>>