Translating DNA into proteinΒΆ

Section author: Gavin Huttley

To translate a DNA alignment, read it in assigning the DNA alphabet. Note setting aligned = False is critical for loading sequences of unequal length. Different genetic codes are available in cogent3.core.genetic_code

>>> from cogent3 import LoadSeqs, DNA
>>> al = LoadSeqs('data/test2.fasta', moltype=DNA, aligned=False)
>>> pal = al.get_translation()
>>> print(pal.to_fasta())
>DogFaced
ARSQQNRWVETKETCNDRQT
>HowlerMon
ARSQHNRWAESEETCNDRQT
>Human
ARSQHNRWAGSKETCNDRRT
>Mouse
AVSQQSRWAASKGTCNDRQV
>NineBande
RQQSRWAESKETCNDRQT

To save this result to a file, use the write method.