#!/usr/bin/perl -w
use strict;
use CGI qw(:standard);
my $sequence = "";
# read data from our data.txt file (with our own demo
sequence)
open( INFILE, "data.txt");
while(<infile>){
my
$line = $_;
chomp
$line;
$sequence
= $sequence . $line;
}
close(INFILE);
# create a CGI object in order to create the HTML file
my $q = new CGI;
# read the parameters sent thru the form and do necessary
initializations
my $new_seq = $q->param("sequence") || "No Sequence";
$new_seq =~ s/[\s\n\t]+//g unless $new_seq =~ /No Sequence/;
$new_seq = "No Sequence" if $new_seq =~ /[^AaCcTtGg]/;
$sequence = $new_seq unless $new_seq =~ /No Sequence/ ;
$sequence = uc $sequence;
# define the fourmers
my $aw_fourmers = {
'GCGC' => [0], 'CGCG' => [0], 'AGAG' => [0], 'GAGA' => [0],
'TGTG' => [0], 'GTGT' => [0], 'TCTC' => [0], 'CTCT' => [0],
'ACAC' => [0], 'CACA' => [0], 'TATA' => [0], 'ATAT' => [0] };
# start printing the HTML file
print $q->header();
# print the sequence that has been pasted
$q->print("<html><head><title>Sequence Results </title></head><body
onLoad='javascript:focus()'>");
$q->print("<table border=0 cellpadding=3 cellspacing=2 width=\"700\"><tr
width='650'><td width=\"650\">");
my $pp = $sequence;
$pp =~ s/(\w{40})/$1\n/g;
$q->print("$pp<br>\n");
undef $pp;
$q->print("</td></tr></table>");
#compute the requested parameters
for( my $i=0; $i<$size; $i++){
my
$fourmer = substr( $sequence, $i, 4 );
$aw_fourmers->{$fourmer}->[0]++
if defined $aw_fourmers->{$fourmer};
}
# print the fourmers
&showFourmers($aw_fourmers) if ($actions->{'fourmers'}->[0]
|| $actions->{'all'}->[0]);
# close the HTML file
$q->print("</body></html>");
#__subs__#
sub showFourmers{
my
$aw_fourmers = shift;
foreach
my $quatros (sort keys %$aw_fourmers){
$q->print("$quatros\t
$aw_fourmers->{$quatros}->[0]<br>\n");
};
return;
}