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 extra input channel to KRAKEN2/ADD #7721

Open
wants to merge 4 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
1 change: 1 addition & 0 deletions modules/nf-core/kraken2/add/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ process KRAKEN2_ADD {
path taxonomy_names, stageAs: 'taxonomy/names.dmp'
path taxonomy_nodes, stageAs: 'taxonomy/nodes.dmp'
path accession2taxid, stageAs: 'taxonomy/*'
path seqid2taxid, stageAs: 'taxonomy/seqid2taxid.map'

output:
tuple val(meta), path("$prefix"), emit: db
Expand Down
6 changes: 6 additions & 0 deletions modules/nf-core/kraken2/add/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ input:
type: file
description: associates sequence accession IDs to taxonomy IDs
pattern: "*.accession2taxid"
- - seqid2taxid:
type: file
description: optional premade 2 column seq2taxid map file. Must be named seq2taxid.map.
If not supplied will be generated by kraken2 itself during upstream build
step.
pattern: "seqit2taxid.map"
output:
- db:
- meta:
Expand Down
36 changes: 36 additions & 0 deletions modules/nf-core/kraken2/add/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,41 @@ nextflow_process {
input[1] = file(params.modules_testdata_base_path + "genomics/sarscov2/metagenome/prot_names.dmp", checkIfExists: true)
input[2] = file(params.modules_testdata_base_path + "genomics/sarscov2/metagenome/prot_nodes.dmp", checkIfExists: true)
input[3] = GUNZIP.out.gunzip.map{ it[1] }
input[4] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert process.out.db.get(0).get(1) ==~ ".*/test" },
{ assert snapshot (
path("${process.out.db[0][1]}/library/added/").list().size(),
path("${process.out.db[0][1]}/taxonomy/")
).match()
}
)
}

}

test("sarscov2 protein_db custom-seqid2map") {

when {
process {
"""
input[0] = [
[ id:'test' ],
[
file(params.modules_testdata_base_path + "genomics/sarscov2/genome/genome.fasta", checkIfExists: true),
file(params.modules_testdata_base_path + "genomics/sarscov2/genome/proteome.fasta", checkIfExists: true)
]
]
input[1] = file(params.modules_testdata_base_path + "genomics/sarscov2/metagenome/prot_names.dmp", checkIfExists: true)
input[2] = file(params.modules_testdata_base_path + "genomics/sarscov2/metagenome/prot_nodes.dmp", checkIfExists: true)
input[3] = GUNZIP.out.gunzip.map{ it[1] }
input[4] = file(params.modules_testdata_base_path + "genomics/sarscov2/metagenome/prot_seqid2taxid.map", checkIfExists: true)
"""
}
}
Expand Down Expand Up @@ -76,6 +111,7 @@ test("sarscov2 protein_db stub") {
input[1] = file(params.modules_testdata_base_path + "genomics/sarscov2/metagenome/prot_names.dmp", checkIfExists: true)
input[2] = file(params.modules_testdata_base_path + "genomics/sarscov2/metagenome/prot_nodes.dmp", checkIfExists: true)
input[3] = GUNZIP.out.gunzip.map{ it[1] }
input[4] = []
"""
}
}
Expand Down
16 changes: 16 additions & 0 deletions modules/nf-core/kraken2/add/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@
},
"timestamp": "2024-03-18T20:20:05.09765"
},
"sarscov2 protein_db custom-seqid2map": {
"content": [
6,
[
"names.dmp:md5,130f9132095562e09c732679c562f5e9",
"nodes.dmp:md5,c471c27a4ce85ae74d2c63633c9ce1e3",
"prot.accession2taxid:md5,c0f96ba5dbb00150b4b805ba6dab7bea",
"seqid2taxid.map:md5,054c8ba74ccfca4412802066eac923f6"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-02-28T22:06:46.792386654"
},
"sarscov2 protein_db stub": {
"content": [
{
Expand Down
105 changes: 89 additions & 16 deletions modules/nf-core/kraken2/build/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ nextflow_process {
tag "gunzip"
tag "modules"
tag "modules_nfcore"
tag "DEBUG"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
tag "DEBUG"


setup {

Expand All @@ -28,33 +29,84 @@ nextflow_process {
}
}

run("KRAKEN2_ADD") {
script "modules/nf-core/kraken2/add/main.nf"
}

test("sarscov2 protein_db") {

setup {
run("KRAKEN2_ADD") {
script "modules/nf-core/kraken2/add/main.nf"
process {
"""
input[0] = [
[ id:'test' ],
[
file(params.modules_testdata_base_path + "genomics/sarscov2/genome/genome.fasta", checkIfExists: true),
file(params.modules_testdata_base_path + "genomics/sarscov2/genome/proteome.fasta", checkIfExists: true)
]
]
input[1] = file(params.modules_testdata_base_path + "genomics/sarscov2/metagenome/prot_names.dmp", checkIfExists: true)
input[2] = file(params.modules_testdata_base_path + "genomics/sarscov2/metagenome/prot_nodes.dmp", checkIfExists: true)
input[3] = GUNZIP.out.gunzip.map{ it[1] }
input[4] = []
"""
}
}
}

when {
process {
"""
input[0] = [
[ id:'test' ],
[
file(params.modules_testdata_base_path + "genomics/sarscov2/genome/genome.fasta", checkIfExists: true),
file(params.modules_testdata_base_path + "genomics/sarscov2/genome/proteome.fasta", checkIfExists: true)
]
]
input[1] = file(params.modules_testdata_base_path + "genomics/sarscov2/metagenome/prot_names.dmp", checkIfExists: true)
input[2] = file(params.modules_testdata_base_path + "genomics/sarscov2/metagenome/prot_nodes.dmp", checkIfExists: true)
input[3] = GUNZIP.out.gunzip.map{ it[1] }
input[0] = KRAKEN2_ADD.out.db
input[1] = true
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert process.out.db.get(0).get(1) ==~ ".*/test" },
{ assert snapshot (
path("${process.out.db[0][1]}/hash.k2d"),
path("${process.out.db[0][1]}/taxo.k2d"),
file("${process.out.db[0][1]}/opts.k2d").name,
file("${process.out.db[0][1]}/unmapped.txt").name
).match()
}
)
}

}

