Wednesday, January 19, 2011

Creating a quick codon table

I didn't think this up, the code comes from Peter Collingridge here.  But it is rather elegant.


bases = ['t', 'c', 'a', 'g']
codons = [a+b+c for a in bases for b in bases for c in bases]
amino_acids = "F F L L S S S S Y Y stop stop C C stop W L L L L P P P P H H Q Q R R R R I I I M T T T T N N K K S S R R V V V V A A A A D D E E G G G G".split(' ')
codon_table = dict(zip(codons, amino_acids))

No comments:

Post a Comment