Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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/centrifuger/centrifuger/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::centrifuger=1.1.0"
88 changes: 88 additions & 0 deletions modules/nf-core/centrifuger/centrifuger/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
process CENTRIFUGER_CENTRIFUGER {
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/centrifuger:1.1.0--hf426362_0':
'biocontainers/centrifuger:1.1.0--hf426362_0' }"

input:
tuple val(meta), path(reads)
path db
val save_unclassified
val save_classified
path barcode
path umi


output:
tuple val(meta), path("${meta.id}.tsv"), emit: classification_file
tuple val(meta), path("${meta.id}.classified*"), optional: true, emit: fastq_classified
tuple val(meta), path("${meta.id}.unclassified*"), optional: true, emit: fastq_unclassified
tuple val("${task.process}"), val('centrifuger'), eval("centrifuger -v 2>&1 | head -n 1 | cut -d ' ' -f 2 | sed 's/^v//'"),emit: versions_centrifuger, topic: versions
Comment thread
haris18s marked this conversation as resolved.

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

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def paired = meta.single_end ? "-u ${reads}" : "-1 ${reads[0]} -2 ${reads[1]}"
Comment thread
haris18s marked this conversation as resolved.
// Optional outputs
def unclassified_arg = save_unclassified ? "--un ${prefix}.unclassified" : ""
def classified_arg = save_classified ? "--cl ${prefix}.classified" : ""
def barcode_arg = barcode ? "--barcode ${barcode}" : ""
def umi_arg = umi ? "--UMI ${umi}" : ""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--read-format STR: format for read, barcode and UMI files, e.g. r1:0:-1,r2:0:-1,bc:0:15,um:16:-1 for paired-end files with barcode and UMI

This might be needed too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think they can pass through args right? is a STR not a file.



"""
db_name=`find -L ${db} -name "*.1.cfr" -not -name "._*" | sed 's/\\.1.cfr\$//'`

centrifuger \\
-x \$db_name \\
${paired} \\
${unclassified_arg} \\
${classified_arg} \\
${barcode_arg} \\
${umi_arg} \\
-t ${task.cpus} \\
${args} > ${prefix}.tsv

"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

"""
echo ${args}
#main output
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need this line?

touch ${prefix}.tsv

#Optional outputs
if ${save_unclassified}; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the optional outputs can be moved after def prefix

if ${meta.single_end}; then
echo "" | gzip > ${prefix}.unclassified.fq.gz
else
echo "" | gzip > ${prefix}.unclassified_1.fq.gz
echo "" | gzip > ${prefix}.unclassified_2.fq.gz
fi
fi

if ${save_classified}; then
if ${meta.single_end}; then
echo "" | gzip > ${prefix}.classified.fq.gz
else
echo "" | gzip > ${prefix}.classified_1.fq.gz
echo "" | gzip > ${prefix}.classified_2.fq.gz
fi
fi

