#!/usr/local/bin/perl
use CGI;
$query = new CGI;
$var1 = ($query->param("var1"));
$lcseq = lc($var1);
chomp ($lcseq);
$oligolength = length($lcseq);
$SCRIPT_uri = $ENV{'SCRIPT_URI'};
$tm = 0;
$charpos = 0;
until($charpos == $oligolength)
{
$pair = substr($lcseq, $charpos, 2);
if ($pair eq "aa"){$tm += 2.116;}
if ($pair eq "ac"){$tm += 3.068;}
if ($pair eq "ag"){$tm += 2.750;}
if ($pair eq "at"){$tm += 1.862;}
if ($pair eq "ca"){$tm += 3.068;}
if ($pair eq "cc"){$tm += 3.893;}
if ($pair eq "cg"){$tm += 4.591;}
if ($pair eq "ct"){$tm += 2.708;}
if ($pair eq "ga"){$tm += 2.750;}
if ($pair eq "gc"){$tm += 4.739;}
if ($pair eq "gg"){$tm += 3.893;}
if ($pair eq "gt"){$tm += 3.047;}
if ($pair eq "ta"){$tm += 1.227;}
if ($pair eq "tc"){$tm += 2.708;}
if ($pair eq "tg"){$tm += 3.047;}
if ($pair eq "tt"){$tm += 2.116;}
$charpos = $charpos +1;
}
###################################### start %gc
$at = 0;
$gc = 0;
$gcpercent = 0;
$charpos = 0;
until($charpos == $oligolength)
{
$base = substr($lcseq, $charpos, 1);
if ($base eq "a") {$at += 1}
if ($base eq "c") {$gc += 1}
if ($base eq "g") {$gc += 1}
if ($base eq "t") {$at += 1}
$charpos = $charpos +1;
}
$gcpercent = ($gc / (($at + $gc) +
0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 )); ####cheated part
###################################### end %gc
$tm = $tm + (5*$gcpercent);
print "Content-type: text/html\n\n";
print "<html>";
print "<head><title>tm calculator</title></head>";
print "<body>";
if ($var1 eq '') {
print "<form action=\"$SCRIPT_uri\" method=\"POST\">";
print "Sequence: <input type=\"text\" name=\"var1\">\n";
print "<input type=\"submit\" value=\"submit\">\n";
print "</form>";
} else {
print "Your sequence is $oligolength characters.\n";
print "The tm of your sequence is $tm";
}
print "</body>";
print "</html>";
exit;
my $div_by_zero; # if needed
if ($at + $gc) {
$gcpercent = ($gc / ($at + $gc));
$tm = $tm + (5*$gcpercent);
} else {
# Handle the division by zero, however it is appropriate
$tm = "Undefined."; # Maybe?
$div_by_zero = 1; # If you need this
} I'm guessing this app is for building oligonucleotides. That's pretty technical stuff; it's hard to tell what your app should be doing.
Um, exactly what was the question again?
sounds like it is standard practice to be on the lookout for all possible divisions by zero? for example, any time a division operation includes a variable in the denominator? I'm going to include timster's "explicit" handling of the gcpercent assignment ... and i guess always include timster's explicit handling of division?
Enrique finished his internship on Friday and left full of gratitude ... he will be a High School Sophmore in the Fall ! ... I'm sure he wont soon forget you guys and all you taught him ...
thanks again and again
rudyS