diff --git a/workflow/rules/frequency.smk b/workflow/rules/frequency.smk index cca9738..24fee74 100644 --- a/workflow/rules/frequency.smk +++ b/workflow/rules/frequency.smk @@ -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}", @@ -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, @@ -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: @@ -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", @@ -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", diff --git a/workflow/scripts/hafpipe.py b/workflow/scripts/hafpipe.py index bd3914b..52ee05c 100644 --- a/workflow/scripts/hafpipe.py +++ b/workflow/scripts/hafpipe.py @@ -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}")