Hi,
Didn't read the previous perl posts? Go here, perl #1 #2 #3 #4)
In the previous post of perl programming, we learnt how to search an aminoacid in a protein sequence. Now, we are going to look at a program by which the "start and stop codons" in a protein sequence could be easily identified. Here, we go,
Program to identify start and stop codons easily:
print "enter a file containing Dna sequence\n";
$dnafile=<>;
chomp($dnafile);
unless(open(DNAFILENAME,$dnafile))
{
print "file not found\n";
exit;
}
$dna=<DNAFILENAME>;
$dna=join("",$dna);
$dna=~s/\s//g;
$dna=uc($dna);
$dna=~tr/T/U/;
print "The mrna is:\t",$dna,"\n";
my(%code)=
(
'AUG'=>'Start',
'UGA'=>'Stop',
'UAA'=>'Stop',
'UAG'=>'Stop',
);
for($i=0;$i<(length($dna)-2);$i+=3)
{
$codon=substr($dna,$i,3);
if($codon=~AUG)
{
$out.=$code{$codon};
}
elsif($codon=~UAG)
{
$out.=$code{$codon};
}
elsif($codon=~UAA)
{
$out.=$code{$codon};
}
else
{
$out.=$codon;
}
}
$out=~tr/U/T/;
print "the dna seq is\t",$out;
exit;
When you run the above program, you would get the result just like this:
Happy perl-ing, Any doubts, just comment, I'll try to clear.
Bye. :)
Didn't read the previous perl posts? Go here, perl #1 #2 #3 #4)
In the previous post of perl programming, we learnt how to search an aminoacid in a protein sequence. Now, we are going to look at a program by which the "start and stop codons" in a protein sequence could be easily identified. Here, we go,
Program to identify start and stop codons easily:
print "enter a file containing Dna sequence\n";
$dnafile=<>;
chomp($dnafile);
unless(open(DNAFILENAME,$dnafile))
{
print "file not found\n";
exit;
}
$dna=<DNAFILENAME>;
$dna=join("",$dna);
$dna=~s/\s//g;
$dna=uc($dna);
$dna=~tr/T/U/;
print "The mrna is:\t",$dna,"\n";
my(%code)=
(
'AUG'=>'Start',
'UGA'=>'Stop',
'UAA'=>'Stop',
'UAG'=>'Stop',
);
for($i=0;$i<(length($dna)-2);$i+=3)
{
$codon=substr($dna,$i,3);
if($codon=~AUG)
{
$out.=$code{$codon};
}
elsif($codon=~UAG)
{
$out.=$code{$codon};
}
elsif($codon=~UAA)
{
$out.=$code{$codon};
}
else
{
$out.=$codon;
}
}
$out=~tr/U/T/;
print "the dna seq is\t",$out;
exit;
When you run the above program, you would get the result just like this:
PERL |
Bye. :)
Comments
Post a Comment