Fields, Christopher J | 9 Oct 21:13 2012

Re: Please help me on the piece of code throwing exception

The error returned indicates this may be an intermittent issue on NCBI's end, but it could also be a proxy
issue as Jason pointed out (so try it again, and try it with proxy settings as Jason indicated).  Locally
this is working for me at the moment, though I admittedly removed the Error stuff (I try to avoid using that
particular module).  

chris

On Oct 9, 2012, at 8:02 AM, Shailesh Maurya - Network <maurya_shailesh <at> network.lilly.com>
 wrote:

> 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>
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l <at> lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l

Gmane