Skip to content

Commit

Permalink
Add functional tests for augur export v2
Browse files Browse the repository at this point in the history
This sets up a template for testing `augur export v2` which is
rather complex in the different ways it can be called. The tests here
are only intended to cover features introduced by this PR.
  • Loading branch information
jameshadfield committed Jun 8, 2021
1 parent c4dd27f commit 73649be
Show file tree
Hide file tree
Showing 7 changed files with 426 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/functional/export_v2.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Integration tests for augur export v2.

$ pushd "$TESTDIR" > /dev/null
$ export AUGUR="../../bin/augur"

Minimal export

$ ${AUGUR} export v2 \
> --tree export_v2/tree.nwk \
> --node-data export_v2/div_node-data.json \
> --output "$TMP/minimal.json" &>/dev/null
[2]

$ python3 "$TESTDIR/../../scripts/diff_jsons.py" export_v2/minimal.json "$TMP/minimal.json" \
> --exclude-paths "root['meta']['updated']"
{}

Future test:
Run augur export _without_ any node-data JSONs when this can read divergence values from the newick file
and compare this to the tree using `div_node-data.json` - they should be identical.
See https://github.com/nextstrain/augur/issues/273 for more


Export with auspice config JSON which defines scale & legend settings
$ ${AUGUR} export v2 \
> --tree export_v2/tree.nwk \
> --node-data export_v2/div_node-data.json export_v2/location_node-data.json \
> --auspice-config export_v2/auspice_config1.json \
> --output "$TMP/dataset1.json" &>/dev/null

$ python3 "$TESTDIR/../../scripts/diff_jsons.py" export_v2/dataset1.json "$TMP/dataset1.json" \
> --exclude-paths "root['meta']['updated']"
{}
32 changes: 32 additions & 0 deletions tests/functional/export_v2/auspice_config1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"colorings": [
{
"key": "location",
"title": "Location",
"type": "categorical",
"legend": [
{"value": "alpha", "display": "α"},
{"value": "beta"}
],
"scale": [
["beta", "#bd0026"],
["gamma", "#6a51a3"]
]
},
{
"key": "mutation_length",
"title": "Mutations per branch",
"type": "continuous",
"legend": [
{"value": 1, "display": "0-2", "bounds": [-1,2]},
{"value": 3, "display": "3-5", "bounds": [2,5]},
{"value": 5, "display": ">5", "bounds": [5, 10]}
],
"scale": [
[1, "#081d58"],
[3, "#1d91c0"],
[5, "#c7e9b4"]
]
}
]
}
224 changes: 224 additions & 0 deletions tests/functional/export_v2/dataset1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
{
"meta": {
"colorings": [
{
"key": "location",
"legend": [
{
"display": "\u03b1",
"value": "alpha"
},
{
"value": "beta"
}
],
"scale": [
[
"beta",
"#bd0026"
],
[
"gamma",
"#6a51a3"
]
],
"title": "Location",
"type": "categorical"
},
{
"key": "mutation_length",
"legend": [
{
"bounds": [
-1,
2
],
"display": "0-2",
"value": 1
},
{
"bounds": [
2,
5
],
"display": "3-5",
"value": 3
},
{
"bounds": [
5,
10
],
"display": ">5",
"value": 5
}
],
"scale": [
[
1,
"#081d58"
],
[
3,
"#1d91c0"
],
[
5,
"#c7e9b4"
]
],
"title": "Mutations per branch",
"type": "continuous"
},
{
"key": "location",
"legend": [
{
"display": "\u03b1",
"value": "alpha"
},
{
"value": "beta"
}
],
"scale": [
[
"beta",
"#bd0026"
],
[
"gamma",
"#6a51a3"
]
],
"title": "Location",
"type": "categorical"
}
],
"filters": [
"location"
],
"panels": [
"tree"
],
"updated": "2021-06-09"
},
"tree": {
"branch_attrs": {},
"children": [
{
"branch_attrs": {},
"name": "tipA",
"node_attrs": {
"div": 1,
"location": {
"value": "delta"
},
"mutation_length": {
"value": 1
}
}
},
{
"branch_attrs": {},
"children": [
{
"branch_attrs": {},
"name": "tipB",
"node_attrs": {
"div": 3,
"location": {
"value": "gamma"
},
"mutation_length": {
"value": 1
}
}
},
{
"branch_attrs": {},
"name": "tipC",
"node_attrs": {
"div": 3,
"location": {
"value": "gamma"
},
"mutation_length": {
"value": 1
}
}
}
],
"name": "internalBC",
"node_attrs": {
"div": 2,
"mutation_length": {
"value": 2
}
}
},
{
"branch_attrs": {},
"children": [
{
"branch_attrs": {},
"name": "tipD",
"node_attrs": {
"div": 8,
"location": {
"value": "alpha"
},
"mutation_length": {
"value": 3
}
}
},
{
"branch_attrs": {},
"name": "tipE",
"node_attrs": {
"div": 9,
"location": {
"value": "alpha"
},
"mutation_length": {
"value": 4
}
}
},
{
"branch_attrs": {},
"name": "tipF",
"node_attrs": {
"div": 6,
"location": {
"value": "beta"
},
"mutation_length": {
"value": 1
}
}
}
],
"name": "internalDEF",
"node_attrs": {
"div": 5,
"location": {
"value": "alpha"
},
"mutation_length": {
"value": 5
}
}
}
],
"name": "ROOT",
"node_attrs": {
"div": 0,
"mutation_length": {
"value": 0
}
}
},
"version": "v2"
}
31 changes: 31 additions & 0 deletions tests/functional/export_v2/div_node-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"nodes": {
"ROOT": {
"mutation_length": 0
},
"tipA": {
"mutation_length": 1
},
"internalBC": {
"mutation_length": 2
},
"tipB": {
"mutation_length": 1
},
"tipC": {
"mutation_length": 1
},
"internalDEF": {
"mutation_length": 5
},
"tipD": {
"mutation_length": 3
},
"tipE": {
"mutation_length": 4
},
"tipF": {
"mutation_length": 1
}
}
}
25 changes: 25 additions & 0 deletions tests/functional/export_v2/location_node-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"nodes": {
"tipA": {
"location": "delta"
},
"tipB": {
"location": "gamma"
},
"tipC": {
"location": "gamma"
},
"internalDEF": {
"location": "alpha"
},
"tipD": {
"location": "alpha"
},
"tipE": {
"location": "alpha"
},
"tipF": {
"location": "beta"
}
}
}
Loading

0 comments on commit 73649be

Please sign in to comment.