From 5f83ffa9629584eec33a34df87b1fb2aa2bf7b53 Mon Sep 17 00:00:00 2001 From: Ivan Blagoev Topolsky Date: Wed, 4 Dec 2024 15:13:21 +0100 Subject: [PATCH] [feature] lofreq parallel threads Co-authored-by: AugusteRi --- workflow/rules/snv.smk | 10 ++++++++-- workflow/schemas/config_schema.json | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/workflow/rules/snv.smk b/workflow/rules/snv.smk index 2c94be8f..c7701883 100644 --- a/workflow/rules/snv.smk +++ b/workflow/rules/snv.smk @@ -263,6 +263,11 @@ rule lofreq: EXTRA=config.lofreq["extra"], SAMTOOLS=config.applications["samtools"], LOFREQ=config.applications["lofreq"], + kind=lambda wildcards, threads: "parallel" if threads > 1 else "old-school", + subcmd=lambda wildcards, threads: "call-parallel" if threads > 1 else "call", + threadspar=lambda wildcards, threads: ( + f"--pp-threads {threads}" if threads > 1 else "" + ), log: outfile="{dataset}/variants/SNVs/lofreq.out.log", errfile="{dataset}/variants/SNVs/lofreq.err.log", @@ -274,6 +279,7 @@ rule lofreq: disk_mb=2000, mem_mb=config.lofreq["mem"], runtime=config.lofreq["time"], + threads: config.lofreq["threads"] shell: """ # Add qualities to indels @@ -282,8 +288,8 @@ rule lofreq: {params.SAMTOOLS} index {output.BAM} 2> >(tee {log.errfile} >&2) # Run Lofreq - echo "Running LoFreq" >> {log.outfile} - {params.LOFREQ} call {params.EXTRA} --call-indels -f {input.REF} -o {output.SNVs} --verbose {output.BAM} >> {log.outfile} 2> >(tee -a {log.errfile} >&2) + echo "Running {params.kind} LoFreq ({params.subcmd})" >> {log.outfile} + {params.LOFREQ} "{params.subcmd}" {params.EXTRA} --call-indels {params.threadspar} -f {input.REF} -o {output.SNVs} --verbose {output.BAM} >> {log.outfile} 2> >(tee -a {log.errfile} >&2) """ diff --git a/workflow/schemas/config_schema.json b/workflow/schemas/config_schema.json index b3482193..2fed877c 100644 --- a/workflow/schemas/config_schema.json +++ b/workflow/schemas/config_schema.json @@ -1274,6 +1274,10 @@ "type": "integer", "default": 2000 }, + "threads": { + "type": "integer", + "default": 4 + }, "time": { "type": "integer", "default": 60