Skip to content

Commit

Permalink
Merge pull request #1317 from nextstrain/export-root-aa-sequences-fro…
Browse files Browse the repository at this point in the history
…m-ancestral

Export ancestral AA sequences for tree's root node
  • Loading branch information
huddlej authored Sep 20, 2023
2 parents e19b5e5 + 1212730 commit 82ed696
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
9 changes: 7 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@
### Features

* Support treetime 0.11.* [#1310][] (@corneliusroemer)
* Allow minimal export using only a (newick) tree in `augur export v2`. [#1299][] (@jameshadfield)
* export: Allow minimal export using only a (newick) tree in `augur export v2`. [#1299][] (@jameshadfield)
* A number of schema updates and improvements [#1299][] (@jameshadfield)
* We now require all nodes to have `node_attrs` on them with one of `div` or `num_date` present
* Some never-used properties are removed from the schemas, including a pattern for defining nucleotide INDELs which was never used by augur or auspice.
* Tip label defaults are now settable within the auspice-config JSON
* Empty colorings definitions are allowed (the tree will be grey in Auspice)

[#1310]: https://github.com/nextstrain/augur/pull/1310
### Bug fixes

* ancestral: Export amino acid sequences inferred for the root node of the tree in the node data JSON output for compatibility with `augur translate` output. [#1317][] (@huddlej)

[#1299]: https://github.com/nextstrain/augur/pull/1299
[#1310]: https://github.com/nextstrain/augur/pull/1310
[#1317]: https://github.com/nextstrain/augur/pull/1317

## 23.0.0 (5 September 2023)

Expand Down
8 changes: 8 additions & 0 deletions augur/ancestral.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@ def run(args):
for key, node in anc_seqs['nodes'].items():
if 'aa_muts' not in node: node['aa_muts'] = {}
node['aa_muts'][gene] = aa_result['mutations']['nodes'][key]['muts']

# Add amino acid sequences to the root node of the tree.
if key == T.root.name:
if "aa_sequences" not in node:
node["aa_sequences"] = {}

node["aa_sequences"][gene] = aa_result['tt'].sequence(T.root, as_string=True, reconstructed=True)

anc_seqs['reference'][gene] = aa_result['root_seq']
# FIXME: Note that this is calculating the end of the CDS as 3*length of translation
# this is equivalent to the annotation for single segment CDS, but not for cds
Expand Down
7 changes: 7 additions & 0 deletions tests/functional/ancestral/cram/infer-amino-acid-sequences.t
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ Check that the reference length was correctly exported as the nuc annotation
"PRO": {
"nuc": {
Check that amino acid sequences exist for the root node of the tree.
$ grep -A 2 "aa_sequences" "$CRAMTMP/$TESTFILE/ancestral_mutations.json"
"aa_sequences": {
"ENV": .* (re)
"PRO": .* (re)
Check that internal nodes have ancestral amino acid sequences.
$ grep "NODE" "$CRAMTMP/$TESTFILE/ancestral_aa_sequences_ENV.fasta" | wc -l
Expand Down

0 comments on commit 82ed696

Please sign in to comment.