[Bioperl-l] More on Eutilities get_Response problem

Mark A. Jensen maj at fortinbras.us
Fri May 8 12:43:16 UTC 2009


Hi Warren,

The get_Response function is really a wrapper for LWP::UserAgent::get;
as such, the -file parameter works differently from the usual BioPerl -file.
I agree that this is a bug; it's just not a BioPerl bug. If the behavior of your
script really did change, maybe it did so after an update of LWP::UserAgent.
Anyway, one way to work around this is to use the callback instead of the
file parameter; something like

 my $global_file = 'eutil-dump.txt';
 ...
 $thing->get_Response( -cb => \&_append_file );
 ...
 sub _append_file {
    my ($data, $response_obj, $protocol_obj) = @_;
    open my $fh, ">>$global_file" or die "can't open dump file: $!";
    print $fh $data;
    return;
 }

See http://search.cpan.org/~gaas/libwww-perl-5.826/lib/LWP/UserAgent.pm,
and 'perldoc Bio::DB::EUtilities'.

cheers,
Mark



----- Original Message ----- 
From: "Warren Gallin" <wgallin at ualberta.ca>
To: "BioPerl List" <Bioperl-l at lists.open-bio.org>
Sent: Thursday, May 07, 2009 7:00 PM
Subject: [Bioperl-l] More on Eutilities get_Response problem


> Hi,
>
> I am using the get_response method inside a loop, so I want to  iteratively 
> append the retrieved material to a file.
>
> If I pass temp_hold.gb as the file parameter a file called  temp_hold.gb is 
> created and that file is successively overwritten as I  cycle through the 
> loop.
>
> If I pass >temp_hold.gb as the file parameter a file called  temp_hold.gb is 
> created and that file is successively overwritten as I  cycle through the 
> loop.
>
> If I pass >>temp_hold.gb as the file parameter a file called
> >temp_hold.gb (yes, the > is part of the file name) is created and
> that file is successively overwritten as I cycle through the loop.
>
> Could it be that the way the file parameter is passed in has been  slightly 
> broken so it is no loner reading the >> as an indicator to  append?
>
>
> Warren Gallin
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>
> 




More information about the Bioperl-l mailing list