-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
augur clades allows attribute name to be specified
Previously the `augur clades` command produced a node-data JSON which stored clade membership as the node-attr "clade_membership" and defined the basal nodes of each clade with the node-attr "clade_annotation". `augur export v2` interpreted the latter as a special-case and turned it into a branch label of the same name. The previous commit allowed `augur export` to be supplied node-data JSONs with a `branches` dictionary. Here we update `augur clades` to export data in this structure, which allows the user to specify the keys to use via the `--attribute-name` arg. This commit breaks backwards compatibility for pipelines as the default attribute name is "clade". This will result in dataset (auspice) JSONs with the same branch labelling as before, but with a different node-attr (was "clade_membership", now "clade"). As `augur export v2` will make colorings for all node-attrs in in node-data JSONs, this will be exported as a "clade" coloring with no changes needed, however auspice config JSONs may now refer to a non-existent "clade_membership" key. `augur export v2` has been updated to no longer special-case `clade_membership` or `clade_annotation` node attrs. We print a warning if an auspice config JSON refers to `clade_membership` to help users update their configs. Functional tests for `augur clades` have been added. Closes #720
- Loading branch information
1 parent
695bfec
commit 422084d
Showing
8 changed files
with
195 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Integration tests for augur clades. | ||
|
||
$ pushd "$TESTDIR" > /dev/null | ||
$ export AUGUR="../../bin/augur" | ||
|
||
Run augur clades without --attribute-name. We expect the name to be "clade" | ||
|
||
$ ${AUGUR} clades \ | ||
> --tree clades/tree.nwk \ | ||
> --clades clades/clades.tsv \ | ||
> --mutations clades/nt_muts.json \ | ||
> --output-node-data "$TMP/default.json" > /dev/null | ||
|
||
$ python3 "$TESTDIR/../../scripts/diff_jsons.py" "clades/expected-output-default.json" "$TMP/default.json" | ||
{} | ||
|
||
Run augur clades with a custom --attribute-name | ||
|
||
$ ${AUGUR} clades \ | ||
> --tree clades/tree.nwk \ | ||
> --clades clades/clades.tsv \ | ||
> --mutations clades/nt_muts.json \ | ||
> --attribute-name custom \ | ||
> --output-node-data "$TMP/custom-attr.json" > /dev/null | ||
|
||
$ python3 "$TESTDIR/../../scripts/diff_jsons.py" "clades/expected-output-custom-attr.json" "$TMP/custom-attr.json" | ||
{} | ||
|
||
Ensure the only change between runs of `augur clades` is the attr name used | ||
$ cat "$TMP/default.json" | sed "s/clade/custom/" > "$TMP/default-now-custom.json" | ||
$ diff -u "$TMP/default-now-custom.json" "$TMP/custom-attr.json" | ||
|
||
Cleanup | ||
$ rm -f "$TMP/default.json" "$TMP/custom-attr.json" "$TMP/default-now-custom.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
clade gene site alt | ||
|
||
# the 1b mutation only once, on the branch leading to tips B and C | ||
# thus we expect the clade label to be on node `internalAB` | ||
cladeCB nuc 1 B | ||
# the 2c mutation appears twice -- on branch `internalAB` and `internalDEF` | ||
# as the latter has 3 descendants, it is chosen over the former | ||
cladeDEF nuc 2 C | ||
# mutation 3e appears only on a terminal node (tipE) | ||
# but we still expect both a branch label and a node_attr | ||
# this means that tipE should be annotated "cladeE" and _not_ "cladeDEF" | ||
cladeE nuc 3 E |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"branches": { | ||
"internalBC": { | ||
"labels": { | ||
"custom": "cladeCB" | ||
} | ||
}, | ||
"internalDEF": { | ||
"labels": { | ||
"custom": "cladeDEF" | ||
} | ||
}, | ||
"tipE": { | ||
"labels": { | ||
"custom": "cladeE" | ||
} | ||
} | ||
}, | ||
"generated_by": { | ||
"program": "augur", | ||
"version": "12.0.0" | ||
}, | ||
"nodes": { | ||
"internalBC": { | ||
"custom": "cladeCB" | ||
}, | ||
"internalDEF": { | ||
"custom": "cladeDEF" | ||
}, | ||
"tipB": { | ||
"custom": "cladeCB" | ||
}, | ||
"tipC": { | ||
"custom": "cladeCB" | ||
}, | ||
"tipD": { | ||
"custom": "cladeDEF" | ||
}, | ||
"tipE": { | ||
"custom": "cladeE" | ||
}, | ||
"tipF": { | ||
"custom": "cladeDEF" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"branches": { | ||
"internalBC": { | ||
"labels": { | ||
"clade": "cladeCB" | ||
} | ||
}, | ||
"internalDEF": { | ||
"labels": { | ||
"clade": "cladeDEF" | ||
} | ||
}, | ||
"tipE": { | ||
"labels": { | ||
"clade": "cladeE" | ||
} | ||
} | ||
}, | ||
"generated_by": { | ||
"program": "augur", | ||
"version": "12.0.0" | ||
}, | ||
"nodes": { | ||
"internalBC": { | ||
"clade": "cladeCB" | ||
}, | ||
"internalDEF": { | ||
"clade": "cladeDEF" | ||
}, | ||
"tipB": { | ||
"clade": "cladeCB" | ||
}, | ||
"tipC": { | ||
"clade": "cladeCB" | ||
}, | ||
"tipD": { | ||
"clade": "cladeDEF" | ||
}, | ||
"tipE": { | ||
"clade": "cladeE" | ||
}, | ||
"tipF": { | ||
"clade": "cladeDEF" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"nodes": { | ||
"tipA": {"muts": [], "aa_muts": {}}, | ||
"tipB": {"muts": [], "aa_muts": {}}, | ||
"tipC": {"muts": [], "aa_muts": {}}, | ||
"tipD": {"muts": [], "aa_muts": {}}, | ||
"tipE": {"muts": ["A3E"], "aa_muts": {}}, | ||
"tipF": {"muts": [], "aa_muts": {}}, | ||
"internalBC": { | ||
"muts": ["A1B", "A2C"], | ||
"aa_muts": {} | ||
}, | ||
"internalDEF": { | ||
"muts": ["A2C"], | ||
"aa_muts": {} | ||
}, | ||
"ROOT":{"muts": [], "aa_muts": {}} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(tipA:1,(tipB:1,tipC:1)internalBC:2,(tipD:3,tipE:4,tipF:1)internalDEF:5)ROOT:1; |