here i have written the script using associative array. but unable to get the answer.
open(FH,"seq.txt");
@seq1 = <FH>;
shift(@seq1);
$seq = join('',@seq1);
print"$seq";
%pro=('I'=>'AUU','I'=>'AUC','I'=>'AUA','L'=>'CUU','L'=>'CUC','L'=>'CUA','L'=>'CUG','L'=>'UAA',
'L'=>'UUG','V'=>'GUU','V'=>'GUC','V'=>'GUA','V'=>'GUG','F'=>'UUU','F'=>'UUC','M'=>'AUG','C'=>'UGU',
'C'=>'UGC','A'=>'GCU','A'=>'GCC','A'=>'GCA','A'=>'GCG','G'=>'GGU','G'=>'GGC','G'=>'GGA','G'=>'GGG',
'P'=>'CCU','P'=>'CCC','P'=>'CCA','P'=>'CGG','T'=>'ACU','T'=>'ACC','T'=>'ACA','T'=>'ACG','S'=>'TCT',
'S'=>'TCC','S'=>'TCA','S'=>'TCG','S'=>'AGT','S'=>'AGC','Y'=>'TAT','Y'=>'TAC',
'W'=>'TGG','Q'=>'CAA','Q'=>'CAG','N'=>'AAT','N'=>'AAC','H'=>'CAT','H'=>'CAC',
'E'=>'GGA','E'=>'GAG','D'=>'GAT','D'=>'GAC','K'=>'AAA','K'=>'AAG',
'R'=>'CGT','R'=>'CGC','R'=>'CGA','R'=>'CGG','R'=>'AGA','R'=>'AGG',
'*'=>'TAA','*'=>'TAG','*'=>'TGA');
$p='';
$ln=length($seq);
$j=$ln;
for($i=0,$k=0;$i<$ln,$k<$j;$k++)
{
$fra[$k]=substr($seq,$i,1);
$i=$i++;
}
for($k=0;$k<$j;$k++)
{
if(exists($pro{$fra[$k]}))
{
$p=$p.$pro{$fra[$k]};
}
else
{
$p=$p.x;
}
}
print"$p";
By the way, I compared the output this produces and it looks like it matches that of the second result (the "consensus codons") of the web service that Jorge suggested. The first result of that web service (the "most likely codons") is based on the empirical frequencies of codons for each amino acid as observed in E. coli. Whether or not that is more appropriate depends on the organism you're dealing with.