Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Automated form submission

by Speedy (Monk)
on Mar 03, 2002 at 05:06 UTC ( [id://148944]=note: print w/replies, xml ) Need Help??


in reply to Automated form submission

Just put in the value of the variable that you want to change to get a new setting.

For example, in the NCBI CD-Search URL given above, the database selection variable name and the three possible values can be seen in the "View source" for the HTML page:
Search Database: <select NAME="DATALIB"> <option VALUE="oasis_smart"> Smart v3.3 - 569 PSSMs <option VALUE="oasis_pfam"> Pfam v6.6 - 3071 PSSMs <option VALUE="oasis_sap" SELECTED> All - 3693 PSSMs </select>
The variable name is DATALIB, with three possible values: oasis_smart, oasis_pfam, and oasis_sap. The SELECTED beside "oasis_sap" indicates that this is the default or selected value if the user does not change it.

So in your code, along with the SEQUENCE=>"$string" you also need a DATALIB=>'oasis_smart' if the Smart v3.3 database was to be the new target.

In fact, you can set all the POST parameters for the wrpsb.cgi page with code like this:
#!/usr/bin/perl use strict; use HTTP::Request::Common qw(POST); use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $string = ">CG2B_MARGL\n "; $string .= "MLNGENVDSRIMGKVATRASSKGVKSTLGTRGALENISNVARNNLQAGAK\n"; $string .= "KELVKAKRGMTKSKATSSLQSVMGLNVEPMEKAKPQSPEPMDMSEINSAL\n"; $string .= "EAFSQNLLEGVEDIDKNDFDNPQLCSEFVNDIYQYMRKLEREFKVRTDYM\n"; $string .= "TIQEITERMRSILIDWLVQVHLRFHLLQETLFLTIQILDRYLEVQPVSKN\n"; $string .= "KLQLVGVTSMLIAAKYEEMYPPEIGDFVYITDNAYTKAQIRSMECNILRR\n"; $string .= "LDFSLGKPLCIHFLRRNSKAGGVDGQKHTMAKYLMELTLPEYAFVPYDPS\n"; $string .= "EIAAAALCLSSKILEPDMEWGTTLVHYSAYSEDHLMPIVQKMALVLKNAP\n"; $string .= "TAKFQAVRKKYSSAKFMNVSTISALTSSTVMDLADQMC"; my $req=POST 'http://www.ncbi.nlm.nih.gov/Structure/cdd/wrpsb.cgi', [ SEQUENCE=>"$string", DATALIB=>'oasis_sap', INPUT_TYPE=>'fasta', EXPECT=>'0.01', FILTER=>'T', SMODE=>'0', NHITS=>'50', GRAPH=>'2', PAIR=>'2', GW=>'-1']; print "Content-type: text/html\n\n"; print $ua->request($req)->as_string();
Running this code as, say, sample.cgi in a Web server will return a rather impressive set of match options. Or just running from the command line as, say,
perl -w sample.cgi
will give the html source code on the screen.

Hope this helps. Good luck with this enterprise.

Replies are listed 'Best First'.
Re: Automated form submission
by domm (Chaplain) on Mar 03, 2002 at 14:30 UTC
    A little bit off-topic, but your setting of $string is rather laboriuos. Wouldn't it be much easier to use a HERE document, like so:
    my $string=<<EOSTRING; CG2B_MARGL MLNGENVDSRIMGKVATRASSKGVKSTLGTRGALENISNVARNNLQAGAK ... TAKFQAVRKKYSSAKFMNVSTISALTSSTVMDLADQMC EOSTRING
    ?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://148944]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-05-20 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found