Biotechnology Forums
PERL Program - BINC 2015 question - Printable Version

+- Biotechnology Forums (https://www.biotechnologyforums.com)
+-- Forum: Biotechnology Discussion (https://www.biotechnologyforums.com/forum-1.html)
+--- Forum: Bioinformatics (https://www.biotechnologyforums.com/forum-5.html)
+--- Thread: PERL Program - BINC 2015 question (/thread-7913.html)



PERL Program - BINC 2015 question - binu - 04-25-2017

Question :
i) An autocatalytic reaction is described by the expression
x/P = [exp(at) -1]/ [1 + b exp(at)], with a= ( A +P)k and b = P/A.
Write a program in C or JAVA or Perl or PYTHON to calculate x/P for three values of t (t =1,2 and 3)
using a & b as given in the input file autocat.dat.
Report if the saturation is reached by printing a string, “The saturation is reached. The values
are” and then print the value of ( x/P, a, b and t) for the saturation point.
Otherwise, print the message “ The Saturation is not reached” . All your output, including
these messages is to be saved in a file called autocat.out.



Solution :


#!/usr/bin/perl -w
# BINC 2015 sample question paper 3 solution
use strict;
my ($line,@arraya,@arrayb,$xp,$t,$j);
my $i=0;
open (FILE, "autocat.dat.txt") or
die "Cannot open file \n\n" ;

while ($line = <FILE>)
{
if ($line =~ /^a/ )
{ next; } 
else

$arraya[$i] = (split (/\s+/, $line))[0];
$arrayb[$i] = (split (/\s+/, $line))[1];
$i++; 
}
}
close FILE;

$j=$i; 
print "The value of J=$j \n";
open (OUTPUT, ">autocat.out");
for ($t=1;$t<4;$t++)
{
for($i=0;$i<$j;$i++)
{
$xp = (exp($arraya[$i]*$t) -1) / (1 + ($arrayb[$i]*exp($arraya[$i]*$t))); 
print "When T=$t the value of XP=$xp \n";
if ($xp==100)

print "The saturation is reached. The values are : \nXP=$xp \na=$arraya[$i] \nb=$arrayb[$i] \nt=$t\n\n";
print OUTPUT "The saturation is reached. The values are : \nXP=$xp \na=$arraya[$i] \nb=$arrayb[$i] \nt=$t\n\n";
}
else

print "The Saturation is not reached \n\n";
print OUTPUT "The Saturation is not reached \n\n";
}

}
close OUTPUT;