Skip to content

Commit

Permalink
impose wildcard constraint on nextclade_dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
Katherine Eaton authored and ktmeaton committed Apr 14, 2022
1 parent 30e1406 commit 1302720
Showing 1 changed file with 4 additions and 31 deletions.
35 changes: 4 additions & 31 deletions workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,15 @@ rule nextclade_dataset:
Download Nextclade dataset.
"""
message: "{wildcards.dataset} | Downloading Nextclade sars-cov-2 dataset."
wildcard_constraints:
# The tag will always begin with the year (ex. 2022)
tag="([0-9]){4}.*",
output:
dataset_dir = directory("data/{dataset}_{tag}"),
benchmark:
"benchmarks/{rule}/{{dataset}}_{{tag}}_{today}.tsv".format(today=today, rule=rule_name),
log:
"logs/{rule}/{{dataset}}_{{tag}}_{today}.txt".format(today=today, rule=rule_name),
"logs/{rule}/{{dataset}}_{{tag}}_{today}.log".format(today=today, rule=rule_name),
shell:
"""
nextclade dataset get --name {wildcards.dataset} --tag {wildcards.tag} --output-dir {output.dataset_dir} > {log} 2>&1;
Expand Down Expand Up @@ -571,36 +574,6 @@ rule usher_subtree:
python3 scripts/usher_collapse.py --indir {output.subtrees_dir} --outdir {output.collapse_dir} >> {log} 2>&1;
"""

# -----------------------------------------------------------------------------
rule_name = "usher_plot"
rule usher_plot:
"""
Plot UShER subtrees.
"""
message: "{wildcards.build} | Plotting UShER subtrees."
input:
collapse_dir = rules.usher_subtree.output.collapse_dir,
samples = "results/{build}/sc2rf.recombinants.txt",
output:
plot_dir = report(
directory("results/{build}/subtrees_plot"),
patterns=["{name}.png"],
caption="report/usher.rst",
category="Stage 3: UShER",
labels={"build": "{build}", "description" : "{name} Image"},
),
benchmark:
"benchmarks/{rule}/{{build}}_{today}.tsv".format(today=today, rule=rule_name),
log:
"logs/{rule}/{{build}}_{today}.log".format(today=today, rule=rule_name),
shell:
"""
mkdir -p {output.plot_dir};
for subtree in $(ls {input.collapse_dir}/*.nwk); do
python3 scripts/usher_plot.py --tree $subtree --strains {input.samples} --outdir {output.plot_dir};
done > {log} 2>&1;
"""

# -----------------------------------------------------------------------------#
# STAGE 4: Summary
# -----------------------------------------------------------------------------#
Expand Down

0 comments on commit 1302720

Please sign in to comment.