Main Content

Converting codons via Amino Acids to Proteins in Perl

Archive - Originally posted on "The Horse's Mouth" - 2012-04-25 08:32:42 - Graham Ellis

DNA is the code of life - a double helix, comprising just four different basic codon elements:
  • Adenine (A)
  • Thymine (T)
  • Guanine (G)
  • Cytosine (c)
and a huge amount of work has gone into analysing these for the genes right across all types of life - including human genes. I understand (but I'm not an expert) that human DNA consists of a string of some 11 billions elements. So it's qute a data handling job to look after this lot and to extract data ... a good way to do that extraction is using the Practical Extraction and Reporting Language (Perl).

Codons are grouped in threes - GGT is one of several codes for the amino acid Glycine, for example; there are around 20 amino acids, and there is a code letter for each of them. G for Glycine, for example.

A group of amino acids then combines to form a protein, with the proteins in any particular DNA string being separated by particular 3-codon sequences with are the major break points - stop codes.

During last week's Perl course, I demonstrated Perl's data handling capability to do this conversion, writing a program from first principles - source code [here]. The conversion of sets of 3 codons to Amino acids uses an unchanging table of data across all sequences, so I've included it within the code file (at the end, not mixed with program lines!). But the sequences will vary - so they're read from separate files; there's an example [here] in industry standard fasta format.

  munchkin:a12perl grahamellis$ perl bacon
  GWG
 
  RCSWRSSGLEQRSRLAATFPRQSARPGRG
 
  APHRRVPRGCSSSGAARGSRWGLGAGPALQDGHSAVSFACLLGQGPEARRAARGEEEGAA
  RGGRGAGGLRGAASGQGRQRREPTQAAVRAHLGAHLEAPGGRVRQEEERQQEGDTQAGIH
  GPRPPGPATQPREPSPQGPGSPRRRRHRQAPGGASAHRARGCRHLRATVGGQRGRSAAGL
  GRGKASAAASPSPAGGAAGAWRLAAAGHRAGVHRRAAALSGRLRVPTLLSPQGAEPGRAG
  GLVPRCGPLAAAAGLARPGLHYACKPGVRVPAVPRVAAWGRAGVGRRAAGRLPHLPLPRL
  LLHGQRDLLPTQALPRGARQGALLAALPAPHPAAQPADAAAQRRPPLLHAGLSRPQERGR
  GRRQRRGPTERGRARRLLGRQGQLRGRNQALDYEPGPLGIPRGRAHPPPQPLTHTRTPRD
  HKATAAVTAAQRPGWAEEETPMPLRGKWRPGHQRPRCLDLLGVEWGRKMSAGKALQPHSS
  RLSAPPFLHFCRGLPLPFSPFPLGFIHFLASFLCLHFSSCLHSSLSLSLSLLFLSFFLPL
  PAFPFSVPWVCVSASPSYPLPDCTP
 
  TPVSPPAPVSPSALLVAPVMCHHLPSCLPSSSTCVSLHFFIPD
 
  VTTPLSPDQREY
 
  FLIWID
 
  GARRNCSPRYPDSHQDGPSPHPHRLSPPFPTCCMLGAGGCGGRGCRLLSGG
 
  GLEAKSTWETTPAAAPQWTGGRKRKLLTLEEGHPASLSLAFLLLLPTAPFNLFGCLRREGGGG
 
  AGPGTVRGAELGRDRNPPGRVPGTELGLGPCPRCQ
 
  CGPTERAALSVCPSVPERTIKRWKRL
  munchkin:a12perl grahamellis$


There are many standard Perl modules that can help with this sort of thing - so you may not want to write your own from scratch (remember - "if you think someone may have done it before, they probably have, and they have probably released the code open source")

If you want to learn how to do it for yourself - perhaps you're researching onwards from these fundamentals - take a look at our range of Perl courses - taking you through from the basics right through to modules on the specialist techniques you might want to employ to handle the huge data sets involved.