test("sarscov2 protein_db") {
test("sarscov2 protein_db - customs seqid2taxid") {

setup {
run("KRAKEN2_ADD", alias: "KRAKEN2_ADD_SEQID2TAXID") {
script "modules/nf-core/kraken2/add/main.nf"
process {
"""
input[0] = [
[ id:'test' ],
[
file(params.modules_testdata_base_path + "genomics/sarscov2/genome/genome.fasta", checkIfExists: true),
file(params.modules_testdata_base_path + "genomics/sarscov2/genome/proteome.fasta", checkIfExists: true)
]
]
input[1] = file(params.modules_testdata_base_path + "genomics/sarscov2/metagenome/prot_names.dmp", checkIfExists: true)
input[2] = file(params.modules_testdata_base_path + "genomics/sarscov2/metagenome/prot_nodes.dmp", checkIfExists: true)
input[3] = GUNZIP.out.gunzip.map{ it[1] }
input[4] = file(params.modules_testdata_base_path + "genomics/sarscov2/metagenome/prot_seqid2taxid.map", checkIfExists: true)
"""
}
}
}

when {
process {
"""
input[0] = KRAKEN2_ADD.out.db
input[1] = true
input[0] = KRAKEN2_ADD_SEQID2TAXID.out.db
input[1] = false
"""
}
}
Expand All @@ -79,10 +131,31 @@ nextflow_process {

options "-stub"

setup {
run("KRAKEN2_ADD", alias: "KRAKEN2_ADD_STUB") {
script "modules/nf-core/kraken2/add/main.nf"
process {
"""
input[0] = [
[ id:'test' ],
[
file(params.modules_testdata_base_path + "genomics/sarscov2/genome/genome.fasta", checkIfExists: true),
file(params.modules_testdata_base_path + "genomics/sarscov2/genome/proteome.fasta", checkIfExists: true)
]
]
input[1] = file(params.modules_testdata_base_path + "genomics/sarscov2/metagenome/prot_names.dmp", checkIfExists: true)
input[2] = file(params.modules_testdata_base_path + "genomics/sarscov2/metagenome/prot_nodes.dmp", checkIfExists: true)
input[3] = GUNZIP.out.gunzip.map{ it[1] }
input[4] = []
"""
}
}
}

when {
process {
"""
input[0] = KRAKEN2_ADD.out.db
input[0] = KRAKEN2_ADD_STUB.out.db
input[1] = true
"""
}
Expand Down
13 changes: 13 additions & 0 deletions modules/nf-core/kraken2/build/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
},
"timestamp": "2024-03-22T08:10:48.644001909"
},
"sarscov2 protein_db - customs seqid2taxid": {
"content": [
"hash.k2d:md5,e9984a5e98f87c0488cb5e7618d5bbe0",
"taxo.k2d:md5,29d65b1796e09191fd7bdcaa24130459",
"opts.k2d",
"unmapped.txt"
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-02-28T22:10:42.78489845"
},
"sarscov2 protein_db stub": {
"content": [
{
Expand Down
2 changes: 1 addition & 1 deletion subworkflows/nf-core/fasta_build_add_kraken2/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ workflow FASTA_BUILD_ADD_KRAKEN2 {

ch_versions = Channel.empty()

KRAKEN2_ADD ( ch_fasta, ch_taxonomy_names, ch_taxonomy_nodes, ch_accession2taxid )
KRAKEN2_ADD ( ch_fasta, ch_taxonomy_names, ch_taxonomy_nodes, ch_accession2taxid, [] )
ch_versions = ch_versions.mix(KRAKEN2_ADD.out.versions.first())

KRAKEN2_BUILD ( KRAKEN2_ADD.out.db, val_cleanintermediate )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ workflow FASTA_BUILD_ADD_KRAKEN2_BRACKEN {

ch_versions = Channel.empty()

KRAKEN2_ADD ( ch_fasta, ch_taxonomy_names, ch_taxonomy_nodes, ch_accession2taxid )
KRAKEN2_ADD ( ch_fasta, ch_taxonomy_names, ch_taxonomy_nodes, ch_accession2taxid, [] )
ch_versions = ch_versions.mix( KRAKEN2_ADD.out.versions.first() )

KRAKEN2_BUILD ( KRAKEN2_ADD.out.db, val_cleanup )
Expand Down
Loading