From 70538021b9b92958afa73c697d0d5decea7aa9ca Mon Sep 17 00:00:00 2001 From: MazzaLab Date: Tue, 7 Jan 2025 19:54:45 +0100 Subject: [PATCH] Added BBMAP/REPAIR submodule (#7249) * New submodule: BBMAP/REPAIR * BBMAP/repair snapshot added * removed cpu setting in nextflow.config --------- Co-authored-by: irongraft --- modules/nf-core/bbmap/repair/environment.yml | 7 + modules/nf-core/bbmap/repair/main.nf | 57 +++++++ modules/nf-core/bbmap/repair/meta.yml | 67 ++++++++ .../nf-core/bbmap/repair/tests/main.nf.test | 115 +++++++++++++ .../bbmap/repair/tests/main.nf.test.snap | 156 ++++++++++++++++++ .../bbmap/repair/tests/nextflow.config | 5 + modules/nf-core/bbmap/repair/tests/tags.yml | 2 + 7 files changed, 409 insertions(+) create mode 100644 modules/nf-core/bbmap/repair/environment.yml create mode 100644 modules/nf-core/bbmap/repair/main.nf create mode 100644 modules/nf-core/bbmap/repair/meta.yml create mode 100644 modules/nf-core/bbmap/repair/tests/main.nf.test create mode 100644 modules/nf-core/bbmap/repair/tests/main.nf.test.snap create mode 100644 modules/nf-core/bbmap/repair/tests/nextflow.config create mode 100644 modules/nf-core/bbmap/repair/tests/tags.yml diff --git a/modules/nf-core/bbmap/repair/environment.yml b/modules/nf-core/bbmap/repair/environment.yml new file mode 100644 index 00000000000..4e65bfe6a99 --- /dev/null +++ b/modules/nf-core/bbmap/repair/environment.yml @@ -0,0 +1,7 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +channels: + - conda-forge + - bioconda +dependencies: + - "bioconda::bbmap=39.13" diff --git a/modules/nf-core/bbmap/repair/main.nf b/modules/nf-core/bbmap/repair/main.nf new file mode 100644 index 00000000000..9c12be2cf53 --- /dev/null +++ b/modules/nf-core/bbmap/repair/main.nf @@ -0,0 +1,57 @@ +process BBMAP_REPAIR { + tag "$meta.id" + label 'process_single' + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/bbmap:39.13--he5f24ec_1': + 'biocontainers/bbmap:39.13--he5f24ec_1' }" + + input: + tuple val(meta), path(reads) + val(interleave) + + output: + tuple val(meta), path("*_repaired.fastq.gz") , emit: repaired + tuple val(meta), path("${prefix}_singleton.fastq.gz"), emit: singleton + path "versions.yml" , emit: versions + path "*.log" , emit: log + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + prefix = task.ext.prefix ?: "${meta.id}" + in_reads = ( interleave ) ? "in=${reads[0]}" : "in=${reads[0]} in2=${reads[1]}" + out_reads = ( interleave ) ? "out=${prefix}_repaired.fastq.gz outs=${prefix}_singleton.fastq.gz" + : "out=${prefix}_1_repaired.fastq.gz out2=${prefix}_2_repaired.fastq.gz outs=${prefix}_singleton.fastq.gz" + """ + maxmem=\$(echo \"$task.memory\"| sed 's/ GB/g/g') + repair.sh \\ + -Xmx\$maxmem \\ + $in_reads \\ + $out_reads \\ + threads=${task.cpus} + ${args} \\ + &> ${prefix}.repair.sh.log + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + repair.sh: \$(repair.sh --version |& sed '2!d ; s/BBMap version //') + END_VERSIONS + """ + + stub: + prefix = task.ext.prefix ?: "${meta.id}" + """ + echo "" | gzip > ${prefix}_1_repaired.fastq.gz + echo "" | gzip > ${prefix}_2_repaired.fastq.gz + echo "" | gzip > ${prefix}_singleton.fastq.gz + touch ${prefix}.repair.sh.log + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + repair.sh: \$(repair.sh --version |& sed '2!d ; s/BBMap version //') + END_VERSIONS + """ +} diff --git a/modules/nf-core/bbmap/repair/meta.yml b/modules/nf-core/bbmap/repair/meta.yml new file mode 100644 index 00000000000..9190cd99c5e --- /dev/null +++ b/modules/nf-core/bbmap/repair/meta.yml @@ -0,0 +1,67 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "bbmap_repair" +description: Re-pairs reads that became disordered or had some mates eliminated. +keywords: + - paired reads re-pairing + - fastq + - preprocessing +tools: + - repair: + description: Repair.sh is a tool that re-pairs reads that became disordered or had some mates eliminated + tools. + homepage: https://jgi.doe.gov/data-and-tools/software-tools/bbtools/ + documentation: https://jgi.doe.gov/data-and-tools/software-tools/bbtools/bb-tools-user-guide/ + licence: ["UC-LBL license (see package)"] + identifier: biotools:bbmap + +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - reads: + type: file + description: | + List of input paired end fastq files + pattern: "*.{fastq,fq}.gz" + - - interleave: + type: boolean + description: | + Indicates whether the input paired reads are interleaved or not +output: + - repaired: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - "*_repaired.fastq.gz": + type: file + description: re-paired reads + pattern: "*_repaired.fastq.gz" + - singleton: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - "${prefix}_singleton.fastq.gz": + type: file + description: singleton reads + pattern: "*singleton.fastq.gz" + - versions: + - versions.yml: + type: file + description: File containing software versions + pattern: "versions.yml" + - log: + - "*.log": + type: file + description: log file containing stdout and stderr from repair.sh + pattern: "*.log" +authors: + - "@mazzalab" +maintainers: + - "@mazzalab" + - "@tm4zza" diff --git a/modules/nf-core/bbmap/repair/tests/main.nf.test b/modules/nf-core/bbmap/repair/tests/main.nf.test new file mode 100644 index 00000000000..ea6ff0f3664 --- /dev/null +++ b/modules/nf-core/bbmap/repair/tests/main.nf.test @@ -0,0 +1,115 @@ +nextflow_process { + + name "Test Process BBMAP_REPAIR" + script "../main.nf" + process "BBMAP_REPAIR" + + tag "modules" + tag "modules_nfcore" + tag "bbmap" + tag "bbmap/repair" + + test("sarscov2_illumina_paired - fastq_gz") { + config "./nextflow.config" + + when { + params { + module_args = 'qin=33' + } + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + [file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true)] + ] + input[1] = false + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.versions).match() } + ) + } + } + + test("sarscov2_illumina_interleaved - fastq_gz") { + config "./nextflow.config" + + when { + params { + module_args = 'qin=33' + } + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + [file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_interleaved.fastq.gz', checkIfExists: true)] + ] + input[1] = true + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.versions).match() } + ) + } + } + + test("sarscov2_illumina_paired - fastq_gz - stub") { + config "./nextflow.config" + options "-stub" + + when { + params { + module_args = 'qin=33' + } + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + [file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true)] + ] + input[1] = false + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("sarscov2_illumina_interleaved - fastq_gz - stub") { + config "./nextflow.config" + options "-stub" + + when { + params { + module_args = 'qin=33' + } + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + [file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_interleaved.fastq.gz', checkIfExists: true)] + ] + input[1] = true + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } +} diff --git a/modules/nf-core/bbmap/repair/tests/main.nf.test.snap b/modules/nf-core/bbmap/repair/tests/main.nf.test.snap new file mode 100644 index 00000000000..54e929b0611 --- /dev/null +++ b/modules/nf-core/bbmap/repair/tests/main.nf.test.snap @@ -0,0 +1,156 @@ +{ + "sarscov2_illumina_paired - fastq_gz": { + "content": [ + [ + "versions.yml:md5,006e8f2167df95a778b428413ed9d859" + ] + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.2" + }, + "timestamp": "2024-12-19T11:01:18.284624712" + }, + "sarscov2_illumina_interleaved - fastq_gz - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": false + }, + [ + "test_1_repaired.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940", + "test_2_repaired.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ] + ], + "1": [ + [ + { + "id": "test", + "single_end": false + }, + "test_singleton.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "2": [ + "versions.yml:md5,006e8f2167df95a778b428413ed9d859" + ], + "3": [ + "test.repair.sh.log:md5,d41d8cd98f00b204e9800998ecf8427e" + ], + "log": [ + "test.repair.sh.log:md5,d41d8cd98f00b204e9800998ecf8427e" + ], + "repaired": [ + [ + { + "id": "test", + "single_end": false + }, + [ + "test_1_repaired.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940", + "test_2_repaired.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ] + ], + "singleton": [ + [ + { + "id": "test", + "single_end": false + }, + "test_singleton.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "versions": [ + "versions.yml:md5,006e8f2167df95a778b428413ed9d859" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.2" + }, + "timestamp": "2024-12-19T11:02:01.385727451" + }, + "sarscov2_illumina_interleaved - fastq_gz": { + "content": [ + [ + "versions.yml:md5,006e8f2167df95a778b428413ed9d859" + ] + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.2" + }, + "timestamp": "2024-12-19T11:01:32.752620818" + }, + "sarscov2_illumina_paired - fastq_gz - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": false + }, + [ + "test_1_repaired.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940", + "test_2_repaired.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ] + ], + "1": [ + [ + { + "id": "test", + "single_end": false + }, + "test_singleton.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "2": [ + "versions.yml:md5,006e8f2167df95a778b428413ed9d859" + ], + "3": [ + "test.repair.sh.log:md5,d41d8cd98f00b204e9800998ecf8427e" + ], + "log": [ + "test.repair.sh.log:md5,d41d8cd98f00b204e9800998ecf8427e" + ], + "repaired": [ + [ + { + "id": "test", + "single_end": false + }, + [ + "test_1_repaired.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940", + "test_2_repaired.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ] + ], + "singleton": [ + [ + { + "id": "test", + "single_end": false + }, + "test_singleton.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "versions": [ + "versions.yml:md5,006e8f2167df95a778b428413ed9d859" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.2" + }, + "timestamp": "2024-12-19T11:01:47.341193946" + } +} \ No newline at end of file diff --git a/modules/nf-core/bbmap/repair/tests/nextflow.config b/modules/nf-core/bbmap/repair/tests/nextflow.config new file mode 100644 index 00000000000..6b9f0bf755b --- /dev/null +++ b/modules/nf-core/bbmap/repair/tests/nextflow.config @@ -0,0 +1,5 @@ +process { + withName: BBMAP_REPAIR { + ext.args = params.module_args + } +} diff --git a/modules/nf-core/bbmap/repair/tests/tags.yml b/modules/nf-core/bbmap/repair/tests/tags.yml new file mode 100644 index 00000000000..a6e491df28f --- /dev/null +++ b/modules/nf-core/bbmap/repair/tests/tags.yml @@ -0,0 +1,2 @@ +bbmap/repair: + - "modules/nf-core/bbmap/repair/**"