Shailesh Maurya - Network | 9 Oct 15:02 2012
Picon

Please help me on the piece of code throwing exception

Hi,

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 -

*****

#!/usr/local/bin/perl
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> network.lilly.com'<mailto:'maurya_shailesh <at> network.lilly.com'>,
                                       -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:$!";

RETRIEVE_SEQS:
while ($retstart < $count) {
    $factory->set_parameters(-retmax   => $retmax,
                             -retstart => $retstart);
    eval{
        $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 eutils.ncbi.nlm.nih.gov:80 (timeout)
STACK: Error::throw
STACK: Bio::Root::Root::throw /usr/local/perl-5.12.1/lib/site_perl/5.12.1/Bio/Root/Root.pm:368
STACK: Bio::DB::GenericWebAgent::get_Response /usr/local/perl-5.12.1/lib/site_perl/5.12.1/Bio/DB/GenericWebAgent.pm:215
STACK: Bio::DB::EUtilities::get_Parser /usr/local/perl-5.12.1/lib/site_perl/5.12.1/Bio/DB/EUtilities.pm:222
STACK: Bio::DB::EUtilities::get_count /usr/local/perl-5.12.1/lib/site_perl/5.12.1/Bio/DB/EUtilities.pm:580
STACK: load.pl:15
-----------------------------------------------------------

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
LRL IT COE
Eli Lilly ODC  <at>  TCS, Noida 2, India
Work :+91-9911666572
EMail: maurya_shailesh <at> network.lilly.com<mailto:maurya_shailesh <at> network.lilly.com>

Gmane