Skip to content

Commit

Permalink
Allow Metabat2 to take uncompressed depths file and bump version (nf-…
Browse files Browse the repository at this point in the history
…core#7230)

* Metabat2 takes uncompressed depths file

* Update main.nf.test

* Update main.nf

* Update environment.yml

* update snapshot

* Move shared setup outside of test blocks to facilitate reuse, switch to regex for cleaning depths
  • Loading branch information
prototaxites authored Dec 19, 2024
1 parent 8581a56 commit cc217b9
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 27 deletions.
2 changes: 1 addition & 1 deletion modules/nf-core/metabat2/metabat2/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ channels:
- conda-forge
- bioconda
dependencies:
- bioconda::metabat2=2.15
- bioconda::metabat2=2.17
13 changes: 7 additions & 6 deletions modules/nf-core/metabat2/metabat2/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ process METABAT2_METABAT2 {

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/metabat2:2.15--h986a166_1' :
'biocontainers/metabat2:2.15--h986a166_1' }"
'https://depot.galaxyproject.org/singularity/metabat2:2.17--hd498684_0' :
'biocontainers/metabat2:2.17--hd498684_0' }"

input:
tuple val(meta), path(fasta), path(depth)
Expand All @@ -24,15 +24,16 @@ process METABAT2_METABAT2 {
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def decompress_depth = depth ? "gzip -d -f $depth" : ""
def depth_file = depth ? "-a ${depth.baseName}" : ""
def clean_depth = depth.toString() - ~/\.gz$/
def decompress_depth = (depth && depth.toString() != clean_depth) ? "gzip -d -f $depth" : ""
def depth_input = depth ? "-a ${clean_depth}" : ""
"""
$decompress_depth
metabat2 \\
$args \\
${args} \\
-i $fasta \\
$depth_file \\
${depth_input} \\
-t $task.cpus \\
--saveCls \\
-o ${prefix}
Expand Down
58 changes: 45 additions & 13 deletions modules/nf-core/metabat2/metabat2/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,35 @@ nextflow_process {

tag "modules"
tag "modules_nfcore"
tag "gunzip"
tag "metabat2"
tag "metabat2/metabat2"
tag "metabat2/jgisummarizebamcontigdepths"

setup {
run("METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS") {
script "../../jgisummarizebamcontigdepths/main.nf"
process {
"""
input[0] = [
[id: 'test', single_end: false],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true),
]
"""
}
}

run("GUNZIP") {
script "../../../gunzip/main.nf"
process {
"""
input[0] = METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS.out.depth
"""
}
}
}

test("sarscov2 - genome - fasta") {

when {
Expand All @@ -36,28 +61,35 @@ nextflow_process {

test("sarscov2 - genome - fasta - depths") {

setup {
run("METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS") {
script "../../jgisummarizebamcontigdepths/main.nf"
process {
"""
input[0] = [
[id: 'test', single_end: false],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true),
]
"""
}
when {
process {
"""
input[0] = Channel
.fromPath(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
.map { it -> [[ id:'test', single_end:false ], it] }
.join(METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS.out.depth)
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(file(process.out.membership[0][1]).name).match() }
)
}

}

test("sarscov2 - genome - fasta - depths uncompressed") {

when {
process {
"""
input[0] = Channel
.fromPath(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
.map { it -> [[ id:'test', single_end:false ], it] }
.join(METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS.out.depth)
.join(GUNZIP.out.gunzip)
"""
}
}
Expand Down
24 changes: 17 additions & 7 deletions modules/nf-core/metabat2/metabat2/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

],
"5": [
"versions.yml:md5,872d18278c2ba7812c62a8bc6b2120eb"
"versions.yml:md5,f5ad39cc43905d8b2c61bf04772a1bda"
],
"fasta": [

Expand All @@ -48,15 +48,25 @@

],
"versions": [
"versions.yml:md5,872d18278c2ba7812c62a8bc6b2120eb"
"versions.yml:md5,f5ad39cc43905d8b2c61bf04772a1bda"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.2"
},
"timestamp": "2024-12-11T12:28:01.970872008"
"timestamp": "2024-12-16T18:47:12.382730533"
},
"sarscov2 - genome - fasta - depths uncompressed": {
"content": [
"test.tsv.gz"
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.2"
},
"timestamp": "2024-12-16T17:07:33.15263136"
},
"sarscov2 - genome - fasta - depths": {
"content": [
Expand All @@ -66,7 +76,7 @@
"nf-test": "0.9.2",
"nextflow": "24.10.2"
},
"timestamp": "2024-12-11T13:08:47.777561763"
"timestamp": "2024-12-16T17:07:19.028059191"
},
"sarscov2 - genome - fasta - stub": {
"content": [
Expand Down Expand Up @@ -117,7 +127,7 @@
]
],
"5": [
"versions.yml:md5,872d18278c2ba7812c62a8bc6b2120eb"
"versions.yml:md5,f5ad39cc43905d8b2c61bf04772a1bda"
],
"fasta": [
[
Expand Down Expand Up @@ -165,14 +175,14 @@
]
],
"versions": [
"versions.yml:md5,872d18278c2ba7812c62a8bc6b2120eb"
"versions.yml:md5,f5ad39cc43905d8b2c61bf04772a1bda"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.2"
},
"timestamp": "2024-12-11T12:28:32.122007408"
"timestamp": "2024-12-16T18:48:01.719015314"
}
}

0 comments on commit cc217b9

Please sign in to comment.