[Bioperl-l] More on EUtilities problem

Chris Fields cjfields at uiuc.edu
Tue Oct 23 03:50:19 UTC 2007


On Oct 22, 2007, at 7:28 PM, Warren Gallin wrote:

> I seem to be missing something here.
>
> I took the code from the HOWTO as a template and wrote the following
> code snippet (@gisearch_number is an array of gi numbers, prints out
> as expected and can be used to successfully download the relevant
> records using Batch Entrez):
> ...

One problem (but not the main one):

>      $file = 'temp_hold.gb';

You don't indicate the file needs appending (such as when rewriting  
to the same file in the loop below); you should change it to:

$file = '>>temp_hold.gb';

The below section is the main issue:

>      $gpeptfactory->set_parameters (-eutil => 'efetch',
>      							   -rettype => 'genbank',
>      							   -history => $history,
>      							
> 	);

In general, unless you're absolutely sure you want to carry over  
parameters from the previous eutil search (such as when you are  
looping through and changing the retmax/retstart parameters below),  
use reset_parameters():

$gpeptfactory->reset_parameters(
        -eutil => 'efetch',
        -db  => 'protein',
        -rettype => 'genbank',
        -history => $history
);

What's I believe is happening is the id parameter setting from your  
first eutil search is carried over and is reposted in the URL (thus  
getting the error).  reset_parameters() resets all parameters to  
undef unless new parameter args are passed in, in which case those  
are set to the new values, so nothing carries over.

 From that point on everything works fine (though again you'll want  
to specify that you are appending to a file instead of overwriting it  
within the loop).

chris

> 	my ($retmax, $retstart) = (300,0);
> 	my $retry = 0;
> RETRIEVE_SEQS: while ($retstart < $count) {
> 	
>      $gpeptfactory->set_parameters(
>      						-retmax => $retmax,
>                              -retstart => $retstart,
>                              );
>      eval{
>          $gpeptfactory->get_Response(-file => $file);
>          print "Output file is $file.\n";
>      };
>      if ($@) {
>          die "Server error: $@.  Try again later" if $retry == 5;
>          print STDERR "$@\n";
>          print STDERR "Server error, redo #$retry\n";
>          $retry++ && goto RETRIEVE_SEQS;
>      }
>      else{
>      	
>      	my $retend = $retstart + $ retmax;
>      	print "Loaded entries $retstart through $retend on retry #
> $retry.\n";
>
>      	$retstart += $retmax;
>      	$retry = 0;
>      }
> }
>
>          $retr_seq = Bio::SeqIO->new(
>              -file   => $file,
>              -format => 'genbank'
>          );
>
> ________________________________________________
> At this point the program fails because there is no file written.
>
> It appears that the get_Response method is not doing its thing.
>
> Also, on each iteration of the loop enclosing the eval the first pass
> fails with the following error message:
>
> ------------- EXCEPTION: Bio::Root::Exception -------------
> MSG: Response Error
> Request-URI Too Large
> STACK: Error::throw
> STACK: Bio::Root::Root::throw /Library/Perl/5.8.1/Bio/Root/Root.pm:357
> STACK: Bio::DB::GenericWebAgent::get_Response /Library/Perl/5.8.1/Bio/
> DB/GenericWebAgent.pm:184
> STACK: Stable_gb_update.pl:177
> -----------------------------------------------------------
>   and then the second pass evaluates as correct - but the output file
> is never opened or written to.
>
> I've tried to pass $file,  "$file" , ">>$file"  and a literal string
> of a file name, with and without the >>, but to no avail.
>
> So I think that I must be missing something basic here, but I am
> unable to see what.
>
> Any advice would be most welcome.
>
> Warren Gallin
>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l

Christopher Fields
Postdoctoral Researcher
Lab of Dr. Robert Switzer
Dept of Biochemistry
University of Illinois Urbana-Champaign






More information about the Bioperl-l mailing list