#!/usr/local/bin/perl # $TITLE = 'ReadSeq.pl v.1.1 - a WWW interface for readseq'; $COPYRIGHT = 'Copyright (c) 1996-1997, ISHIKAWA Jun'; $DATE = '$Date: 1997/02/22 20:17:15 $'; # # This program is provided free of charge to educational, charity or # not-for-profit organisations provided the Copyright notice remains intact. # Commercial organizations should contact the author for licensing details. # No warranty is made, either expressed or implied. `USE AT YOUR OWN RISK'. # #------------ You must set the following variable -------------- # Where is your readseq binary? $READSEQ = "/home/bioact/jun/bin/sparc/readseq"; #------------ No further configuration required ----------------- alarm(600); # Timeout: generate SIGALRM after 10 min. $SIG{'INT'} = $SIG{'TERM'} = $SIG{'STOP'} = $SIG{'QUIT'} = $SIG{'ALRM'} = '&stop'; #get data if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); %FORM = &parse($buffer); &cooking; } else { &print_form; } exit; # -------- subroutines -------- sub cooking { $|=1; # force flush buffer print "Content-Type: text/html\n\n"; print "
";
open(CMD,"| $READSEQ -p -f=$FORM{'format'} $FORM{'case'} $FORM{'reverse'} $FORM{'opt'}");
print CMD $FORM{'sequence'},"\n";
close(CMD);
print "";
}
sub parse { # parse parameters
local(%form, @pairs, $name, $value);
@pairs = split(/&/,$_[0]);
foreach (@pairs) {
($name, $value) = split /=/;
$value =~ tr/\+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$form{$name} = $value;
}
return %form;
}
sub stop { exit 1; }
sub print_form {
print <<"HTML";
Content-Type: text/html
$DATE
$COPYRIGHT
Source code (Perl script) is available.
The brief usage of options is as follows. The ``[ ]'' denote optional parts of the syntax:
options
-a[ll] select All sequences
-degap[=-] remove gap symbols
-i[tem=2,3,4] select Item number(s) from several
-l[ist] List sequences only
-r[everse] change to Reverse-complement
Pretty format options:
-wid[th]=# sequence line width
-tab=# left indent
-col[space]=# column space within sequence line on output
-gap[count] count gap chars in sequence numbers
-nameleft, -nameright[=#] name on left/right side [=max width]
-nametop name at top/bottom
-numleft, -numright seq index on left/right side
-numtop, -numbot index on top/bottom
-match[=.] use match base for 2..n species
-inter[line=#] blank line(s) between sequence blocks
\$ENB{'SCRIPT_NAME'}
for \$CGIPATH.
Moved -all option to "Other option(s)".