Skip to content

Commit

Permalink
Merge pull request #1658: clades: Update Cram tests
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlin authored Oct 25, 2024
2 parents 862aa37 + ba370d9 commit 37958a6
Show file tree
Hide file tree
Showing 20 changed files with 106 additions and 94 deletions.
94 changes: 0 additions & 94 deletions tests/functional/clades.t

This file was deleted.

2 changes: 2 additions & 0 deletions tests/functional/clades/cram/_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export AUGUR="${AUGUR:-$TESTDIR/../../../../bin/augur}"
set -o pipefail
18 changes: 18 additions & 0 deletions tests/functional/clades/cram/membership-and-label.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Integration tests for augur clades.

$ source "$TESTDIR"/_setup.sh

Test custom membership key + label key. The only change should be the key names

$ ${AUGUR} clades \
> --tree "$TESTDIR/../data/tree.nwk" \
> --mutations "$TESTDIR/../data/aa_muts.json" "$TESTDIR/../data/nt_muts_small.json" \
> --clades "$TESTDIR/../data/clades.tsv" \
> --membership-name lineage --label-name origin \
> --output-node-data clades_custom.json &>/dev/null

$ cat clades_custom.json | sed "s/lineage/clade_membership/" | sed "s/origin/clade/" > clades_sed.json

$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/clades.json" clades_sed.json \
> --exclude-paths "root['generated_by']"
{}
12 changes: 12 additions & 0 deletions tests/functional/clades/cram/multiple-mutations-error.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Integration tests for augur clades.

$ source "$TESTDIR"/_setup.sh

Multiple mutations at the same position on a single branch are a fatal error

$ ${AUGUR} clades \
> --tree "$TESTDIR/../data/toy_tree.nwk" \
> --mutations "$TESTDIR/../data/toy_muts_multiple.json" \
> --clades "$TESTDIR/../data/toy_clades_nuc.tsv"
ERROR: Multiple mutations at the same position on a single branch were found: Node A (nuc), Node AB (geneName)
[2]
16 changes: 16 additions & 0 deletions tests/functional/clades/cram/no-label.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Integration tests for augur clades.

$ source "$TESTDIR"/_setup.sh

Test the ability to _not_ export a branch label (same logic as not exporting the membership)

$ ${AUGUR} clades \
> --tree "$TESTDIR/../data/tree.nwk" \
> --mutations "$TESTDIR/../data/aa_muts.json" "$TESTDIR/../data/nt_muts_small.json" \
> --clades "$TESTDIR/../data/clades.tsv" \
> --label-name none \
> --output-node-data clades_no-labels.json &>/dev/null

$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/clades.json" clades_no-labels.json \
> --exclude-paths "root['generated_by']"
{'dictionary_item_removed': [root['branches']]}
43 changes: 43 additions & 0 deletions tests/functional/clades/cram/root-clade-identification.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Integration tests for augur clades.

$ source "$TESTDIR"/_setup.sh

A clade which exists at the root is not identified by inferring the root state
(i.e. we don't infer the root state to be A if we observe a subsequent A10T mutation)
This is an oversight and ideally would be fixed

$ ${AUGUR} clades \
> --tree "$TESTDIR/../data/toy_tree.nwk" \
> --mutations "$TESTDIR/../data/toy_muts_no_ref.json" \
> --clades "$TESTDIR/../data/toy_clades_nuc.tsv" \
> --output-node-data toy_clades_1.json &>/dev/null

$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/toy_clades_1.json" toy_clades_1.json \
> --exclude-paths "root['generated_by']"
{}

A clade which exists at the root is identified (and correctly propogated) if the root sequence
is explicitly set.

$ ${AUGUR} clades \
> --tree "$TESTDIR/../data/toy_tree.nwk" \
> --mutations "$TESTDIR/../data/toy_muts_ref.json" \
> --clades "$TESTDIR/../data/toy_clades_nuc.tsv" \
> --output-node-data toy_clades_2a.json &>/dev/null

$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/toy_clades_2.json" toy_clades_2a.json \
> --exclude-paths "root['generated_by']"
{}

A clade which exists at the root is identified (and correctly propogated) without a root sequence
if the (branch leading to the) root has the clade-defining mutation.

$ ${AUGUR} clades \
> --tree "$TESTDIR/../data/toy_tree.nwk" \
> --mutations "$TESTDIR/../data/toy_muts_explicit_root_mutation.json" \
> --clades "$TESTDIR/../data/toy_clades_nuc.tsv" \
> --output-node-data toy_clades_2b.json &>/dev/null

$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/toy_clades_2.json" toy_clades_2b.json \
> --exclude-paths "root['generated_by']"
{}
15 changes: 15 additions & 0 deletions tests/functional/clades/cram/simple.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Integration tests for augur clades.

$ source "$TESTDIR"/_setup.sh

Test augur clades with simple Zika input files and hierarchical clades.

$ ${AUGUR} clades \
> --tree "$TESTDIR/../data/tree.nwk" \
> --mutations "$TESTDIR/../data/aa_muts.json" "$TESTDIR/../data/nt_muts_small.json" \
> --clades "$TESTDIR/../data/clades.tsv" \
> --output-node-data clades.json &>/dev/null

$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/clades.json" clades.json \
> --exclude-paths "root['generated_by']"
{}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 37958a6

Please sign in to comment.