in reply to Re^4: translating multiple DNA sequence to protein sequence
in thread translating multiple DNA sequence to protein sequence

from the output I concluded that it is only for the ">header1". Moreover, this is not the required output

the output which i require is something like that:

>header1 HGADFFADJHGAJFGAFLGJ >header2 HJFSAGJFADGADKJAHGHJ

The UPPERCASE is the translated sequence of the DNA sequences

Replies are listed 'Best First'.
Re^6: translating multiple DNA sequence to protein sequence
by choroba (Cardinal) on Aug 22, 2013 at 10:28 UTC
    I see both header1 and header2 in the output. Moving one part of the print out of the loop is rather easy, you should study how loops work.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      okay thank you....I will post the code as soon as i get it right...cheers

        This is the code which I find it useful for translation

        I need to modify this code so that the output which i get get it saved in text file

        print "ENTER THE FILENAME OF THE DNA SEQUENCE:= "; $DNAfilename = <STDIN>; chomp $DNAfilename; unless ( open(DNAFILE, $DNAfilename) ) { print "Cannot open file \"$DNAfilename\"\n\n"; } @DNA = <DNAFILE>; close DNAFILE; $DNA = join( '', @DNA); #print " \nThe original DNA file is:\n$DNA \n"; $DNA =~ s/\s//g; my $protein=''; my $codon; for(my $i=0;$i<(length($DNA)-2);$i+=3) { $codon=substr($DNA,$i,3); $protein.=&codon2aa($codon); } print "The translated protein is :\n$protein\n"; <STDIN>; sub codon2aa{ my($codon)=@_; $codon=uc $codon; my(%g)=('TCA'=>'S','TCC'=>'S','TCG'=>'S','TCT'=>'S','TTC'=>'F','TTT'=> +'F','TTA'=>'L','TTG'=>'L','TAC'=>'Y','TAT'=>'Y','TAA'=>'X','TAG'=>'X' +,'TGC'=>'C','TGT'=>'C','TGA'=>'X','TGG'=>'W','CTA'=>'L','CTC'=>'L','C +TG'=>'L','CTT'=>'L','CCA'=>'P','CCC'=>'P','CCG'=>'P','CCT'=>'P','CAC' +=>'H','CAT'=>'H','CAA'=>'Q','CAG'=>'Q','CGA'=>'R','CGC'=>'R','CGG'=>' +R','CGT'=>'R','ATA'=>'I','ATC'=>'I','ATT'=>'I','ATG'=>'M','ACA'=>'T', +'ACC'=>'T','ACG'=>'T','ACT'=>'T','AAC'=>'N','AAT'=>'N','AAA'=>'K','AA +G'=>'K','AGC'=>'S','AGT'=>'S','AGA'=>'R','AGG'=>'R','GTA'=>'V','GTC'= +>'V','GTG'=>'V','GTT'=>'V','GCA'=>'A','GCC'=>'A','GCG'=>'A','GCT'=>'A +','GAC'=>'D','GAT'=>'D','GAA'=>'E','GAG'=>'E','GGA'=>'G','GGC'=>'G',' +GGG'=>'G','GGT'=>'G'); if(exists $g{$codon}) { return $g{$codon}; } else { print STDERR "Bad codon \"$codon\"!!\n"; exit; } }