cat <<-END_VERSIONS > versions.yml
"${task.process}":
centrifuger: \$(centrifuger -v 2>&1 | head -n 1 | cut -d ' ' -f 2)
END_VERSIONS
Comment thread
haris18s marked this conversation as resolved.
"""
}
114 changes: 114 additions & 0 deletions modules/nf-core/centrifuger/centrifuger/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: "centrifuger_centrifuger"
description: Classification of sequencing reads using the Centrifuger tool.
keywords:
- metagenomics
- classification
- centrifuger
tools:
- "centrifuger":
description: "Lossless compression of microbial genomes for efficient and accurate
metagenomic sequence classification."
homepage: "https://github.com/mourisl/centrifuger"
documentation: "https://github.com/mourisl/centrifuger"
tool_dev_url: "https://github.com/mourisl/centrifuger"
doi: "10.1186/s13059-024-03244-4"
licence:
- "MIT"
identifier: biotools:centrifuger
input:
- - meta:
type: map
description: Groovy Map containing sample information. e.g. `[
id:'sample1', single_end:false ]`
- reads:
type: file
description: |
List of input FastQ files of size 1 and 2 for single-end and paired-end, respectively.
pattern: "*.{fastq,fq,fastq.gz,fq.gz}"
ontologies:
- edam: http://edamontology.org/format_1930 #FASTQ
- db:
type: directory
description: Path to directory containing Centrifuger database files.
- save_unclassified:
type: boolean
description: |
Optional - if true, output unclassified reads.
- save_classified:
type: boolean
description: |
Optional - if true, output classified reads.
- barcode:
type: file
description: |
Optional barcode file.
- umi:
type: file
description: |
Optional UMI file.
output:
classification_file:
- - meta:
type: map
description: Groovy Map containing sample information. e.g. `[
id:'sample1', single_end:false ]`
- ${meta.id}.tsv:
type: file
description: |
File contαining classification results
pattern: "${prefix}.tsv"
ontologies:
- edam: http://edamontology.org/format_3475 #TSV

fastq_classified:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- ${meta.id}.classified*:
type: file
description: FASTQ file(s) containing classified reads
pattern: "*.{fastq,fq,fastq.gz,fq.gz}"
ontologies:
- edam: http://edamontology.org/format_1930

fastq_unclassified:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- ${meta.id}.unclassified*:
type: file
description: FASTQ file(s) containing unclassified reads
pattern: "*.{fastq,fq,fastq.gz,fq.gz}"
ontologies:
- edam: http://edamontology.org/format_1930
versions_centrifuger:
- - ${task.process}:
type: string
description: The name of the process
- centrifuger:
type: string
description: The name of the tool
- centrifuger -v 2>&1 | head -n 1 | cut -d ' ' -f 2 | sed 's/^v//':
type: eval
description: The expression to obtain the version of the tool
topics:
versions:
- - ${task.process}:
type: string
description: The name of the process
- centrifuger:
type: string
description: The name of the tool
- centrifuger -v 2>&1 | head -n 1 | cut -d ' ' -f 2 | sed 's/^v//':
type: eval
description: The expression to obtain the version of the tool
authors:
- "@haris18s"
maintainers:
- "@haris18s"
- "@sofstam"
- "@jfy133"
114 changes: 114 additions & 0 deletions modules/nf-core/centrifuger/centrifuger/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "centrifuger"
tag "centrifuger/centrifuger"
tag "untar"

setup {
run("UNTAR") {
script "../../../untar/main.nf"
process {
"""
input[0] = [ [], file('https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/delete_me/cfr_files_short.tar.gz', checkIfExists: true) ]
"""
}
}
}

test("sarscov2 - fastq_single_end") {
when {
process {
"""
input[0] = [[ id:'test', single_end: true ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true)
]
input[1] = UNTAR.out.untar.map{ it[1] }
input[2] = true
input[3] = true
input[4] = []
Comment thread
haris18s marked this conversation as resolved.
input[5] = []
"""
}
}
then {
assertAll(
{assert process.success },
{ assert snapshot(
file(process.out.classification_file[0][1]).name,
file(process.out.fastq_classified[0][1]).name,
file(process.out.fastq_unclassified[0][1]).name,
process.out.findAll { key, val -> key.startsWith('versions') }
).match() }
)
}
}
test("sarscov2 - fastq_paired_end") {
when {
process {
"""
input[0] = [
[ id:'test', single_end: false ],
[
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] = UNTAR.out.untar.map{ it[1] }
input[2] = true
input[3] = true
input[4] = []
input[5] = []
"""
}
}
then {
assertAll(
{assert process.success },
{ assert snapshot(
file(process.out.classification_file[0][1]).name,
process.out.fastq_classified[0][1].collect { file(it).name },
process.out.fastq_unclassified[0][1].collect {file (it).name },
process.out.findAll { key, val -> key.startsWith('versions') }
).match() }
)
}

}
test("sarscov2 - fastq_single_end_stub") {
options "-stub"

when {
process {
"""
input[0] = [[ id:'test', single_end: true ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true)
]
input[1] = UNTAR.out.untar.map{ it[1] }
input[2] = true
input[3] = true
input[4] = []
input[5] = []
"""
}
}
then {
assertAll(
{assert process.success },
{ assert snapshot(
file(process.out.classification_file[0][1]).name,
file(process.out.fastq_classified[0][1]).name,
file(process.out.fastq_unclassified[0][1]).name,
process.out.findAll { key, val -> key.startsWith('versions') }
Comment thread
haris18s marked this conversation as resolved.
).match() }
)
}

}

}
71 changes: 71 additions & 0 deletions modules/nf-core/centrifuger/centrifuger/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"sarscov2 - fastq_paired_end": {
"content": [
"test.tsv",
[
"test.classified_1.fq.gz",
"test.classified_2.fq.gz"
],
[
"test.unclassified_1.fq.gz",
"test.unclassified_2.fq.gz"
],
{
"versions_centrifuger": [
[
"CENTRIFUGER_CENTRIFUGER",
"centrifuger",
"1.1.0-r299"
]
]
}
],
"timestamp": "2026-04-20T10:50:42.284983",
"meta": {
"nf-test": "0.9.4",
"nextflow": "25.10.4"
}
},
"sarscov2 - fastq_single_end": {
"content": [
"test.tsv",
"test.classified.fq.gz",
"test.unclassified.fq.gz",
{
"versions_centrifuger": [
[
"CENTRIFUGER_CENTRIFUGER",
"centrifuger",
"1.1.0-r299"
]
]
}
],
"timestamp": "2026-04-20T10:50:36.957143",
"meta": {
"nf-test": "0.9.4",
"nextflow": "25.10.4"
}
},
"sarscov2 - fastq_single_end_stub": {
"content": [
"test.tsv",
"test.classified.fq.gz",
"test.unclassified.fq.gz",
{
"versions_centrifuger": [
[
"CENTRIFUGER_CENTRIFUGER",
"centrifuger",
"1.1.0-r299"
]
]
}
],
"timestamp": "2026-04-20T10:50:46.78207",
"meta": {
"nf-test": "0.9.4",
"nextflow": "25.10.4"
}
}
}
Loading
Loading