Skip to content

Commit

Permalink
Add a module for MashMap (#6208)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mberacochea authored Aug 20, 2024
1 parent 41fc46d commit ce6ca4d
Show file tree
Hide file tree
Showing 6 changed files with 257 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/nf-core/mashmap/environment.yml
Original file line number Diff line number Diff line change
@@ -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"
48 changes: 48 additions & 0 deletions modules/nf-core/mashmap/main.nf
Original file line number Diff line number Diff line change
@@ -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
"""
}
57 changes: 57 additions & 0 deletions modules/nf-core/mashmap/meta.yml
Original file line number Diff line number Diff line change
@@ -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"
69 changes: 69 additions & 0 deletions modules/nf-core/mashmap/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -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() }
)
}

}

}
72 changes: 72 additions & 0 deletions modules/nf-core/mashmap/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -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"
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/mashmap/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mashmap:
- "modules/nf-core/mashmap/**"

0 comments on commit ce6ca4d

Please sign in to comment.