From 1fcafb6a40713a2ecc5ace57783323f3b594ee9f Mon Sep 17 00:00:00 2001 From: skchronicles Date: Tue, 12 Mar 2024 11:01:43 -0400 Subject: [PATCH] Delete previous runs flye output directory if it exists. --- workflow/Snakefile | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/workflow/Snakefile b/workflow/Snakefile index c05b96e..aa75d98 100644 --- a/workflow/Snakefile +++ b/workflow/Snakefile @@ -279,22 +279,25 @@ rule flye_assembly: rname="flye_assembly", flye="flye/2.9.1", id="{samples}", - dir= join(workpath,"flye_assembly"), + outdir= join(workpath,"flye_assembly"), genome_size_flag= "--genome-size" if Genome_size != "" else "", asm_coverage_flag= "--asm-coverage" if Coverage != "" else "" threads: int(allocated("threads", "flye_assembly", cluster)), shell: """ module load {params.flye} - mkdir -p {params.rname} + if [ -d "{params.outdir}/{params.id}" ]; then + rm -rf "{params.outdir}/{params.id}"; + fi + mkdir -p "{params.outdir}/{params.id}" cd /lscratch/$SLURM_JOBID mkdir -p {params.rname}/{params.id} flye \\ --threads {threads} \\ --pacbio-hifi {input} {params.genome_size_flag} {Genome_size} \\ --out-dir {params.rname}/{params.id} {params.asm_coverage_flag} {Coverage} - mv /lscratch/$SLURM_JOBID/{params.rname}/{params.id} {params.dir} - cd {params.dir}/{params.id} + mv /lscratch/$SLURM_JOBID/{params.rname}/{params.id} {params.outdir} + cd {params.outdir}/{params.id} mv assembly.fasta {output} """ @@ -470,3 +473,7 @@ rule busco_summaries: -rt specific \\ --working_directory {params.dir} """ + + +# Import rules +include: join("rules", "hooks.smk") \ No newline at end of file