augur.translate module

Translate gene regions from nucleotides to amino acids.

exception augur.translate.MismatchNodeError

Bases: Exception

exception augur.translate.MissingNodeError

Bases: Exception

augur.translate.assign_aa_fasta(tree, translations)
augur.translate.assign_aa_vcf(tree, translations)
augur.translate.construct_mut(start, pos, end)
augur.translate.get_genes_from_file(fname)
augur.translate.register_arguments(parser)
augur.translate.run(args)
augur.translate.safe_translate(sequence, report_exceptions=False)

Returns an amino acid translation of the given nucleotide sequence accounting for gaps in the given sequence.

Optionally, returns a tuple of the translated sequence and whether an exception was raised during initial translation.

>>> safe_translate("ATG")
'M'
>>> safe_translate("ATGGT-")
'MX'
>>> safe_translate("ATG---")
'M-'
>>> safe_translate("ATGTAG")
'M*'
>>> safe_translate("")
''
>>> safe_translate("ATGT")
'MX'
>>> safe_translate("ATG", report_exceptions=True)
('M', False)
>>> safe_translate("ATGA-G", report_exceptions=True)
('MX', True)
augur.translate.translate_feature(aln, feature)

Translates a subsequence of input nucleotide sequences.

Parameters
  • aln (dict) – sequences indexed by node name

  • feature (Bio.Seq.Seq) – BioPython sequence feature

Returns

translated sequences indexed by node name

Return type

dict

augur.translate.translate_vcf_feature(sequences, ref, feature)

Translates a subsequence of input nucleotide sequences.

Parameters
  • sequences (dict) – TreeTime format dictionary from VCF-input of sequences indexed by node name

  • ref – reference alignment the VCF was mapped to

  • feature (Bio.Seq.Seq) – BioPython sequence feature

Returns

translated reference gene, positions of AA differences, and AA differences indexed by node name

Return type

dict