From 7a9877745c47d69c3f938a56ec97384cf4deab0f Mon Sep 17 00:00:00 2001 From: Marijon Pierre Date: Sat, 13 Oct 2018 23:55:29 +0200 Subject: [PATCH 1/7] Add bcalm flowcraft --- flowcraft/generator/components/assembly.py | 44 ++++++++++++++++++++++ flowcraft/generator/engine.py | 1 + flowcraft/generator/templates/bcalm.nf | 30 +++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 flowcraft/generator/templates/bcalm.nf diff --git a/flowcraft/generator/components/assembly.py b/flowcraft/generator/components/assembly.py index d6d8f8d4..1073a83e 100644 --- a/flowcraft/generator/components/assembly.py +++ b/flowcraft/generator/components/assembly.py @@ -4,6 +4,50 @@ except ImportError: from flowcraft.generator.process import Process +class Bcalm(Process): + """Bcalm process template interface + + This process is set with: + + - ``input_type``: fastq + - ``output_type``: assembly + - ``ptype``: assembly + + """ + + def __init__(self, **kwargs): + + super().__init__(**kwargs) + + self.input_type = "fastq" + self.output_type = "fasta" + + self.dependencies = ["integrity_coverage"] + + self.params = { + "bcalmKmerSize": { + "default": 31, + "description": + "size of a kmer" + }, + "clearInput": { + "default": "false", + "description": + "Permanently removes temporary input files. This option " + "is only useful to remove temporary files in large " + "workflows and prevents nextflow's resume functionality. " + "Use with caution." + } + } + + self.directives = {"bcalm": { + "cpus": 4, + "memory": "{ 5.GB * task.attempt }", + "container": "quay.io/biocontainers/quast", + "version": "2.2.0", + "scratch": "true" + }} + class Spades(Process): """Spades process template interface diff --git a/flowcraft/generator/engine.py b/flowcraft/generator/engine.py index f4083f3d..4115dc90 100644 --- a/flowcraft/generator/engine.py +++ b/flowcraft/generator/engine.py @@ -97,6 +97,7 @@ "seq_typing": typing.SeqTyping, "sistr": typing.Sistr, "skesa": assembly.Skesa, + "bcalm": assembly.Bcalm, "spades": assembly.Spades, "split_assembly": meta.SplitAssembly, "trimmomatic": readsqc.Trimmomatic, diff --git a/flowcraft/generator/templates/bcalm.nf b/flowcraft/generator/templates/bcalm.nf new file mode 100644 index 00000000..7862f89c --- /dev/null +++ b/flowcraft/generator/templates/bcalm.nf @@ -0,0 +1,30 @@ +# Check parameter +if ( !params.bcalmKmerSize{{ param_id }}.toString().isNumber() ){ + exit 1, "'bcalmKmerSize{{ param_id }}' parameter must be a number. Provided value: '${params.bcalmKmes%rSize{{ param_id }}}'" +} + +# Clear +clear = params.clearInput{{ param_id }} ? "true" : "false" +checkpointClear_{{ pid }} = Channel.value(clear) + +process bcalm_{{ pid }} { + {% include "post.txt" ignore missing %} + + tag { sample_id } + publishDir "results/assembly/bcalm_{{pid}}/$sample_id", pattern: "*.unitig.fa" + publishDir "reports/assembly/quast_{{pid}}/$sample_id" + + input: + set sample_id, file(fastq) from {{input_channel}} + val KmerSize from Channel.value(params.bcalmKmerSize{{param_id}}) + +output: + file "*" + {% with task_name="bcalm" %} + {%- include "compiler_channels.txt" ignore missing -%} + {% endwith %} + + script: + "bcalm -in $fastq -out unitig -kmer-size $KmerSize" +} + From 86f7e60134cda4a24c1b35c5ad54877b8e3006a4 Mon Sep 17 00:00:00 2001 From: Marijon Pierre Date: Sun, 14 Oct 2018 22:02:15 +0200 Subject: [PATCH 2/7] bcalm: correct some mistake --- flowcraft/generator/engine.py | 2 +- flowcraft/generator/templates/bcalm.nf | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/flowcraft/generator/engine.py b/flowcraft/generator/engine.py index 4115dc90..c6071933 100644 --- a/flowcraft/generator/engine.py +++ b/flowcraft/generator/engine.py @@ -57,6 +57,7 @@ process_map = { "abricate": annotation.Abricate, "assembly_mapping": ap.AssemblyMapping, + "bcalm": assembly.Bcalm, "bowtie": mapping.Bowtie, "card_rgi": annotation.CardRgi, "check_coverage": readsqc.CheckCoverage, @@ -97,7 +98,6 @@ "seq_typing": typing.SeqTyping, "sistr": typing.Sistr, "skesa": assembly.Skesa, - "bcalm": assembly.Bcalm, "spades": assembly.Spades, "split_assembly": meta.SplitAssembly, "trimmomatic": readsqc.Trimmomatic, diff --git a/flowcraft/generator/templates/bcalm.nf b/flowcraft/generator/templates/bcalm.nf index 7862f89c..c9a1bd7e 100644 --- a/flowcraft/generator/templates/bcalm.nf +++ b/flowcraft/generator/templates/bcalm.nf @@ -1,9 +1,9 @@ -# Check parameter +// Check parameter if ( !params.bcalmKmerSize{{ param_id }}.toString().isNumber() ){ exit 1, "'bcalmKmerSize{{ param_id }}' parameter must be a number. Provided value: '${params.bcalmKmes%rSize{{ param_id }}}'" } -# Clear +// Clear clear = params.clearInput{{ param_id }} ? "true" : "false" checkpointClear_{{ pid }} = Channel.value(clear) @@ -11,15 +11,13 @@ process bcalm_{{ pid }} { {% include "post.txt" ignore missing %} tag { sample_id } - publishDir "results/assembly/bcalm_{{pid}}/$sample_id", pattern: "*.unitig.fa" - publishDir "reports/assembly/quast_{{pid}}/$sample_id" input: set sample_id, file(fastq) from {{input_channel}} val KmerSize from Channel.value(params.bcalmKmerSize{{param_id}}) output: - file "*" + file "*.unitig.fa" {% with task_name="bcalm" %} {%- include "compiler_channels.txt" ignore missing -%} {% endwith %} From f6724a5cea6f36c10c4f151f37f2c56f364ae191 Mon Sep 17 00:00:00 2001 From: Marijon Pierre Date: Sun, 14 Oct 2018 22:05:14 +0200 Subject: [PATCH 3/7] Add bcalm in changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 5d136beb..db37ab97 100644 --- a/changelog.md +++ b/changelog.md @@ -17,6 +17,7 @@ which is particularly useful in very large workflows. ### New components - Added component `fast_ani`. +- Added component `bcalm`. ### Minor/Other changes From 2e4046622803503549553ecdb706e865a8131e46 Mon Sep 17 00:00:00 2001 From: Marijon Pierre Date: Sun, 14 Oct 2018 22:09:05 +0200 Subject: [PATCH 4/7] Typo correction --- flowcraft/generator/templates/bcalm.nf | 1 + 1 file changed, 1 insertion(+) diff --git a/flowcraft/generator/templates/bcalm.nf b/flowcraft/generator/templates/bcalm.nf index c9a1bd7e..be7e5885 100644 --- a/flowcraft/generator/templates/bcalm.nf +++ b/flowcraft/generator/templates/bcalm.nf @@ -11,6 +11,7 @@ process bcalm_{{ pid }} { {% include "post.txt" ignore missing %} tag { sample_id } + publishDir "reports/assembly/quast_{{pid}}/$sample_id" input: set sample_id, file(fastq) from {{input_channel}} From 90a99e9e1bcace6c177160c9cfd8586a84f4ab61 Mon Sep 17 00:00:00 2001 From: Marijon Pierre Date: Fri, 26 Oct 2018 15:41:19 +0200 Subject: [PATCH 5/7] Solve @ODiogoSilva comments --- flowcraft/generator/templates/bcalm.nf | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/flowcraft/generator/templates/bcalm.nf b/flowcraft/generator/templates/bcalm.nf index be7e5885..700487a0 100644 --- a/flowcraft/generator/templates/bcalm.nf +++ b/flowcraft/generator/templates/bcalm.nf @@ -24,6 +24,15 @@ output: {% endwith %} script: - "bcalm -in $fastq -out unitig -kmer-size $KmerSize" + """ + { + bcalm -in $fastq -out unitig -kmer-size $KmerSize" + + if [ "$clear" = "true" ]; + then + find . -type f -print | egrep "work/.*(h5)|(glue)" | xargs -L 1 rm + fi + } + """ } From 21aa26e5f50707542dc97c55adb52e89f316377e Mon Sep 17 00:00:00 2001 From: Marijon Pierre Date: Fri, 26 Oct 2018 15:42:31 +0200 Subject: [PATCH 6/7] Solve @tiagofilipe12 comments --- changelog.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index db37ab97..582ae4ec 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,8 @@ ## Changes in upcoming release (`dev` branch) +- Added component `bcalm`. + ## 1.3.1 ### Features @@ -17,7 +19,6 @@ which is particularly useful in very large workflows. ### New components - Added component `fast_ani`. -- Added component `bcalm`. ### Minor/Other changes From 9bf6786aedf1734401da40d4c9fd651f39f60adb Mon Sep 17 00:00:00 2001 From: Marijon Pierre Date: Fri, 26 Oct 2018 15:42:53 +0200 Subject: [PATCH 7/7] Add good docker image with good version number --- flowcraft/generator/components/assembly.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/flowcraft/generator/components/assembly.py b/flowcraft/generator/components/assembly.py index 1073a83e..e2a12474 100644 --- a/flowcraft/generator/components/assembly.py +++ b/flowcraft/generator/components/assembly.py @@ -22,8 +22,6 @@ def __init__(self, **kwargs): self.input_type = "fastq" self.output_type = "fasta" - self.dependencies = ["integrity_coverage"] - self.params = { "bcalmKmerSize": { "default": 31, @@ -43,8 +41,8 @@ def __init__(self, **kwargs): self.directives = {"bcalm": { "cpus": 4, "memory": "{ 5.GB * task.attempt }", - "container": "quay.io/biocontainers/quast", - "version": "2.2.0", + "container": "quay.io/biocontainers/bcalm", + "version": "2.2.0--hd28b015_2", "scratch": "true" }}