Skip to content

Commit c4ff0fc

Browse files
committed
Restore clades to top entry in colorings
The intention of the coloring logic is that if an auspice-config provides the clade_membership key then it is exported at that position in the colorings list. If clade_membership is not explicitly set in the config (but is present in a node-data file) then we have (for a very long time) added it as the very first entry in the colorings list. PR #728 (augur v22.0.0) erroneously modified the behavior of the second case described above, which has now been restored by this commit.
1 parent 5daf6e8 commit c4ff0fc

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

augur/export_v2.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,8 @@ def _add_coloring(colorings, key):
361361
deprecated("[colorings] The 'authors' key is now called 'author'")
362362
key = "author"
363363
# check if the key has already been added by another part of the color-creating logic
364-
if key in {x['key'] for x in colorings}:
365-
return False
366-
colorings.append({"key": key})
367-
return True
364+
if key not in {x['key'] for x in colorings}:
365+
colorings.append({"key": key})
368366

369367
def _is_valid(coloring):
370368
key = coloring["key"]
@@ -798,8 +796,9 @@ def node_data_prop_is_normal_trait(name):
798796
"authors", # authors are set as a node property, not a trait property
799797
"author", # see above
800798
"vaccine", # vaccine info is stored as a "special" node prop
799+
'clade_membership', # explicitly set as a coloring if present
801800
'branch_length',
802-
'num_date',
801+
'num_date', # explicitly set as a coloring if present
803802
'raw_date',
804803
'numdate',
805804
'clock_length',

tests/functional/export_v2/dataset-with-branch-labels.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
},
2626
"colorings": [
2727
{
28-
"key": "gt",
29-
"title": "Genotype",
28+
"key": "clade_membership",
29+
"title": "Clade",
3030
"type": "categorical"
3131
},
3232
{
33-
"key": "clade_membership",
34-
"title": "Clade",
33+
"key": "gt",
34+
"title": "Genotype",
3535
"type": "categorical"
3636
}
3737
],

0 commit comments

Comments
 (0)