Skip to content

Commit

Permalink
Refine success checks for hafpipe rules
Browse files Browse the repository at this point in the history
  • Loading branch information
lczech committed Dec 16, 2024
1 parent a0ad0de commit 020d97c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
16 changes: 7 additions & 9 deletions workflow/rules/frequency.smk
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ rule hafpipe_snp_table:
# in order to better inform the user about the situation and how to fix this.
numeric=get_hafpipe_snp_table_dir() + "/{chrom}.csv.numeric",
numericbgz=get_hafpipe_snp_table_dir() + "/{chrom}.csv.numeric.bgz",
done=touch(get_hafpipe_snp_table_dir() + "/{chrom}.done"),
done=get_hafpipe_snp_table_dir() + "/{chrom}.done",
params:
tasks="1",
chrom="{chrom}",
Expand Down Expand Up @@ -247,9 +247,8 @@ if impmethod in ["simpute", "npute"]:
snptable=get_hafpipe_snp_table_dir() + "/{chrom}.csv",
bins=get_hafpipe_bins(),
output:
# Unnamed output, as this is implicit in HAFpipe Task 2
get_hafpipe_snp_table_dir() + "/{chrom}.csv." + impmethod,
touch(get_hafpipe_snp_table_dir() + "/{chrom}.csv." + impmethod + ".done"),
csv=get_hafpipe_snp_table_dir() + "/{chrom}.csv." + impmethod,
done=get_hafpipe_snp_table_dir() + "/{chrom}.csv." + impmethod + ".done",
params:
tasks="2",
impmethod=impmethod,
Expand Down Expand Up @@ -278,9 +277,8 @@ elif impmethod != "":
input:
snptable=get_hafpipe_snp_table_dir() + "/{chrom}.csv",
output:
# Unnamed output, as this is implicit in the user script
get_hafpipe_snp_table_dir() + "/{chrom}.csv." + impmethod,
touch(get_hafpipe_snp_table_dir() + "/{chrom}.csv." + impmethod + ".done"),
csv=get_hafpipe_snp_table_dir() + "/{chrom}.csv." + impmethod,
done=get_hafpipe_snp_table_dir() + "/{chrom}.csv." + impmethod + ".done",
# Same logic as above, let's accelarate the workflow.
priority: 5
log:
Expand Down Expand Up @@ -448,7 +446,7 @@ rule hafpipe_haplotype_frequencies:
if config["params"]["hafpipe"].get("keep-intermediates", True)
else temp("hafpipe/frequencies/{sample}.bam.{chrom}.freqs")
),
done=touch("hafpipe/frequencies/{sample}.bam.{chrom}.freqs.done"),
done="hafpipe/frequencies/{sample}.bam.{chrom}.freqs.done",
params:
tasks="3",
outdir="hafpipe/frequencies",
Expand Down Expand Up @@ -476,7 +474,7 @@ rule hafpipe_allele_frequencies:
if config["params"]["hafpipe"].get("keep-intermediates", True)
else temp("hafpipe/frequencies/{sample}.bam.{chrom}.afSite")
),
done=touch("hafpipe/frequencies/{sample}.bam.{chrom}.afSite.done"),
done="hafpipe/frequencies/{sample}.bam.{chrom}.afSite.done",
params:
tasks="4",
outdir="hafpipe/frequencies",
Expand Down
5 changes: 5 additions & 0 deletions workflow/scripts/hafpipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,8 @@
# "big if your founder VCF has many samples. Please check all log files for errors, "
# "and try to increase the amount of memory for our grenepipe rule `hafpipe_snp_table`."
# )

# Finally, if the snakemake rule expects a "done" marker file, we produce this,
# at the very end, so that it only is made when everything above succeeded.
if snakemake.output.get("done", ""):
shell("touch {snakemake.output.done:q}")

0 comments on commit 020d97c

Please sign in to comment.