Skip to content

Sequence Translation

Translate DNA sequences to amino acid sequences.

import pysegul
def translate_sequences():
translate = pysegul.SequenceTranslation(
input_fmt='nexus',
datatype='dna',
output_path='tests/output',
output_format='fasta',
table='1',
reading_frame=1,
)
translate.from_dir('tests/align-data')

To use a list of files, call from_files instead of from_dir:

translate.from_files(['tests/align-data/alignment1.nex', 'tests/align-data/alignment2.nex'])
OptionDefaultDescription
input_fmtRequired'auto', 'fasta', 'nexus', 'phylip'
datatypeRequired'dna', 'aa', 'ignore'
output_pathRequiredOutput directory
output_formatRequired'fasta', 'nexus', 'phylip', or interleaved 'fasta-int', 'nexus-int', 'phylip-int'
table'1'NCBI genetic code number as a string. See supported translation tables
reading_frameNone1, 2, or 3. Detected for each file when not set
MethodDescription
from_dir(input_dir)Translate the sequence files in a directory
from_files(input_files)Translate a list of sequence files

This material is based upon work supported by the National Science Foundation under grant numbers: DEB-1754393 and DEB-2244754. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the National Science Foundation.