From ce370d92433b266c415abea14d96a64f9fdf9961 Mon Sep 17 00:00:00 2001 From: fgvieira <1151762+fgvieira@users.noreply.github.com> Date: Thu, 6 Apr 2023 13:37:06 +0200 Subject: [PATCH 1/2] Better memory calculation --- bio/fastqc/environment.yaml | 1 + bio/fastqc/meta.yaml | 1 + bio/fastqc/test/Snakefile | 5 ++++- bio/fastqc/wrapper.py | 13 ++++++++++--- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bio/fastqc/environment.yaml b/bio/fastqc/environment.yaml index 2dec8c9eba..66fe60ce4b 100644 --- a/bio/fastqc/environment.yaml +++ b/bio/fastqc/environment.yaml @@ -4,3 +4,4 @@ channels: - nodefaults dependencies: - fastqc =0.12.1 + - snakemake-wrapper-utils =0.5.3 diff --git a/bio/fastqc/meta.yaml b/bio/fastqc/meta.yaml index 5da8b49224..b414fe9223 100644 --- a/bio/fastqc/meta.yaml +++ b/bio/fastqc/meta.yaml @@ -1,6 +1,7 @@ name: fastqc description: | Generate fastq qc statistics using fastqc. +url: https://github.com/s-andrews/FastQC authors: - Julian de Ruiter input: diff --git a/bio/fastqc/test/Snakefile b/bio/fastqc/test/Snakefile index 1973b2e55f..6ee68f3ee9 100644 --- a/bio/fastqc/test/Snakefile +++ b/bio/fastqc/test/Snakefile @@ -4,9 +4,12 @@ rule fastqc: output: html="qc/fastqc/{sample}.html", zip="qc/fastqc/{sample}_fastqc.zip" # the suffix _fastqc.zip is necessary for multiqc to find the file. If not using multiqc, you are free to choose an arbitrary filename - params: "--quiet" + params: + extra = "--quiet" log: "logs/fastqc/{sample}.log" threads: 1 + resources: + mem_mb = 1024 wrapper: "master/bio/fastqc" diff --git a/bio/fastqc/wrapper.py b/bio/fastqc/wrapper.py index 30c9968590..c3db8e9230 100644 --- a/bio/fastqc/wrapper.py +++ b/bio/fastqc/wrapper.py @@ -9,10 +9,13 @@ from os import path import re from tempfile import TemporaryDirectory - from snakemake.shell import shell +from snakemake_wrapper_utils.snakemake import get_mem +extra = snakemake.params.get("extra", "") log = snakemake.log_fmt_shell(stdout=True, stderr=True) +# Define memory per thread (https://github.com/s-andrews/FastQC/blob/master/fastqc#L201-L222) +mem_mb = get_mem(snakemake, "MiB") / snakemake.threads def basename_without_ext(file_path): @@ -35,8 +38,12 @@ def basename_without_ext(file_path): # use the same fastqc dir, we create a temp dir. with TemporaryDirectory() as tempdir: shell( - "fastqc {snakemake.params} -t {snakemake.threads} " - "--outdir {tempdir:q} {snakemake.input[0]:q}" + "fastqc" + " --threads {snakemake.threads}" + " --memory {mem_mb}" + " {extra}" + "--outdir {tempdir:q}" + " {snakemake.input[0]:q}" " {log}" ) From 169d6693dd846162f0422232d29bfa1fa935f225 Mon Sep 17 00:00:00 2001 From: fgvieira <1151762+fgvieira@users.noreply.github.com> Date: Thu, 6 Apr 2023 13:42:41 +0200 Subject: [PATCH 2/2] Fix typo --- bio/fastqc/wrapper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bio/fastqc/wrapper.py b/bio/fastqc/wrapper.py index c3db8e9230..7c9e759977 100644 --- a/bio/fastqc/wrapper.py +++ b/bio/fastqc/wrapper.py @@ -15,7 +15,7 @@ extra = snakemake.params.get("extra", "") log = snakemake.log_fmt_shell(stdout=True, stderr=True) # Define memory per thread (https://github.com/s-andrews/FastQC/blob/master/fastqc#L201-L222) -mem_mb = get_mem(snakemake, "MiB") / snakemake.threads +mem_mb = int(get_mem(snakemake, "MiB") / snakemake.threads) def basename_without_ext(file_path): @@ -42,7 +42,7 @@ def basename_without_ext(file_path): " --threads {snakemake.threads}" " --memory {mem_mb}" " {extra}" - "--outdir {tempdir:q}" + " --outdir {tempdir:q}" " {snakemake.input[0]:q}" " {log}" )