diff --git a/changelog.md b/changelog.md index 6880b2f5..97f90af0 100644 --- a/changelog.md +++ b/changelog.md @@ -23,6 +23,7 @@ resolution - Added component `bandage`. - Added component `unicycler`. - Added component `prokka`. +- Added component `bcalm`. ### Minor/Other changes diff --git a/flowcraft/generator/components/assembly.py b/flowcraft/generator/components/assembly.py index 9f1d9fa7..9b685851 100644 --- a/flowcraft/generator/components/assembly.py +++ b/flowcraft/generator/components/assembly.py @@ -4,6 +4,48 @@ 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.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/bcalm", + "version": "2.2.0--hd28b015_2", + "scratch": "true" + }} + class Spades(Process): """Spades process template interface diff --git a/flowcraft/generator/engine.py b/flowcraft/generator/engine.py index ab35ab47..48f1cebc 100644 --- a/flowcraft/generator/engine.py +++ b/flowcraft/generator/engine.py @@ -58,6 +58,7 @@ "abyss": assembly.Abyss, "abricate": annotation.Abricate, "assembly_mapping": ap.AssemblyMapping, + "bcalm": assembly.Bcalm, "bandage": ap.Bandage, "bowtie": mapping.Bowtie, "card_rgi": annotation.CardRgi, diff --git a/flowcraft/generator/templates/bcalm.nf b/flowcraft/generator/templates/bcalm.nf new file mode 100644 index 00000000..700487a0 --- /dev/null +++ b/flowcraft/generator/templates/bcalm.nf @@ -0,0 +1,38 @@ +// 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 "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 "*.unitig.fa" + {% with task_name="bcalm" %} + {%- include "compiler_channels.txt" ignore missing -%} + {% endwith %} + + script: + """ + { + 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 + } + """ +} +