1) Translating 'all' combinations of triple bases into amino acids

From Biolecture.org
Revision as of 16:34, 17 May 2017 by imported>S (Created page with "<p><u><strong><span style="font-family:tahoma,geneva,sans-serif"><span style="font-size:14px">Run it on perl. You can enter booth triplet nucleotides and whole sequence, this pro...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Run it on perl. You can enter booth triplet nucleotides and whole sequence, this program will tranlate it to aminoacids: 

#!usr/bin/perl/
use strict;
use warnings;

 my %anticodon;                                  ## creating hash to assign each combination to aminoacid
 while (<DATA>){                                    ##reading DATA file at the end of the script 
 chomp($_);                                            ##chomping new lines in text data
 my @codons = split " ", $_;                  ## break apart by " " spaces into arrays in each line 
 my $aminoacid = shift @codons;         ## shift takes out first item from the list @codons
 foreach my $code (@codons){                ##each left codons in the list
  $anticodon{$code} = $aminoacid;            ## every codon in the line will be coupled with above-shifted-aminoacid 
}}
  print "Enter triple bases, we will find aminoacids: \n ";           ##printing
  my $triplet = <STDIN>;                                                    ##reads user entered line
  chomp $triplet;                                      
  $triplet = uc $triplet;                                                              ##change all entered string into uppercase
  my $aaseq; 
  while ($triplet =~ s/(...)//){                                              ##if there is sequence, will take first three bases, then second ...
  $aaseq .= $anticodon{$1};                                                 ## finding from hash amino acid corresponding to triple bases and storing it in another scalar variable
}

 print "Corresponding aminoacid sequence is: $aaseq\n";

__DATA__
Ala GCU GCC GCA GCG
Arg CGU CGC GCA CGG AGA AGG
Asn AAU AAC
Asp GAU GAC
Cys UGU UGC
Gln CAA CAG
Glu GAA GAG
Gly GGU GGC GGA GGG
His CAU CAC 
Ile AUU AUC AUA
Leu UUA UUG CUU CUC CUA CUG
Lys AAA AAG
Met AUG
Phe UUU UUC
Pro CCU CCC CCA CCG
Ser UCU UCC UCA UCG AGU AGC
Thr ACU ACC ACA ACG
Trp UGG
Tyr UAU UAC
Val GUU GUC GUA GUG
Stop UAA UAG UGA