bobekdj has asked for the wisdom of the Perl Monks concerning the following question:
concepts.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html lang="en"> <head> <title>Form Example</title> </head> <body> <!-- Insert your content here --> <form action="cgi-bin/concepts2.pl" method="post"> <p>File:<input type="FILE" name="file"> <input type="submit" name="submit" value="Submit"> </form> </body> </html>
concepts2.pl #!/usr/bin/perl use strict; use CGI; my $cgi=new CGI; print $cgi->header(); print $cgi->start_html(-title=>'Form Results', -author=>'BoChak'); #my $file=$cgi->param('file'); my $file="/root/Desktop/test.fasta"; print "<br> $file <br>"; ################ Process File ######################### #my $file=<>; my $seqname=''; my $sequence=''; my %seqhash=(); open (FILE,"<$file") or die "Can't open $file\n"; while (my $line=<FILE>){ chomp($line); if ($line=~m/^>/){ my @temp=split(' ',$line); $seqname=substr($temp[0],1); } elsif ($line=~m/^\s$/||$line=~m/^$/){ $seqhash{$seqname}=$sequence; } else { $sequence=$sequence.$line; } } close (FILE); ######################################################## foreach my $key (keys %seqhash){ my $risk=docParser->new($key, $seqhash{$key} ); $risk->CAG_count(); } print $cgi->end_html."\n";
docParser.pm package docParser; use strict; sub new { my $class = shift; my $self = bless {}, $class; my $seqname=shift; my $sequence=shift; $self->{_seqname}=$seqname; $self->{_sequence}=$sequence; return $self; } sub CAG_count { my ($self)=shift; my $seqname=$self->{_seqname}; my $sequence=$self->{_sequence}; my $count_of_CAG=0; my @seq=split(//,$sequence); my $aa=''; my @position; my $len; my $amino_acid_number; for (my $index=0; $index<$#seq-2; $index+=3) { if ($sequence=~m/((CAG){6,})/g){ $count_of_CAG++; @position=index($sequence,$1); $len=length($1)/3; $amino_acid_number=shift(@position); } } print "For the sequence ".$seqname." we found a CAG string "; print "with $len\n repeats "; print "at amino acid number ".$amino_acid_number."\n\n"; if ($len<35) { print "Risk Evaluation: Normal"."\n\n"; } elsif ($len>36||$len<48) { print "Risk Evaluation: Warning"."\n\n"; } elsif ($len>48) { print "Risk Evaluation: Dangerous"."\n\n"; } } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing a file from a form, processing, and then outputting as html
by gone2015 (Deacon) on Dec 13, 2008 at 12:17 UTC | |
|
Re: Passing a file from a form, processing, and then outputting as html
by mr_mischief (Monsignor) on Dec 13, 2008 at 04:29 UTC | |
|
Re: Passing a file from a form, processing, and then outputting as html
by imrags (Monk) on Dec 13, 2008 at 06:50 UTC | |
|
Re: Passing a file from a form, processing, and then outputting as html
by YesOn8 (Initiate) on Dec 13, 2008 at 05:10 UTC | |
by mr_mischief (Monsignor) on Dec 13, 2008 at 06:02 UTC | |
by bobekdj (Initiate) on Dec 13, 2008 at 05:14 UTC |