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

Fixes to augur export #1218

Merged
merged 3 commits into from
May 16, 2023
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
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

### Bug fixes

* export: No longer export duplicate entries in the colorings array, a bug which has been present in Augur since at least v12 [#719][]. [#1218][] (@jameshadfield)

* export: In version 22.0.0, some configurations of export may have resulted in the clade coloring appearing last in the Auspice dropdown rather than first. This is now fixed. [#1218] (@jameshadfield)

* export: In version 22.0.0, validation of `augur.utils.read_node_data` was changed to error when a node data JSON did not contain any actual data. This causes export to error when an empty node data JSON is passed, as for example in ncov's pathogen-ci. This is now fixed by warning instead. The bug was originally introduced in PR [#728][]. [#1214][] (@corneliusroemer)

[#719]: https://github.com/nextstrain/augur/issues/719
[#1214]: https://github.com/nextstrain/augur/pull/1214
[#1218]: https://github.com/nextstrain/augur/pull/1218

## 22.0.0 (9 May 2023)

Expand Down
17 changes: 10 additions & 7 deletions augur/export_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,14 @@ def _add_title_and_type(coloring):
return False # a warning message will have been printed before `InvalidOption` is raised
return coloring

def _create_coloring(key):
def _add_coloring(colorings, key):
# handle deprecations
if key == "authors":
deprecated("[colorings] The 'authors' key is now called 'author'")
key = "author"
return {"key": key}
# check if the key has already been added by another part of the color-creating logic
if key not in {x['key'] for x in colorings}:
colorings.append({"key": key})

def _is_valid(coloring):
key = coloring["key"]
Expand Down Expand Up @@ -389,18 +391,18 @@ def _get_colorings():
if command_line_colorings:
# start with auto_colorings (already validated to be included)
for x in auto_colorings:
colorings.append(_create_coloring(x))
_add_coloring(colorings, x)
# then add in command line colorings
for x in command_line_colorings:
colorings.append(_create_coloring(x))
_add_coloring(colorings, x)
else:
# if we have a config file, start with these (extra info, such as title&type, is added in later)
if config:
for x in config.keys():
colorings.append(_create_coloring(x))
_add_coloring(colorings, x)
# then add in any auto-colorings already validated to include
for x in auto_colorings:
colorings.append(_create_coloring(x))
_add_coloring(colorings, x)

explicitly_defined_colorings = [x["key"] for x in colorings]
# add in genotype as a special case if (a) not already set and (b) the data supports it
Expand Down Expand Up @@ -794,8 +796,9 @@ def node_data_prop_is_normal_trait(name):
"authors", # authors are set as a node property, not a trait property
"author", # see above
"vaccine", # vaccine info is stored as a "special" node prop
'clade_membership', # explicitly set as a coloring if present
'branch_length',
'num_date',
'num_date', # explicitly set as a coloring if present
'raw_date',
'numdate',
'clock_length',
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/export_v2/dataset-with-branch-labels.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
},
"colorings": [
{
"key": "gt",
"title": "Genotype",
"key": "clade_membership",
"title": "Clade",
"type": "categorical"
},
{
"key": "clade_membership",
"title": "Clade",
"key": "gt",
"title": "Genotype",
"type": "categorical"
}
],
Expand Down
24 changes: 0 additions & 24 deletions tests/functional/export_v2/dataset1.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,6 @@
],
"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": [
Expand Down
24 changes: 0 additions & 24 deletions tests/functional/export_v2/dataset2.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,6 @@
],
"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": [
Expand Down
24 changes: 0 additions & 24 deletions tests/functional/export_v2/dataset3.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,30 +82,6 @@
"#4042C7"
]
]
},
{
"key": "location",
"title": "Location",
"type": "categorical",
"scale": [
[
"beta",
"#bd0026"
],
[
"gamma",
"#6a51a3"
]
],
"legend": [
{
"value": "alpha",
"display": "\u03b1"
},
{
"value": "beta"
}
]
}
],
"filters": [
Expand Down