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

[h5n1-cattle-outbreak] show timetree for genome build #98

Merged
merged 1 commit into from
Oct 29, 2024
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
24 changes: 23 additions & 1 deletion Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,28 @@ def additional_export_config(wildcards):

return args

rule auspice_config:
"""
Depending on the build we may make wildcard-dependent modifications to the auspice config JSON.
If we implement config overlays in augur this rule will become unnecessary.
"""
input:
auspice_config = files.auspice_config,
output:
auspice_config = "results/{subtype}/{segment}/{time}/auspice-config.json",
run:
import json
with open(input.auspice_config) as fh:
config = json.load(fh)
if wildcards.subtype == "h5n1-cattle-outbreak":
if wildcards.segment == "genome":
config['display_defaults']['distance_measure'] = "num_date"
else:
config['display_defaults']['distance_measure'] = "div"
with open(output.auspice_config, 'w') as fh:
json.dump(config, fh, indent=2)


rule export:
"""
Export the files into results/ and then use a subsequent rule to move these to the
Expand All @@ -529,7 +551,7 @@ rule export:
node_data = export_node_data_files,
colors = files.colors,
lat_longs = files.lat_longs,
auspice_config = files.auspice_config,
auspice_config = rules.auspice_config.output.auspice_config,
description = files.description
output:
auspice_json = "results/{subtype}/{segment}/{time}/auspice-dataset.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"map_triplicate": false,
"color_by": "host",
"geo_resolution": "division",
"distance_measure": "div"
"distance_measure": "__VALUE_OVERWRITTEN_BY_SNAKEMAKE_PIPELINE__"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not asking for a change, just thinking through how this value can affect UX

Interesting how this tightly couples the Auspice config with this version of the workflow. If the auspice_config rule is changed in a way that fails to edit this value, the export rule will run into a validation error, which is a great check for us. On the other hand, if someone tries to use this config in another workflow (or older version of this workflow), they will also run into a validation error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the export rule will run into a validation error

This was my thinking for this decision. I could have left it as "div" but wanted to avoid silent failures. Of the two downsides to this approach you point out,

if someone tries to use this config in another workflow

this is fair, although hopefully the text is a big enough hint to them that they have to add something on the snakemake side! They'll get validation errors if they forget

or older version of this workflow

given both the config and the snakemake pipeline are in version control I expect such usage to never happen, but 🤷

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or older version of this workflow

given both the config and the snakemake pipeline are in version control I expect such usage to never happen, but 🤷

Mostly thinking of people who copy/paste configs without being fully aware of these internal nuances 🤷‍♀️

But yeah, I think the validation error is clear enough in this case

Validating schema of 'results/h5n1-cattle-outbreak/ha/default/auspice-config.json'...
  .display_defaults.distance_measure "__VALUE_OVERWRITTEN_BY_SNAKEMAKE_PIPELINE__" failed enum validation for ["num_date", "div"]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking through things Jover!

},
"filters": [
"host",
Expand Down