Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi fellow Monks!
So, I have the following script for running a tool I need for my research through the web, since it is not available for download.
My question is, since the authors suggest that web users should allow a small interval between submissions, how can I tell the script to execute with a, say, 1 minute interval per run, so as not to overload their server?
use WWW::Mechanize; ($fasta, $type) = @ARGV; #type -> euk, Gpos, Gneg $outfile = $fasta.".SIGNALCF"; open OUT, ">>$outfile"; open IN, $fasta; while(<IN>) { if($_=~/^>(.*)/) { $id=$1; $seq=<IN>; chomp $seq; $mikos=length($seq); $url = 'http://www.csbio.sjtu.edu.cn/bioinf/Signal-CF/'; $mech = WWW::Mechanize->new(); $mech->get($url); $mech->submit_form ( form_number => 1, fields => { #textarea name | value S1 => $seq, #Radio button name | value R2 => $type } ); $result = $mech->content(); #case with NO signal peptide if($result=~/According to our computational result, your input + sequence/) {print OUT $id."\t0\n";} #case with signal peptide if($result=~/According to our computational results, the signa +l peptide is:\<font color\=red\>1\-(\d+)\<\/font>/) {$sp_end=$1; print OUT $id."\t".$sp_end."\n";} } } close IN; close OUT;

Thank you!

Replies are listed 'Best First'.
Re: How to set a time interval in web batch script?
by spadacciniweb (Curate) on Oct 24, 2013 at 20:11 UTC
    Try
    while(<IN>) { if (...) { ... sleep 60; } }

    (($_="Mzz ojjdloobnf jt uvy5502383")=~y~b-zg2-5c96-81~a-z0-9~s)=~s~~~s; print
      Aha, I did not know that!
      Thank you!
        Hi again,
        so, the script seems to work now with an added interval.
        May I also ask, in case it is possible:
        If the service/tool I want to run via its webserver, does not send the result to the screen, but to my email, is there any way to somehow "capture" the result and not get my mailbox flooded with email responses from the server?
        For example this tool, which I need to also run:
        http://gpcr.biocomp.unibo.it/oldpredictors/spep/

        and it does not run unless you specify a mail address to get the results...