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

Add sylphtax taxprof module #7452

Merged
merged 13 commits into from
Feb 13, 2025
7 changes: 7 additions & 0 deletions modules/nf-core/sylphtax/taxprof/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:
- conda-forge
- bioconda
dependencies:
- "bioconda::sylph-tax=1.1.2"
50 changes: 50 additions & 0 deletions modules/nf-core/sylphtax/taxprof/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

process SYLPHTAX_TAXPROF {
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/sylph-tax:1.1.2--pyhdfd78af_0':
'biocontainers/sylph-tax:1.1.2--pyhdfd78af_0' }"

input:
tuple val(meta), path(sylph_results)
path taxonomy

output:
tuple val(meta), path("*.sylphmpa"), emit: taxprof_output
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}"

"""
sylph-tax \\
taxprof \\
$sylph_results \\
$args \\
-o ${prefix}.sylphmpa \\
sofstam marked this conversation as resolved.
Show resolved Hide resolved
-t $taxonomy

cat <<-END_VERSIONS > versions.yml
"${task.process}":
sylph-tax: \$(sylph-tax --version 2>&1 | sed -n 's/.*\\([0-9]\\+\\.[0-9]\\+\\.[0-9]\\+\\).*/\\1/p' | head -n 1)
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.sylphmpa

cat <<-END_VERSIONS > versions.yml
"${task.process}":
sylph-tax: \$(sylph-tax --version 2>&1 | sed -n 's/.*\\([0-9]\\+\\.[0-9]\\+\\.[0-9]\\+\\).*/\\1/p' | head -n 1)
END_VERSIONS
"""
}
51 changes: 51 additions & 0 deletions modules/nf-core/sylphtax/taxprof/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: sylphtax_taxprof
description: Incorporates taxonomy into sylph metagenomic classifier
keywords:
- taxonomy
- sylph
- metagenomics
tools:
- sylphtax:
description: Integrating taxonomic information into the sylph metagenome profiler.
homepage: https://github.com/bluenote-1577/sylph-tax?tab=readme-ov-file
documentation: https://sylph-docs.github.io/sylph-tax/
licence: ["MIT"]
identifier: ''
input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- sylph_results:
type: file
description: Output results from sylph classifier. The database file(s) used to create this file with sylph must be the same as those of the taxonomy input channel of this module.
pattern: "*.{tsv}"
- - taxonomy:
type: file
description: A list of sylph-tax identifiers (e.g. GTDB_r220 or IMGVR_4.1).
Multiple taxonomy metadata files can be input. Custom taxonomy files are also
possible.
output:
- taxprof_output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
pattern: "*{.sylphmpa}"
- '*.sylphmpa':
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
pattern: "*{.sylphmpa}"
- versions:
- versions.yml:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@sofstam"
maintainers:
- "@sofstam"
91 changes: 91 additions & 0 deletions modules/nf-core/sylphtax/taxprof/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "sylph"
tag "sylph/profile"
tag "sylphtax"
tag "sylphtax/taxprof"


test("sarscov2 illumina single-end [fastq_gz]") {
setup {
run("SYLPH_PROFILE") {
script "../../../sylph/profile/main.nf"
process {
"""
input[0] = [ [ id:'test' ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true)
]
]
input[1] = file(params.modules_testdata_base_path +'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
"""
}
}
}
when {
process {
"""
input[0] = SYLPH_PROFILE.out.profile_out
input[1] = file('https://github.com/nf-core/test-datasets/raw/taxprofiler/data/database/sylph/test_taxonomy.tsv.gz', checkIfExists: true)
"""
}
}

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

}

test("stub sarscov2 illumina single-end [fastq_gz]") {

options '-stub'

setup {
run("SYLPH_PROFILE") {
script "../../../sylph/profile/main.nf"
process {
"""
input[0] = [ [ id:'test' ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true)
]
]
input[1] = file(params.modules_testdata_base_path +'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
"""
}
}
}
when {
process {
"""
input[0] = SYLPH_PROFILE.out.profile_out
input[1] = file('https://github.com/nf-core/test-datasets/raw/taxprofiler/data/database/sylph/test_taxonomy.tsv.gz', checkIfExists: true)
"""
}
}

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

}
42 changes: 42 additions & 0 deletions modules/nf-core/sylphtax/taxprof/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"stub sarscov2 illumina single-end [fastq_gz]": {
"content": [
[
"versions.yml:md5,976fae8d146f4f3087e2a090703f09b9"
],
[
[
{
"id": "test"
},
"test.sylphmpa:md5,d41d8cd98f00b204e9800998ecf8427e"
]
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-02-13T13:27:49.708058346"
},
"sarscov2 illumina single-end [fastq_gz]": {
"content": [
[
"versions.yml:md5,976fae8d146f4f3087e2a090703f09b9"
],
[
[
{
"id": "test"
},
"test.sylphmpatest_1.fastq.gz.sylphmpa:md5,797e3463eeb9a2e8f91de9b842cd421d"
]
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-02-13T13:22:19.31463228"
}
}
Loading