8000 srst2/srst2 to nf-test by famosab · Pull Request #8301 · nf-core/modules · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

srst2/srst2 to nf-test #8301

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.

Sign up for GitHub

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

Merged
merged 9 commits into from
May 28, 2025
Merged
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
43 changes: 33 additions & 10 deletions modules/nf-core/srst2/srst2/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ process SRST2_SRST2 {

input:
tuple val(meta), path(fastq_s), path(db)
val(db_type)

output:
tuple val(meta), path("*_genes_*_results.txt") , optional:true, emit: gene_results
tuple val(meta), path("*_fullgenes_*_results.txt") , optional:true, emit: fullgene_results
tuple val(meta), path("*_mlst_*_results.txt") , optional:true, emit: mlst_results
tuple val(meta), path("*.pileup") , emit: pileup
tuple val(meta), path("*.sorted.bam") , emit: sorted_bam
path "versions.yml" , emit: versions
tuple val(meta), path("*_genes_*_results.txt") , emit: gene_results , optional:true
tuple val(meta), path("*_fullgenes_*_results.txt"), emit: fullgene_results, optional:true
tuple val(meta), path("*_mlst_*_results.txt") , emit: mlst_results , optional:true
tuple val(meta), path("*.pileup") , emit: pileup
tuple val(meta), path("*.sorted.bam") , emit: sorted_bam
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when
Expand All @@ -25,12 +26,12 @@ process SRST2_SRST2 {
def args = task.ext.args ?: ""
def prefix = task.ext.prefix ?: "${meta.id}"
def read_s = meta.single_end ? "--input_se ${fastq_s}" : "--input_pe ${fastq_s[0]} ${fastq_s[1]}"
if (meta.db=="gene") {
if (db_type=="gene") {
database = "--gene_db ${db}"
} else if (meta.db=="mlst") {
} else if (db_type=="mlst") {
database = "--mlst_db ${db}"
} else {
error "Please set meta.db to either \"gene\" or \"mlst\""
error "Please set input[1] to either \"gene\" or \"mlst\""
}
"""
srst2 \\
Expand All @@ -39,9 +40,31 @@ process SRST2_SRST2 {
--output ${prefix} \\
${database} \\
$args

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

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
def db_name = db.getBaseName()
if (db_type=="gene") {
db_cmd = "touch ${prefix}__genes__${db_name}__results.txt ${prefix}__fullgenes__${db_name}__results.txt"
} else if (db_type=="mlst") {
db_cmd = "touch ${prefix}__mlst__${db_name}__results.txt"
} else {
error "Please set input[1] to either \"gene\" or \"mlst\""
}
"""
touch ${prefix}.pileup
touch ${prefix}.sorted.bam
${db_cmd}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
srst2: \$(echo \$(srst2 --version 2>&1) | sed 's/srst2 //' ))
srst2: \$(echo \$(srst2 --version 2>&1) | sed 's/srst2 //' )
END_VERSIONS
"""
}
3 changes: 3 additions & 0 deletions modules/nf-core/srst2/srst2/meta.yml
10000
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ input:
type: file
description: Database in FASTA format
pattern: "*.fasta"
- - db_type:
type: string
description: Type of database to use, either 'gene' or 'mlst'
output:
- gene_results:
- meta:
Expand Down
158 changes: 158 additions & 0 deletions modules/nf-core/srst2/srst2/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
nextflow_process {

name "Test Process SRST2_SRST2"

script "../main.nf"
process "SRST2_SRST2"

tag "modules"
tag "modules_nfcore"
tag "srst2"
tag "srst2/srst2"

test("delete_me - fastq.gz") {

when {
process {
"""
input[0] = [
[id:'test', single_end:false],// meta map
[
file(params.modules_testdata_base_path + 'delete_me/srst2/SRR9067271_1.fastq.gz',checkIfExists:true),
file(params.modules_testdata_base_path + 'delete_me/srst2/SRR9067271_2.fastq.gz',checkIfExists:true)
],
file(params.modules_testdata_base_path + 'delete_me/srst2/MLST_DB.fas', checkIfExists:true)
]
input[1] = "mlst"
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(
path(process.out.mlst_results.get(0).get(1)).readLines(),
path(process.out.pileup.get(0).get(1)).readLines()[0..10],
bam(process.out.sorted_bam.get(0).get(1)).getStatistics(),
process.out.versions
).match() }
)
}
}

// test("bacteroides_fragilis - fastq.gz - paired_end") {

// when {
// process {
// """
// input[0] = [
// [id:'test', single_end:false],// meta map
// [
// file(params.modules_testdata_base_path + 'genomics/prokaryotes/bacteroides_fragilis/illumina/fastq/test1_1.fastq.gz',checkIfExists:true),
// file(params.modules_testdata_base_path + 'genomics/prokaryotes/bacteroides_fragilis/illumina/fastq/test1_2.fastq.gz',checkIfExists:true)
// ],
// file(params.modules_testdata_base_path + 'delete_me/srst2/resFinder_20180221_srst2.fasta',checkIfExists:true)
// ]
// input[1] = "gene"
// """
// }
// }
// then {
// assertAll(
// { assert process.success },
// { assert snapshot(
// path(process.out.gene_results.get(0).get(1)).readLines(),
// path(process.out.fullgene_results.get(0).get(1)).readLines(),
// path(process.out.pileup.get(0).get(1)).readLines(),
// bam(process.out.sorted_bam.get(0).get(1)).getReadsMD5(),
// process.out.versions
// ).match() }
// )
// }
// }

// test("bacteroides_fragilis - fastq.gz - single_end") {

// when {
// process {
// """
// input[0] = [
// [id:'test', single_end:true],// meta map
// file(params.modules_testdata_base_path + 'genomics/prokaryotes/bacteroides_fragilis/illumina/fastq/test1_1.fastq.gz', checkIfExists:true),
// file(params.modules_testdata_base_path + 'delete_me/srst2/resFinder_20180221_srst2.fasta', checkIfExists:true)
// ]
// input[1] = "gene"
// """
// }
// }
// then {
// assertAll(
// { assert process.success },
// { assert snapshot(
// path(process.out.gene_results.get(0).get(1)).readLines(),
// path(process.out.fullgene_results.get(0).get(1)).readLines(),
// path(process.out.pileup.get(0).get(1)).readLines(),
// bam(process.out.sorted_bam.get(0).get(1)).getReadsMD5(),
// process.out.versions
// ).match() }
// )
// }
// }

test("delete_me - fastq.gz - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[id:'test', single_end:false],// meta map
[
file(params.modules_testdata_base_path + 'delete_me/srst2/SRR9067271_1.fastq.gz',checkIfExists:true),
file(params.modules_testdata_base_path + 'delete_me/srst2/SRR9067271_2.fastq.gz',checkIfExists:true)
],
file(params.modules_testdata_base_path + 'delete_me/srst2/MLST_DB.fas', checkIfExists:true)
]
input[1] = "mlst"
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out,
path(process.out.versions[0]).yaml
).match() }
)
}
}

test("bacteroides_fragilis - fastq.gz - single_end - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[id:'test',single_end:true],// meta map
file(params.modules_testdata_base_path + 'genomics/prokaryotes/bacteroides_fragilis/illumina/fastq/test1_1.fastq.gz',checkIfExists:true),
file(params.modules_testdata_base_path + 'delete_me/srst2/resFinder_20180221_srst2.fasta',checkIfExists:true)
]
input[1] = "gene"
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out,
path(process.out.versions[0]).yaml
).match() }
)
}
}
}
Loading
Loading
0