Skip to content

Commit

Permalink
feat: make it possible to set input as files or dirs to multiqc (#488)
Browse files Browse the repository at this point in the history
* feat: make it possible to set input as files or dirs to multiqc

make it possible to use the actual input from the rule as input to multiqc, instead of converting it to dirs that are then searched.

* Update bio/multiqc/test/Snakefile

Co-authored-by: Filipe G. Vieira <fgarrettvieira@gmail.com>

* feat: change params variable name

* Update Snakefile

* doc: update documentation

* Update bio/multiqc/meta.yaml

Co-authored-by: Filipe G. Vieira <fgarrettvieira@gmail.com>

Co-authored-by: Filipe G. Vieira <fgarrettvieira@gmail.com>
  • Loading branch information
Smeds and fgvieira committed May 16, 2022
1 parent c05006d commit 32fd0e0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
5 changes: 4 additions & 1 deletion bio/multiqc/meta.yaml
@@ -1,9 +1,12 @@
name: multiqc
description: |
Generate qc report using multiqc.
url: https://multiqc.info/
authors:
- 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
@@ -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
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
Expand Up @@ -2132,6 +2132,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

0 comments on commit 32fd0e0

Please sign in to comment.