Remove trailing stop codons from sequences in an alignment#

Note

These docs now use the new_type core objects via the following setting.

import os

# using new types without requiring an explicit argument
os.environ["COGENT3_NEW_TYPE"] = "1"

For evolutionary analyses that use codon models, we need to exclude terminating stop codons. To account for the difference in stop codons in different genetic codes, we can provide an argument for the genetic code. For a list of all genetic codes, see here.

from cogent3 import get_app, make_aligned_seqs

aln = make_aligned_seqs(
    data={"seq1": "ACGTAA---", "seq2": "ACGACA---", "seq3": "ACGCAATGA"},
    moltype="dna",
)
no_stops = get_app("trim_stop_codons", gc=1)
no_stops(aln)
0
seq2ACGACA---
seq1...---...
seq3...CA....

3 x 9 dna alignment