Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: auto memory calculation #1210

Merged
merged 2 commits into from May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions bio/fastqc/environment.yaml
Expand Up @@ -4,3 +4,4 @@ channels:
- nodefaults
dependencies:
- fastqc =0.12.1
- snakemake-wrapper-utils =0.5.3
1 change: 1 addition & 0 deletions 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:
Expand Down
5 changes: 4 additions & 1 deletion bio/fastqc/test/Snakefile
Expand Up @@ -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"
13 changes: 10 additions & 3 deletions bio/fastqc/wrapper.py
Expand Up @@ -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 = int(get_mem(snakemake, "MiB") / snakemake.threads)


def basename_without_ext(file_path):
Expand All @@ -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}"
)

Expand Down