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

feat: make it possible to set input as files or dirs to multiqc #488

Merged
merged 6 commits into from
May 16, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bio/multiqc/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: multiqc
description: |
Generate qc report using multiqc.
url: https://multiqc.info/
authors:
Smeds marked this conversation as resolved.
Show resolved Hide resolved
- Julian de Ruiter
input:
- input directory containing qc files
- input directory containing qc files, default behaviour is to extract folder path from the provided files or parent folder if a folder is provided.
params:
- use_input_files_only: if this variable is set to True input will be used as it is, i.e no folder will be extract from provided file names
output:
- qc report (html)
17 changes: 15 additions & 2 deletions bio/multiqc/test/Snakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
rule multiqc:
rule multiqc_dir:
input:
expand("samtools_stats/{sample}.txt", sample=["a", "b"])
output:
"qc/multiqc.html"
params:
"" # Optional: extra parameters for multiqc.
extra="" # Optional: extra parameters for multiqc.
log:
"logs/multiqc.log"
wrapper:
"master/bio/multiqc"

rule multiqc_file:
input:
expand("samtools_stats/{sample}.txt", sample=["a"])
output:
"qc/multiqc_a.html"
params:
extra="", # Optional: extra parameters for multiqc.
use_input_files_only=True, # Optional, use only a.txt and don't search folder samtools_stats for files
log:
"logs/multiqc.log"
wrapper:
Expand Down
15 changes: 12 additions & 3 deletions bio/multiqc/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,26 @@
from snakemake.shell import shell


input_dirs = set(path.dirname(fp) for fp in snakemake.input)
extra = snakemake.params.get("extra", "")
# Set this to False if multiqc should use the actual input directly
# instead of parsing the folders where the provided files are located
use_input_files_only = snakemake.params.get("use_input_files_only", False)

if not use_input_files_only:
input_data = set(path.dirname(fp) for fp in snakemake.input)
else:
input_data = set(snakemake.input)

output_dir = path.dirname(snakemake.output[0])
output_name = path.basename(snakemake.output[0])
log = snakemake.log_fmt_shell(stdout=True, stderr=True)

shell(
"multiqc"
" {snakemake.params}"
" {extra}"
" --force"
" -o {output_dir}"
" -n {output_name}"
" {input_dirs}"
" {input_data}"
" {log}"
)
6 changes: 6 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2052,6 +2052,12 @@ def test_multiqc():
["snakemake", "--cores", "1", "qc/multiqc.html", "--use-conda", "-F"],
)

@skip_if_not_modified
def test_multiqc_a():
run(
"bio/multiqc",
["snakemake", "--cores", "1", "qc/multiqc_a.html", "--use-conda", "-F"],
)

@skip_if_not_modified
def test_muscle_clw():
Expand Down