📄 meme.pl
字号:
#!@WHICHPERL@#### $Id: meme.pl 1339 2006-09-21 19:46:28Z tbailey $#### $Log$## Revision 1.12 2006/03/07 23:30:19 nadya## merge branches v3_5_1 and v3_5_2 back to the trunk#### Revision 1.11.6.1 2006/02/16 23:22:35 nadya## update path to show the background image on the page.#### Revision 1.11 2006/01/03 06:42:24 tbailey## Fix use of "min()".#### Revision 1.10 2005/12/15 06:27:42 tbailey## Don't allow more than $MAXSITES sequences in OOPS mode.## Set maxsites to minimum of number of sequences and $MAXSITES in ZOOPS mode.#### Revision 1.9 2005/10/02 01:00:10 nadya## move meme-client and mast-client names into Globals and use variables instead.#### Revision 1.8 2005/09/16 01:44:55 wilfred## url fixed#### Revision 1.7 2005/08/24 05:42:39 nadya## move variables to Globals#### Revision 1.6 2005/08/19 22:59:20 nadya## move email validation to Validation module from check_address.cgi#### Revision 1.5 2005/08/19 01:26:56 nadya## change check_address to do email address verification.## all functionality is there. update mast.pl and meme.pl for a new call.#### Revision 1.4 2005/08/10 21:02:39 nadya## mv MAXTIME to Globals module#### Revision 1.3 2005/08/10 20:33:24 nadya## use variable for MAXTIME, set by configure#### Revision 1.2 2005/08/07 05:58:26 nadya## use vairables in Globals for meme locations,## fix locatio of website.#### Revision 1.1.1.1 2005/07/25 23:26:55 nadya## Importing from meme-3.0.14, and adding configure/make#####$debug = 1; # uncomment to debug this scriptuse lib qw(@PERLLIBDIR@);use Globals;use Validation;use CGI qw/:standard/; # use the CGI package$scratch = "$MEME_LOGS"; # directory for temp files$bin = "$MEME_BIN"; # directory for executables $cgidir = "$MEME_WEB";$maint = "$SITE_MAINTAINER"; # email address of site maintainer; # start the response formprint <<END; Content-type: text/html<HTML><TITLE> MEME - Verification </TITLE><BODY BACKGROUND=\"../images/bkg.jpg\"><HR>END# no errors yet$nerrors = 0;$sequences_given = 1;# change working directory to LOGSchdir($scratch) || &whine("Can't cd to $scratch");# retrieve the fields from the form$address = param('address');$subject = param('subject');$subject =~ s/[^\w:;-_"()<>%]/ /g; # remove funny characters$datafile_name = param('datafile');$dist = param('dist');$nmotifs = param('nmotifs');$data = param('data');$text = param('text');$minsites = param('minsites');$maxsites = param('maxsites');$minw = param('minw');$maxw = param('maxw');$bfile = param('bfile');$evt = param('evt');$shuffle = param('shuffle'); $shuffle = 0 unless ($shuffle);$pal = param('pal');$posonly = param('posonly');# dna switches$dna_switches = "$pal $posonly";# add notice to use web browser to descriptionif (!$text) {$viewer = "(Use web browser to view results)";}# check that valid email address was provided&check_address;# check that sequence data was providedif (!$datafile_name && !$data) { &whine(" You haven't entered any sequence data. <BR> If you still wish to submit a query, please go back and enter the name of a sequence file or the actual sequences. "); $sequences_given = 0;}# don't allow both datafile and dataif ($datafile_name && $data) { &whine(" You may not enter <I>both</I> the name of a sequence file and sequences.<BR> If you still wish to submit a query, please go back and erase either what you have written in the <I>name of a file</I> field or in the <I>actual sequences</I> field. "); $sequences_given = 0;}## create file containing sequences#$datafile = "meme.seqs.$$";open(SEQS, ">$datafile") || &whine("Can't open file $datafile: $!");if ($data) { # process inline data $_ = $data; s/\r\n/\n/g; # Windows -> UNIX eol s/\r/\n/g; # MacOS -> UNIX eol print SEQS $_;} else { # process uploaded sequences while (<$datafile_name>) { s/\r\n/\n/g; # Windows -> UNIX eol s/\r/\n/g; # MacOS -> UNIX eol print SEQS $_; }}print SEQS "\n"; # make sure there is a last nlclose (SEQS);chmod 0777, $datafile;# use datafile_name for printing by MEME$datafile_name = "pasted sequences" unless($datafile_name); # make sure sequence file isn't emptyif ($datafile_name) { $_ = `wc $datafile`; @tmp = split (' '); if ($tmp[0] == 0) { &whine(" MEME could not read your sequence file or it is empty. <BR> Make sure the name is correct and that you have read access to the file. "); $sequences_given = 0; }}# Get information on the sequencesif ($sequences_given) { &check_data;}# Make sure the data was in FASTA format or got converted correctly. if ($nerrors == 0 && $num == 0 ) { &whine(" MEME was unable to read your data. <BR> Please check to be sure that your data is <A HREF=../help_format.html> formatted</A> properly. <BR> If you are still having trouble, you can try to convert your data to <A HREF=http://dot.imgen.bcm.tmc.edu:9331/seq-util/Help/example_input.html> FASTA format</A> using the <A HREF=http://dot.imgen.bcm.tmc.edu:9331/seq-util/readseq.html> ReadSeq</A> program and then resubmit it. ");}# Make sure there isn't too much data.if ($total > $MAXDATASET) { &whine(" The data you have entered contains more than $MAXDATASET characters. MEME cannot process it at this time. <BR> Please submit a smaller dataset. ");}# Make sure there aren't too many sequences in OOPS mode if ($dist eq "oops" && $num > $MAXSITES) { &whine(" Your dataset must contain no more than $MAXSITES sequences when you specify that the motif is <I>distributed</I> one per sequence. Please input a dataset with no more than $MAXSITES sequences or chose a different motif distribution. ");}# Set the maximum number of sites in ZOOPS mode if not specifiedif ($dist eq "zoops" && !$maxsites) { $maxsites = ($num <= $MAXSITES ? $num : $MAXSITES);}# check that DNA dataset specified if using DNA switchesif (($dna_switches =~ /\S/) && !($alphabet eq "dna")) { &whine(" You may not use DNA only options with a protein dataset.<BR> Please specify a DNA dataset or make sure that the <I>strand</I> and <I>palindromes</I> boxes are not checked. "); }# check that TCM specified if only one sequenceif (($num == 1) && !($dist eq "tcm")) { &whine(" You must specify <I>Any number of repetitions</I> under the <I>distribution</I> option since your dataset contains only one sequence. Alternatively, you might wish to break your sequence into several sequences. ");}# check that number of motifs is OKif ($nmotifs < 1 || $nmotifs > $MAXMOTIFS) { &whine(" You must specify <I> number of motifs</I> between 1 and $MAXMOTIFS, inclusive. ");}# check that number of sites is OK&check_nsites($minsites, $maxsites, $dist, $num);# check that width is OK&check_width;# set the revcomp switchif (!$posonly && $alphabet eq "dna") { $revcomp = "-revcomp";}# set the number of sites switches$mins = " -minsites $minsites" if ($minsites);$maxs = " -maxsites $maxsites" if ($maxsites);# set the background model file switchif ($bfile) { $bf = "-bfile $bfile";}# combine all switches$switches = "-$alphabet -mod $dist -nmotifs $nmotifs $mins $maxs -minw $minw -maxw $maxw -evt $evt $pal $revcomp $bf $text -time $MAXTIME -maxsize $MAXDATASET";# remove spaces, non-ASCII and single quotes from $datafile_name$datafile_name =~ s/[ \'\x80-\xFF]/\_/g;## Create the file to be sent to the client#&print_file;## submit the job#if ($nerrors == 0) { &submit;}## delete the temporary files#unlink "meme.msg.$$";unlink $datafile;unlink "meme.data.$$";unlink "meme.client.msg.$$";## finish the form#if ($nerrors) { if ($nerrors == 1) { $tobe = "was"; $booboo = "error"; $pronoun = "it"; } else { $tobe = "were"; $booboo = "errors"; $pronoun = "them"; } print "</B></OL>\n"; print "<B>There $tobe $nerrors $booboo on the form.\n"; print "Please correct $pronoun and try again.</B>\n";}print " <HR> </BODY> </HTML>";exit(0);################################################################################### SUBROUTINES:################################################################################# Check to see whether the email address is valid.#sub check_address
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -