implement function for exported node data
@@ -508,32 +508,47 @@ def export_title(wildcards):
region_title = region.replace("-", " ").title()
return f"Genomic epidemiology of novel coronavirus - {region_title}-focused subsampling"
+def _get_node_data_by_wildcards(wildcards):
+ """Return a list of node data files to include for a given build's wildcards.
+ """
+ # Define inputs shared by all builds.
+ wildcards_dict = dict(wildcards)
+ inputs = [
+ rules.refine.output.node_data,
+ rules.ancestral.output.node_data,
+ rules.translate.output.node_data,
+ rules.clades.output.clade_data,
+ rules.recency.output.node_data
+ ]
+
+ if wildcards.region in config["traits"]:
+ inputs.append(rules.traits.output.node_data)
+
+ # Convert input files from wildcard strings to real file names.
+ inputs = [input_file.format(**wildcards_dict) for input_file in inputs]
+ return inputs
+
rule export:
message: "Exporting data files for for auspice"
input:
tree = rules.refine.output.tree,
metadata = _get_metadata_by_wildcards,
- branch_lengths = rules.refine.output.node_data,
- nt_muts = rules.ancestral.output.node_data,
- aa_muts = rules.translate.output.node_data,
- traits = rules.traits.output.node_data,
+ node_data = _get_node_data_by_wildcards,
auspice_config = config["files"]["auspice_config"],
colors = rules.colors.output.colors,
lat_longs = config["files"]["lat_longs"],
- description = config["files"]["description"],
- clades = rules.clades.output.clade_data,
- recency = rules.recency.output
+ description = config["files"]["description"]
output:
auspice_json = REGION_PATH + "ncov_with_accessions.json"
params:
title = export_title
- conda: config["conda_environment"]
+ conda: "../envs/nextstrain.yaml"
shell:
"""
augur export v2 \
--tree {input.tree} \
--metadata {input.metadata} \
- --node-data {input.branch_lengths} {input.nt_muts} {input.aa_muts} {input.traits} {input.clades} {input.recency} \
+ --node-data {input.node_data} \
--auspice-config {input.auspice_config} \
--colors {input.colors} \
--lat-longs {input.lat_longs} \
