From ce6ca4dbec5921f62a427a6a433a66b6bc1f0dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Beracochea?= Date: Tue, 20 Aug 2024 15:57:07 +0100 Subject: [PATCH] Add a module for MashMap (#6208) * Module for MashMap * Fix mashmap based on PR feedback - Adjust the test_data path format - Fixed versions.yml, it was empy - Added meta2 for the reference input channel --- modules/nf-core/mashmap/environment.yml | 9 +++ modules/nf-core/mashmap/main.nf | 48 +++++++++++++ modules/nf-core/mashmap/meta.yml | 57 +++++++++++++++ modules/nf-core/mashmap/tests/main.nf.test | 69 ++++++++++++++++++ .../nf-core/mashmap/tests/main.nf.test.snap | 72 +++++++++++++++++++ modules/nf-core/mashmap/tests/tags.yml | 2 + 6 files changed, 257 insertions(+) create mode 100644 modules/nf-core/mashmap/environment.yml create mode 100644 modules/nf-core/mashmap/main.nf create mode 100644 modules/nf-core/mashmap/meta.yml create mode 100644 modules/nf-core/mashmap/tests/main.nf.test create mode 100644 modules/nf-core/mashmap/tests/main.nf.test.snap create mode 100644 modules/nf-core/mashmap/tests/tags.yml diff --git a/modules/nf-core/mashmap/environment.yml b/modules/nf-core/mashmap/environment.yml new file mode 100644 index 00000000000..9ee3e8f73eb --- /dev/null +++ b/modules/nf-core/mashmap/environment.yml @@ -0,0 +1,9 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +name: "mashmap" +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - "bioconda::mashmap=3.1.3" diff --git a/modules/nf-core/mashmap/main.nf b/modules/nf-core/mashmap/main.nf new file mode 100644 index 00000000000..4c8014df0e2 --- /dev/null +++ b/modules/nf-core/mashmap/main.nf @@ -0,0 +1,48 @@ +process MASHMAP { + tag "$meta.id" + label 'process_medium' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/mashmap:3.1.3--h07ea13f_0': + 'biocontainers/mashmap:3.1.3--h07ea13f_0' }" + + input: + tuple val(meta), path(fasta) + tuple val(meta2), path(reference) + + output: + tuple val(meta), path("*.paf"), emit: paf + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + """ + mashmap -q ${fasta} \\ + -r ${reference} \\ + -t ${task.cpus} \\ + -o ${prefix}.paf \\ + ${args} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + mashmap: \$(mashmap --version 2>&1) + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.paf + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + mashmap: \$(mashmap --version 2>&1) + END_VERSIONS + """ +} diff --git a/modules/nf-core/mashmap/meta.yml b/modules/nf-core/mashmap/meta.yml new file mode 100644 index 00000000000..f9a608c8aff --- /dev/null +++ b/modules/nf-core/mashmap/meta.yml @@ -0,0 +1,57 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "mashmap" +description: Mashmap is an approximate long read or contig mapper based on Jaccard similarity +keywords: + - mapper + - aligner + - minhash + - kmer +tools: + - "mashmap": + description: "A fast approximate aligner for long DNA sequences." + homepage: "https://github.com/marbl/MashMap" + documentation: "https://github.com/marbl/MashMap" + tool_dev_url: "https://github.com/marbl/MashMap" + doi: "10.1007/978-3-319-56970-3_5" + licence: ["Public Domain"] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + + - fasta: + type: file + description: Input fasta file containing query sequences + pattern: "*.{fa,fasta,fa.gz,fasta.gz}" + + - reference: + type: file + description: Input fasta file containing reference sequences + pattern: "*.{fa,fasta,fa.gz,fasta.gz}" + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + + - paf: + type: file + description: Alignment in PAF format + pattern: "*.paf" + + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@mberacochea" + +maintainers: + - "@mberacochea" diff --git a/modules/nf-core/mashmap/tests/main.nf.test b/modules/nf-core/mashmap/tests/main.nf.test new file mode 100644 index 00000000000..afcfc24df6b --- /dev/null +++ b/modules/nf-core/mashmap/tests/main.nf.test @@ -0,0 +1,69 @@ +nextflow_process { + + name "Test Process MASHMAP" + script "../main.nf" + process "MASHMAP" + + tag "modules" + tag "modules_nfcore" + tag "mashmap" + + test("Should align the contigs to the genome") { + + when { + process { + """ + // Query + input[0] = [ + [ id:'test', single_end:false ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fasta/contigs.fasta', checkIfExists: true) + ] + // Reference + input[1] = [ + [ id:'sarscov2_genome' ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.gz', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + + test("Should align the contigs to the genome - stub") { + + options "-stub" + + when { + process { + """ + // Query + input[0] = [ + [ id:'test', single_end:false ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fasta/contigs.fasta', checkIfExists: true) + ] + // Reference + input[1] = [ + [ id:'sarscov2_genome' ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.gz', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} diff --git a/modules/nf-core/mashmap/tests/main.nf.test.snap b/modules/nf-core/mashmap/tests/main.nf.test.snap new file mode 100644 index 00000000000..249c30a04b7 --- /dev/null +++ b/modules/nf-core/mashmap/tests/main.nf.test.snap @@ -0,0 +1,72 @@ +{ + "Should align the contigs to the genome - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": false + }, + "test.paf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,3dccac8ea537122bd63488e9ad5737bf" + ], + "paf": [ + [ + { + "id": "test", + "single_end": false + }, + "test.paf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,3dccac8ea537122bd63488e9ad5737bf" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.3" + }, + "timestamp": "2024-08-17T09:26:01.404111" + }, + "Should align the contigs to the genome": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": false + }, + "test.paf:md5,170c0c1e438154d743c595aa511f7e6e" + ] + ], + "1": [ + "versions.yml:md5,3dccac8ea537122bd63488e9ad5737bf" + ], + "paf": [ + [ + { + "id": "test", + "single_end": false + }, + "test.paf:md5,170c0c1e438154d743c595aa511f7e6e" + ] + ], + "versions": [ + "versions.yml:md5,3dccac8ea537122bd63488e9ad5737bf" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.3" + }, + "timestamp": "2024-08-17T09:25:33.715838" + } +} \ No newline at end of file diff --git a/modules/nf-core/mashmap/tests/tags.yml b/modules/nf-core/mashmap/tests/tags.yml new file mode 100644 index 00000000000..64b3e3a1d28 --- /dev/null +++ b/modules/nf-core/mashmap/tests/tags.yml @@ -0,0 +1,2 @@ +mashmap: + - "modules/nf-core/mashmap/**"