Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up tests #703

Merged
merged 2 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 0 additions & 142 deletions tests/builds/zika_compressed.t
Original file line number Diff line number Diff line change
Expand Up @@ -46,148 +46,6 @@ Filter sequences by a minimum date and an exclusion list and only keep one seque
$ gzip -c -d "$TMP/out/filtered.fasta.gz" | grep "^>" | wc -l
\s*10 (re)

Align filtered sequences to a specific reference sequence and fill any gaps.

$ ${AUGUR} align \
> --sequences "results/filtered.fasta" \
> --reference-sequence "config/zika_outgroup.gb" \
> --output "$TMP/out/aligned.fasta" \
> --fill-gaps > /dev/null

$ diff -u "results/aligned.fasta" "$TMP/out/aligned.fasta"

Build a tree from the multiple sequence alignment.

$ ${AUGUR} tree \
> --alignment "results/aligned.fasta" \
> --output "$TMP/out/tree_raw.nwk" \
> --method iqtree \
> --tree-builder-args "-seed 314159" > /dev/null

$ python3 "$TESTDIR/../../scripts/diff_trees.py" "results/tree_raw.nwk" "$TMP/out/tree_raw.nwk" --significant-digits 5
{}

Confirm that tree log file exists.

$ test -e "results/aligned-delim.iqtree.log"
$ echo $?
0

Build a time tree from the existing tree topology, the multiple sequence alignment, and the strain metadata.

$ ${AUGUR} refine \
> --tree "results/tree_raw.nwk" \
> --alignment "results/aligned.fasta" \
> --metadata "results/metadata.tsv.gz" \
> --output-tree "$TMP/out/tree.nwk" \
> --output-node-data "$TMP/out/branch_lengths.json" \
> --timetree \
> --coalescent opt \
> --date-confidence \
> --date-inference marginal \
> --clock-filter-iqd 4 \
> --seed 314159 > /dev/null

Confirm that TreeTime trees match expected topology and branch lengths.

$ python3 "$TESTDIR/../../scripts/diff_trees.py" "results/tree.nwk" "$TMP/out/tree.nwk" --significant-digits 2
{}

Branch lengths and other annotations like dates are too stochastic across runs to consistently compare with reasonable precision.

#$ python3 "$TESTDIR/../../scripts/diff_jsons.py" "results/branch_lengths.json" "$TMP/out/branch_lengths.json" --significant-digits 0
#{}

Calculate tip frequencies from the tree.

$ ${AUGUR} frequencies \
> --method kde \
> --tree "results/tree.nwk" \
> --metadata "results/metadata.tsv.gz" \
> --pivot-interval 3 \
> --output "$TMP/out/zika_tip-frequencies.json" > /dev/null

$ diff -u --ignore-matching-lines version "auspice/zika_tip-frequencies.json" "$TMP/out/zika_tip-frequencies.json"

Infer ancestral sequences from the tree.

$ ${AUGUR} ancestral \
> --tree "results/tree.nwk" \
> --alignment "results/aligned.fasta" \
> --infer-ambiguous \
> --output-node-data "$TMP/out/nt_muts.json" \
> --inference joint > /dev/null

$ diff -u --ignore-matching-lines version "results/nt_muts.json" "$TMP/out/nt_muts.json"

Infer ancestral traits from the tree.

$ ${AUGUR} traits \
> --tree "results/tree.nwk" \
> --weights "config/trait_weights.csv" \
> --metadata "results/metadata.tsv.gz" \
> --output-node-data "$TMP/out/traits.json" \
> --columns country region \
> --sampling-bias-correction 3 \
> --confidence > /dev/null

$ python3 "$TESTDIR/../../scripts/diff_jsons.py" "results/traits.json" "$TMP/out/traits.json" --significant-digits 5
{}

