Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New kma module #7251

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions modules/nf-core/kma/index/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- bioconda
- conda-forge
dependencies:
- bioconda::kma=1.4.15
52 changes: 52 additions & 0 deletions modules/nf-core/kma/index/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
process KMA_INDEX {
tag "$meta.id"
label 'process_low'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/kma:1.4.15--h577a1d6_1' :
'biocontainers/kma:1.4.15--h577a1d6_1' }"

input:
tuple val(meta), path(fasta)

output:
tuple val(meta), path("kmaindex"), emit: index
path "versions.yml", emit: versions

when:
task.ext.when == null || task.ext.when

script:
def prefix = task.ext.prefix ?: "${fasta.baseName}"
def args = task.ext.args ?: ''
"""
mkdir kmaindex
kma \\
index \\
-i ${fasta} \\
-o kmaindex/${prefix} \\
$args

cat <<-END_VERSIONS > versions.yml
"${task.process}":
kma: \$(echo \$(kma_index -v 2>&1) | sed 's/^KMA_index-\$//')
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${fasta.baseName}"
"""
mkdir kmaindex

touch kmaindex/${prefix}.comp.b
touch kmaindex/${prefix}.length.b
touch kmaindex/${prefix}.name
touch kmaindex/${prefix}.seq.b

cat <<-END_VERSIONS > versions.yml
"${task.process}":
kma: \$(echo \$(kma_index -v 2>&1) | sed 's/^KMA_index-\$//')
END_VERSIONS
"""
}
52 changes: 52 additions & 0 deletions modules/nf-core/kma/index/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "kma_index"
description: This module wraps the index module of the KMA alignment tool.
keywords:
- alignment
- kma
- index
- database
- reads
tools:
- "kma":
description: "Rapid and precise alignment of raw reads against redundant databases with KMA"
homepage: "https://bitbucket.org/genomicepidemiology/kma/src/master/"
documentation: "https://bitbucket.org/genomicepidemiology/kma/src/master/"
tool_dev_url: "https://bitbucket.org/genomicepidemiology/kma/src/master/"
doi: "10.1186/s12859-018-2336-6"
licence:
["http://www.apache.org/licenses/LICENSE-2.0"]

input:
- - meta:
type: map
description: |
Groovy Map containing reference information
e.g. `[ id:'reference' ]`
- fasta:
type: file
description: (Multi-)FASTA file of your database sequences.
pattern: "*.{fa,fasta}"

output:
- index:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'reference' ]`
- 'kmaindex':
type: directory
description: Directory of KMA index files
pattern: "*.{comp.b,length.b,name,seq.b}"
- versions:
- versions.yml:
type: file
description: File containing software versions
pattern: "versions.yml"

authors:
- "@krannich479"
maintainers:
- "@krannich479"
59 changes: 59 additions & 0 deletions modules/nf-core/kma/index/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

nextflow_process {

name "Test Process KMA_INDEX"
script "../main.nf"
process "KMA_INDEX"

tag "modules"
tag "modules_nfcore"
tag "kma"
tag "kma/index"

test("sarscov2 - fasta") {

when {
process {
"""
input[0] = [
[ id:'MT192765.1', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("sarscov2 - fasta - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'MT192765.1', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
92 changes: 92 additions & 0 deletions modules/nf-core/kma/index/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"sarscov2 - fasta - stub": {
"content": [
{
"0": [
[
{
"id": "MT192765.1",
"single_end": false
},
[
"genome.comp.b:md5,d41d8cd98f00b204e9800998ecf8427e",
"genome.length.b:md5,d41d8cd98f00b204e9800998ecf8427e",
"genome.name:md5,d41d8cd98f00b204e9800998ecf8427e",
"genome.seq.b:md5,d41d8cd98f00b204e9800998ecf8427e"
]
]
],
"1": [
"versions.yml:md5,ba9763933bdc811b1e19e466cceae9c8"
],
"index": [
[
{
"id": "MT192765.1",
"single_end": false
},
[
"genome.comp.b:md5,d41d8cd98f00b204e9800998ecf8427e",
"genome.length.b:md5,d41d8cd98f00b204e9800998ecf8427e",
"genome.name:md5,d41d8cd98f00b204e9800998ecf8427e",
"genome.seq.b:md5,d41d8cd98f00b204e9800998ecf8427e"
]
]
],
"versions": [
"versions.yml:md5,ba9763933bdc811b1e19e466cceae9c8"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2024-12-19T17:07:30.875020727"
},
"sarscov2 - fasta": {
"content": [
{
"0": [
[
{
"id": "MT192765.1",
"single_end": false
},
[
"genome.comp.b:md5,2d4075cee26606cfb9b3624f8d7fe260",
"genome.length.b:md5,aaded6f5e19db3f3292e7ff9cd0157ec",
"genome.name:md5,e98cac0e614ac65bb458f77245af7d32",
"genome.seq.b:md5,48647a9697263fe218ddc728c2d01641"
]
]
],
"1": [
"versions.yml:md5,ba9763933bdc811b1e19e466cceae9c8"
],
"index": [
[
{
"id": "MT192765.1",
"single_end": false
},
[
"genome.comp.b:md5,2d4075cee26606cfb9b3624f8d7fe260",
"genome.length.b:md5,aaded6f5e19db3f3292e7ff9cd0157ec",
"genome.name:md5,e98cac0e614ac65bb458f77245af7d32",
"genome.seq.b:md5,48647a9697263fe218ddc728c2d01641"
]
]
],
"versions": [
"versions.yml:md5,ba9763933bdc811b1e19e466cceae9c8"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2024-12-19T17:07:24.8942212"
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/kma/index/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
kma/index:
- "modules/nf-core/kma/index/**"
7 changes: 7 additions & 0 deletions modules/nf-core/kma/kma/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- bioconda
- conda-forge
dependencies:
- kma==1.4.15
76 changes: 76 additions & 0 deletions modules/nf-core/kma/kma/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
process KMA {
tag "$meta.id"
label 'process_low'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/kma:1.4.15--h577a1d6_1' :
'biocontainers/kma:1.4.15--h577a1d6_1' }"

input:
tuple val(meta) , path(reads)
tuple val(meta2), path(index)
val interleaved
val mat_format

output:
tuple val(meta), path("*.res") , optional: true, emit: res
tuple val(meta), path("*.fsa") , optional: true, emit: fsa
tuple val(meta), path("*.aln") , optional: true, emit: aln
tuple val(meta), path("*.frag.gz") , optional: true, emit: frag
tuple val(meta), path("*.mat.gz") , optional: true, emit: mat // if mat_format == true
tuple val(meta), path("*.spa") , optional: true, emit: spa // if ext.args contains '-Sparse' (only output in this case)
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}.${meta2.id}"
def input_style = interleaved ? "-int ${reads}" : "-ipe ${reads}"
def create_mat = mat_format ? "-matrix" : ''
"""
INDEX=`find -L ./ -name "*.name" | sed 's/\\.name\$//'`

kma \\
${input_style} \\
-o ${prefix} \\
-t_db \$INDEX \\
${create_mat} \\
$args

cat <<-END_VERSIONS > versions.yml
"${task.process}":
kma: \$(echo \$(kma -v 2>&1) | sed 's/^KMA-\$//')
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}.${meta2.id}"
def create_spa = task.ext.args.contains('-Sparse')

if ( create_spa )
"""
touch ${prefix}.spa
"""
else
"""
touch ${prefix}.res \\
touch ${prefix}.fsa \\
touch ${prefix}.aln \\
touch ${prefix}.frag.gz
"""

if ( mat_format )
"""
touch ${prefix}.mat.gz
"""

"""
cat <<-END_VERSIONS > versions.yml
"${task.process}":
kma: \$(echo \$(kma -v 2>&1) | sed 's/^KMA-\$//')
END_VERSIONS
"""
}
Loading
Loading