[Bioperl-l] How_to_set_proxy_information_in_getGenBank.pl

Peter Kos kos@rite.or.jp" <kos@rite.or.jp
Mon, 5 Aug 2002 14:41:56 +0900


Hi all,

My solution may not be universal, but since it works for me, I can 
recommend it. You need to set the HTTP_PROXY environment value via 
the .cshrc (in case you work in cshell or tcshell)
For unknown reason, if I set it using
setenv HTTP_PROXY=http://a.b.c.d:80
then I will get an equal sign at the end of the string, causing 
malfunction.
Perhaps you can also set the same environment variable from your 
script.

THEN we need one additional line in the "new" method of the 
WebDBSeqI.pm

Jason,
I think this line may not have any disadvantage at sites without 
firewall where therefore there is no such environment variable and no 
need for the whole thing. Perhaps it sets the proxy info to undef as 
it is by default. I can not test it, however. Please think about it, 
and if it is all right please consider putting this line in the 
official WebDBSeqI.pm
(And of course we may put an  " if ($ENV{'HTTP_PROXY'})" or similar 
at the end of the line if necessary.)

The code of the whole sub is here below, with the extra line marked 
for easy identification.
An alternative, site-specific, manual variant is also suggested.

Regards
Peter

...

sub new {
    my ($class, @args) = @_;
    my $self = $class->SUPER::new(@args);
    my ($baseaddress, $params, $ret_type, $format) =
	$self->_rearrange([qw(BASEADDRESS PARAMS RETRIEVALTYPE FORMAT)],
			  @args);

    $ret_type = $DEFAULT_RETRIEVAL_TYPE unless ( $ret_type);
    $baseaddress && $self->url_base_address($baseaddress);
    $params      && $self->url_params($params);
    $ret_type    && $self->retrieval_type($ret_type);

    # insure we always have a default format set for retrieval
    # even though this will be immedietly overwritten by most sub 
classes
    $format = $self->default_format unless ( defined $format &&
					     $format ne '' );

    $self->request_format($format);
    my $ua = new LWP::UserAgent;
	$ua -> env_proxy ();  ##  THIS LINE IS THE FANTASTIC MODIFICATION ##
#	$ua-> proxy ('http', 'http://a.b.c.d:80');   ## The alternative way 
##
    $ua-> agent (ref($self) ."/$MODVERSION");
    $self-> ua ($ua);
    return $self;
}

...

On Friday, August 02, 2002 9:50 AM, Wei Yichun 
[SMTP:ycwei@mail.ustc.edu.cn] wrote:
...
> I am a newbie behind a firewall and have to use bioperl
> through that firewall. But I can not figure out how to
> set it in bioperl scripts.

......

On Friday, June 14, 2002 10:37 PM, Jason Stajich 
[SMTP:jason@cgt.mc.duke.edu] wrote:
> Have you set the proxy information.  The code can't deduce your
> proxy information automatically.
>
> All the modules which make internet connections either use LWP or a
> bioperl internal module to connect which has built in proxy
> capabilities.
> It is currently the case that you can't automatically set the
> proxy/user/pass for the tests but, some people have proposed, and 
we
> would
> whole heartedly endorse someone coming up with an environment
> variable
> strategy that would allow the tests to pick up the necessary proxy
> information and set the data in the specific objects so that tests
> would
> run.
>
> We'll be happy to apply any solutions to the code base.



..................................................................  
..........
Peter B. Kos, Ph.D.
Molecular Microbiology and Genetics Lab.
Research Institute of Innovative Technology for the Earth (RITE)
9-2 Kizugawadai, Kizu-cho, Soraku-gun,
Kyoto 619-0292 JAPAN
Phone: +81-774-75-2308
Fax: +81-774-75-2321
E-mail: kos@rite.or.jp