Implicit mugration model outputs are not written to the same directory as the traits output, so we cannot test for matching mugration models here.
See augur issue 541 (https://github.com/nextstrain/augur/issues/541) for more details.

#$ diff -u "results/treecountry.mugration_model.txt" "$TMP/out/treecountry.mugration_model.txt"
#$ diff -u "results/treeregion.mugration_model.txt" "$TMP/out/treeregion.mugration_model.txt"

Translate inferred ancestral and observed nucleotide sequences to amino acid mutations.

$ ${AUGUR} translate \
> --tree "results/tree.nwk" \
> --ancestral-sequences "$TMP/out/nt_muts.json" \
> --reference-sequence "config/zika_outgroup.gb" \
> --output-node-data "$TMP/out/aa_muts.json" > /dev/null

$ diff -u --ignore-matching-lines version "results/aa_muts.json" "$TMP/out/aa_muts.json"

Export JSON files as v1 auspice outputs.

$ ${AUGUR} export v1 \
> --tree "results/tree.nwk" \
> --metadata "results/metadata.tsv.gz" \
> --node-data "$TMP/out/branch_lengths.json" \
> "$TMP/out/traits.json" \
> "$TMP/out/nt_muts.json" \
> "$TMP/out/aa_muts.json" \
> --colors "config/colors.tsv" \
> --auspice-config "config/auspice_config_v1.json" \
> --output-tree "$TMP/out/v1_zika_tree.json" \
> --output-meta "$TMP/out/v1_zika_meta.json" \
> --output-sequence "$TMP/out/v1_zika_seq.json" > /dev/null

$ ${AUGUR} validate export-v1 "$TMP/out/v1_zika_meta.json" "$TMP/out/v1_zika_tree.json" > /dev/null

Compare auspice metadata files, but ignore the "updated" field since this changes with the date the export command is run.

$ diff -u --ignore-matching-lines updated "auspice/v1_zika_meta.json" "$TMP/out/v1_zika_meta.json"

Export JSON files as v2 auspice outputs.

$ ${AUGUR} export v2 \
> --tree "results/tree.nwk" \
> --metadata "results/metadata.tsv.gz" \
> --node-data "$TMP/out/branch_lengths.json" \
> "$TMP/out/traits.json" \
> "$TMP/out/nt_muts.json" \
> "$TMP/out/aa_muts.json" \
> --colors "config/colors.tsv" \
> --auspice-config "config/auspice_config_v2.json" \
> --output "$TMP/out/v2_zika.json" \
> --title 'Real-time tracking of Zika virus evolution -- v2 JSON' \
> --panels tree map entropy frequencies > /dev/null

$ ${AUGUR} validate export-v2 "$TMP/out/v2_zika.json" > /dev/null

Switch back to the original directory where testing started.

$ popd > /dev/null
3 changes: 3 additions & 0 deletions tests/functional/tree.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ Try building a tree with IQ-TREE with more threads (4) than there are input sequ
> --nthreads 4 > /dev/null
WARNING: more threads requested than there are sequences; falling back to IQ-TREE's `-nt AUTO` mode.

Clean up tree log files.

$ rm -f tree/*.log
$ popd > /dev/null
8 changes: 1 addition & 7 deletions tests/test_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,7 @@ def test_run_fill_gaps(self, test_file, ref_file, run, fill_gaps):
assert output["SUFFIX"].seq.endswith(expected_char*3)
if fill_gaps:
assert all("-" not in record.seq for record in output.values())

def test_run_error_during_alignment(self, test_file, argparser, mp_context):
"""Not a great test - we can't be sure we're not failing some other check somewhere along the way, but it's all we can do"""
mp_context.setattr(align, "run_shell_command", lambda i: False)
args = argparser("-s %s" % test_file)
assert align.run(args) == 1


def test_run_debug_files(self, test_file, out_file, run):
run("-s %s --debug" % test_file)
assert os.path.isfile(out_file + ".pre_aligner.fasta")
Expand Down