develooper Front page | perl.libwww | Postings from December 2000

help with 'multipart' and 'text/html' websites

From:
Brian Tam
Date:
December 20, 2000 21:01
Subject:
help with 'multipart' and 'text/html' websites
Message ID:
754DA4972080D311935100A0C9D4BE1735ADD4@atticus
> Hi,
> 
I don't know if this is the appropriate forum to post this question, but
since it's libwww-related (involves LWP) and I've tried other forums without
success, I might as well give this one a go.

> I'm trying to query Genemark
> (http://genemark.biology.gatech.edu/GeneMark/webgenemark.html), a gene
> prediction program, from the Unix shell with a Perl script.  Yes, I know I
> could paste in the sequences and 'run' the software from the web page
> itself, but I've got hundreds of sequences to input, too many to do
> manually.
>  
> Anyway, I've created the following user, request, and response objects: 
>  
>    use LWP::UserAgent;
>    use HTTP::Request::Common qw(POST);
>    $ua = new LWP::UserAgent;
> 
>    my $req = new POST =>
> 'http://exon.biology.gatech.edu/GeneMark/bin/webgenemark.cgi';
>       Content_Type => 'text/html',
>       Content => [species => 'A.thaliana',
>          window => '96',
>          step => '12',
>          threshold => '0.5',
>          l_orfs => 'ORFs',
>          sequence => $a_sequence,
>          B1 => 'Start Genemark'
>       ];
>  
>    while (1)  {
>       $res = $ua->request($req);
>  
>       if ($res->is_success) {
>          last;
>       };
>    };
> 
>    @results = split /\n/, $res->content;
>    print $res->content;
> 
> $a_sequence is a sequence of "A"s, "T"s, "G"s, and "C"s you can randomly
> distribute as a test case.  When I run the script, it doesn't return the
> same results the web page does.  In fact, it returns an html with no
> results.  Am I calling Genemark.hmm incorrectly, inputting the parameters
> wrong, or what?  Admittedly, I don't know how to handle 'text/html' forms,
> so I'm sure I'm structuring the request wrong.  
> 
> Another website I'm having trouble with is Genscan
> (http://genes.mit/edu/GENSCAN.html), another gene prediction program.  I
> get no response from their mail server, so please don't suggest I try
> using that.  The following code:
>  
>    use LWP::UserAgent;
>    $ua = new LWP::UserAgent;
>    $ua->agent("AgentName/0.1 " . $ua->agent);
> 
>    my $req = new HTTP::Request POST =>
> 'http://genes.mit.edu/cgi-bin/genescanw.cgi';
>    $req->content_type('multipart/form-data');
>    $req->content([-o => Arabidopsis, -n => $a_sequence, -p => 'Predicted
> CDS and peptides', submit => 'Run GENSCAN']);
>  
>    my $res = $ua->request($req);
>  
>    while (1)  {
>       $res = $ua->request($req);
>  
>       if ($res->is_success) {
>          last;
>       };
>    };
> 
>    @results = split /\n/, $res->content;
>    print $res->content;
>  
> doesn't return anything--at least not the same thing as the webpage
> itself.  When I input a 'www-xxx-url-encoded' version into the
> 'www-xxx-url-encoded' site, http://genes.mit.edu/oldGENSCAN.html, it just
> returns the message: 'gform: Error This program can only be used to decode
> forms'.  I don't understand what's going on with either site.
> 
> Any help would be greatly appreciated.  Please e-mail responses to
> btam@akkadix.com.   Thanks.
> 
> 
> ---Brian Tam



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About