From bc228c62012ff1c67f9974798c39884ebf004b0c Mon Sep 17 00:00:00 2001 From: kehillio <kenzo-hugo.hillion1@pasteur.fr> Date: Thu, 16 May 2019 15:31:04 +0200 Subject: [PATCH] add possibility to add modules dependencies --- README.md | 4 ++-- tools/metaphlan2/metaphlan2/Snakefile | 14 +++++++++----- tools/metaphlan2/metaphlan2_heatmap/Snakefile | 12 ++++++++---- tools/metaphlan2/metaphlan2_merge/Snakefile | 12 ++++++++---- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1591228..08f36d1 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Snakemake tools and workflows -This repository aims to gather all Snakemake descriptions. They all try to follow some rules in order to make them easily reusable from one workflow to another. +This repository aims to gather Snakemake descriptions. They all try to follow some rules in order to make them easily reusable from one workflow to another. Thus, the repository is splitted in two sections: * [__tools__](tools/): All tool descriptions. These are not meant to be used directly and need to be refered in another Snakefile -* [__subworkflows__](subworkflows/): Supposed to behave as tool descriptions, meaning that they need to be refered in another Snakefile to be used. +* [__subworkflows__](subworkflows/): Supposed to behave as tool descriptions, meaning that they need to be refered in another Snakefile to be used * [__workflows__](workflows/): All workflows that are supposed to be usable directly \ No newline at end of file diff --git a/tools/metaphlan2/metaphlan2/Snakefile b/tools/metaphlan2/metaphlan2/Snakefile index f4fdec2..0bee33c 100644 --- a/tools/metaphlan2/metaphlan2/Snakefile +++ b/tools/metaphlan2/metaphlan2/Snakefile @@ -1,6 +1,7 @@ -__metaphlan2_exec_command = config['metaphlan2'].get('exec_command', 'metaphlan2.py') -__metaphlan2_options = config['metaphlan2'].get('options', "") -__metaphlan2_threads = config['metaphlan2'].get('threads', 1) +__metaphlan2_exec_command = config.get('metaphlan2', {}).get('exec_command', 'metaphlan2.py') +__metaphlan2_modules = config.get('metaphlan2', {}).get('modules') +__metaphlan2_options = config.get('metaphlan2', {}).get('options', "") +__metaphlan2_threads = config.get('metaphlan2', {}).get('threads', 1) rule metaphlan2: input: @@ -9,9 +10,12 @@ rule metaphlan2: __metaphlan2_output params: exec_command = __metaphlan2_exec_command, + modules = __metaphlan2_modules, input_type = __metaphlan2_input_type, options = __metaphlan2_options threads: __metaphlan2_threads - shell: - "{params.exec_command} --nproc {threads} --input_type {params.input_type} {params.options} {input} {output}" + run: + if params.modules: + shell("module load {params.modules}") + shell("{params.exec_command} --nproc {threads} --input_type {params.input_type} {params.options} {input} {output}") diff --git a/tools/metaphlan2/metaphlan2_heatmap/Snakefile b/tools/metaphlan2/metaphlan2_heatmap/Snakefile index f97bb4b..147e0cd 100644 --- a/tools/metaphlan2/metaphlan2_heatmap/Snakefile +++ b/tools/metaphlan2/metaphlan2_heatmap/Snakefile @@ -1,5 +1,6 @@ -__metaphlan2_heatmap_exec_command = config['metaphlan2_heatmap'].get('exec_command', "metaphlan_hclust_heatmap.py") -__metaphlan2_heatmap_options = config['metaphlan2_heatmap'].get('options', "") +__metaphlan2_heatmap_exec_command = config.get('metaphlan2_heatmap', {}).get('exec_command', "metaphlan_hclust_heatmap.py") +__metaphlan2_heatmap_modules = config.get('metaphlan2_heatmap', {}).get('modules') +__metaphlan2_heatmap_options = config.get('metaphlan2_heatmap', {}).get('options', "") rule heatmap: input: @@ -8,6 +9,9 @@ rule heatmap: __metaphlan2_heatmap_output params: exec_command = __metaphlan2_heatmap_exec_command, + modules = __metaphlan2_heatmap_modules, options = __metaphlan2_heatmap_options - shell: - "{params.exec_command} {params.options} --in {input} --out {output}" + run: + if params.modules: + shell("module load {params.modules}") + shell("{params.exec_command} {params.options} --in {input} --out {output}") diff --git a/tools/metaphlan2/metaphlan2_merge/Snakefile b/tools/metaphlan2/metaphlan2_merge/Snakefile index 4d50031..d986768 100644 --- a/tools/metaphlan2/metaphlan2_merge/Snakefile +++ b/tools/metaphlan2/metaphlan2_merge/Snakefile @@ -1,5 +1,6 @@ -__metaphlan2_merge_exec_command = config['metaphlan2_merge'].get('exec_command', 'merge_metaphlan_tables.py') -__metaphlan2_merge_options = config['metaphlan2_merge'].get('options', "") +__metaphlan2_merge_exec_command = config.get('metaphlan2_merge', {}).get('exec_command', 'merge_metaphlan_tables.py') +__metaphlan2_merge_modules = config.get('metaphlan2_merge', {}).get('modules') +__metaphlan2_merge_options = config.get('metaphlan2_merge', {}).get('options', "") rule metaphlan2_merge: input: @@ -8,6 +9,9 @@ rule metaphlan2_merge: __metaphlan2_merge_output params: exec_command = __metaphlan2_merge_exec_command, + modules = __metaphlan2_merge_modules, options = __metaphlan2_merge_options - shell: - "{params.exec_command} {params.options} {input} > {output}" + run: + if params.modules: + shell("module load {params.modules}") + shell("{params.exec_command} {params.options} {input} > {output}") -- GitLab