Skip to content

Commit

Permalink
Use wildcards conditionals to further combine rules
Browse files Browse the repository at this point in the history
Use wildcard conditionals to further combine rules that take a different
set of input files for the genome and E gene builds.

Case 1: The E gene build excludes the "augur clades" command, resulting in the
absence of a clades_{serotype}_E.json file in the E gene export rule.

Case 2: The reference Genbank files for E genes are dynamically generated
in the results folder.
  • Loading branch information
j23414 committed May 2, 2024
1 parent 4cf6b1c commit 2f48ddb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 103 deletions.
2 changes: 0 additions & 2 deletions phylogenetic/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ include: "rules/prepare_sequences.smk"
include: "rules/prepare_sequences_E.smk"
include: "rules/construct_phylogeny.smk"
include: "rules/annotate_phylogeny.smk"
include: "rules/annotate_phylogeny_E.smk"
include: "rules/export.smk"
include: "rules/export_E.smk"

# Include custom rules defined in the config.
if "custom_rules" in config:
Expand Down
9 changes: 5 additions & 4 deletions phylogenetic/rules/annotate_phylogeny.smk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ rule ancestral:
rule translate:
"""Translating amino acid sequences"""
input:
tree = "results/tree_{serotype}_genome.nwk",
node_data = "results/nt-muts_{serotype}_genome.json",
reference = "config/reference_dengue_{serotype}.gb"
tree = "results/tree_{serotype}_{gene}.nwk",
node_data = "results/nt-muts_{serotype}_{gene}.json",
# The genbank references for the E gene are dynamically generated files located within the results folder.
reference = lambda wildcard: "config/reference_dengue_{serotype}.gb" if wildcard.gene in ["genome"] else "results/config/reference_dengue_{serotype}_{gene}.gb"
output:
node_data = "results/aa-muts_{serotype}_genome.json"
node_data = "results/aa-muts_{serotype}_{gene}.json"
shell:
"""
augur translate \
Expand Down
41 changes: 0 additions & 41 deletions phylogenetic/rules/annotate_phylogeny_E.smk

This file was deleted.

18 changes: 9 additions & 9 deletions phylogenetic/rules/export.smk
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ rule colors:
rule prepare_auspice_config:
"""Prepare the auspice config file for each serotypes"""
output:
auspice_config="results/config/auspice_config_{serotype}.json",
auspice_config="results/config/auspice_config_{serotype}_{gene}.json",
params:
replace_clade_key="clade_membership",
replace_clade_title=lambda wildcard: r"Serotype" if wildcard.serotype in ['all'] else r"DENV genotype",
Expand Down Expand Up @@ -109,17 +109,17 @@ rule prepare_auspice_config:
rule export:
"""Exporting data files for auspice"""
input:
tree = "results/tree_{serotype}_genome.nwk",
tree = "results/tree_{serotype}_{gene}.nwk",
metadata = "data/metadata_{serotype}.tsv",
branch_lengths = "results/branch-lengths_{serotype}_genome.json",
traits = "results/traits_{serotype}_genome.json",
clades = "results/clades_{serotype}_genome.json",
nt_muts = "results/nt-muts_{serotype}_genome.json",
aa_muts = "results/aa-muts_{serotype}_genome.json",
auspice_config = "results/config/auspice_config_{serotype}.json",
branch_lengths = "results/branch-lengths_{serotype}_{gene}.json",
traits = "results/traits_{serotype}_{gene}.json",
clades = lambda wildcard: "results/clades_{serotype}_{gene}.json" if wildcard.gene in ['genome'] else [],
nt_muts = "results/nt-muts_{serotype}_{gene}.json",
aa_muts = "results/aa-muts_{serotype}_{gene}.json",
auspice_config = "results/config/auspice_config_{serotype}_{gene}.json",
colors = "results/colors_{serotype}.tsv",
output:
auspice_json = "results/raw_dengue_{serotype}_genome.json",
auspice_json = "results/raw_dengue_{serotype}_{gene}.json",
params:
strain_id = config.get("strain_id_field", "strain"),
shell:
Expand Down
47 changes: 0 additions & 47 deletions phylogenetic/rules/export_E.smk

This file was deleted.

0 comments on commit 2f48ddb

Please sign in to comment.