Skip to content

Commit

Permalink
Swap unzip to nf-test (continuation of 5357) (#5897)
Browse files Browse the repository at this point in the history
* unzip stub, nf-test, snap

* Revert "unzip stub, nf-test, snap"

This reverts commit dec35aa.

* Reapply "unzip stub, nf-test, snap"

This reverts commit e0d708e.

* added minimal required tests for process and stub

* added snapshot

* simplify snapshot input in stub test

Co-authored-by: Matthias Hörtenhuber <mashehu@users.noreply.github.com>

* remove unneeded stub files

* migrate pytest for unzipfiles

* add snapshot file for script block

* added stub

* added stub and stub test

* updated stub snapshot for unzip

* remove unneeded test config

* Update snaps and malt

* Update malt for linting

* Fix linting for maltextract

* Swap test-data paths for malt modules

* Update modules/nf-core/maltextract/tests/main.nf.test

---------

Co-authored-by: Sateesh <perisateesh@gmail.com>
Co-authored-by: Jenny Leopoldina Smith <jennyl.smith12@gmail.com>
Co-authored-by: Matthias Hörtenhuber <mashehu@users.noreply.github.com>
Co-authored-by: Maxime U Garcia <max.u.garcia@gmail.com>
  • Loading branch information
5 people authored Jul 16, 2024
1 parent 96e59e7 commit b0c3ff2
Show file tree
Hide file tree
Showing 22 changed files with 327 additions and 104 deletions.
7 changes: 4 additions & 3 deletions modules/nf-core/malt/build/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ nextflow_process {
when {
process {
"""
input[0] = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
input[0] = file(params.modules_testdata_base_path + "genomics/sarscov2/genome/genome.fasta", checkIfExists: true)
input[1] = []
input[2] = UNZIP.out.unzipped_archive.map { it[1] }
"""
Expand All @@ -45,7 +45,8 @@ nextflow_process {
path("${process.out.index[0]}/ref.inf"),
path("${process.out.index[0]}/taxonomy.idx"),
path("${process.out.index[0]}/taxonomy.map"),
path("${process.out.index[0]}/taxonomy.tre")
path("${process.out.index[0]}/taxonomy.tre"),
process.out.versions
)
.match()
},
Expand All @@ -64,7 +65,7 @@ nextflow_process {
when {
process {
"""
input[0] = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
input[0] = file(params.modules_testdata_base_path + "genomics/sarscov2/genome/genome.fasta", checkIfExists: true)
input[1] = []
input[2] = UNZIP.out.unzipped_archive.map { it[1] }
"""
Expand Down
15 changes: 13 additions & 2 deletions modules/nf-core/malt/build/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-01-26T11:49:19.685017271"
},
"sarscov2 - fastq": {
Expand All @@ -36,8 +40,15 @@
"ref.inf:md5,b146842067cf278ef1d23e6c2e7c0c35",
"taxonomy.idx:md5,bb335e7c378a5bd85761b6eeed16d984",
"taxonomy.map:md5,5bb3f2192e925bca2e61e4b54f1671e0",
"taxonomy.tre:md5,f76fb2d5aa9b0d637234d48175841e0e"
"taxonomy.tre:md5,f76fb2d5aa9b0d637234d48175841e0e",
[
"versions.yml:md5,52c299d59c90219b9b442ee54f1acc97"
]
],
"timestamp": "2024-01-26T11:48:45.195850552"
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-30T19:04:45.72181253"
}
}
2 changes: 1 addition & 1 deletion modules/nf-core/malt/run/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ output:
type: file
description: MEGAN6 RMA6 file
pattern: "*.rma6"
- sam:
- alignments:
type: file
description: Alignment files in Tab, Text or MEGAN-compatible SAM format
pattern: "*.{tab,txt,sam}"
Expand Down
9 changes: 4 additions & 5 deletions modules/nf-core/malt/run/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// TODO nf-core: Once you have added the required tests, please run the following command to build this file:
// nf-core modules test malt/run
nextflow_process {

name "Test Process MALT_RUN"
Expand Down Expand Up @@ -27,7 +25,7 @@ nextflow_process {
script "../../../malt/build/main.nf"
process {
"""
input[0] = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
input[0] = file(params.modules_testdata_base_path + "genomics/sarscov2/genome/genome.fasta", checkIfExists: true)
input[1] = []
input[2] = UNZIP.out.unzipped_archive.map { it[1] }
"""
Expand All @@ -43,7 +41,7 @@ nextflow_process {
input[0] = [
[ id:'test_1', single_end:false ],
[
file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true)
file(params.modules_testdata_base_path + "genomics/sarscov2/illumina/fastq/test_1.fastq.gz", checkIfExists: true)
]
]
input[1] = MALT_BUILD.out.index
Expand All @@ -56,6 +54,7 @@ nextflow_process {
{ assert process.success },
{ assert snapshot(
process.out.alignments,
process.out.versions,
file(process.out.rma6[0][1]).name
).match()
},
Expand All @@ -75,7 +74,7 @@ nextflow_process {
input[0] = [
[ id:'test_1', single_end:false ],
[
file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true)
file(params.modules_testdata_base_path + "genomics/sarscov2/illumina/fastq/test_1.fastq.gz", checkIfExists: true)
]
]
input[1] = MALT_BUILD.out.index
Expand Down
13 changes: 12 additions & 1 deletion modules/nf-core/malt/run/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-01-26T14:15:43.18685293"
},
"sarscov2 - fastq": {
Expand All @@ -77,8 +81,15 @@
"test_1.blastn.sam.gz:md5,8ad56803c1674e1a8cd42fe8801e71fd"
]
],
[
"versions.yml:md5,5b91a785e0342f9ef17a634c0452335a"
],
"test_1.rma6"
],
"timestamp": "2024-01-26T14:15:08.880645244"
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-30T07:04:07.674069223"
}
}
15 changes: 7 additions & 8 deletions modules/nf-core/maltextract/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ nextflow_process {
script "../../unzip/main.nf"
process {
"""
input[0] = [[], file('https://github.com/nf-core/test-datasets/raw/modules/data/genomics/sarscov2/genome/db/maltextract/ncbi_taxmap.zip')]
input[0] = [[], file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/db/maltextract/ncbi_taxmap.zip')]
"""
}
}
Expand All @@ -25,8 +25,9 @@ nextflow_process {
process {
"""
input[0] = [ [], // meta map
file('https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/malt/test.rma6') ]
input[1] = file('https://github.com/nf-core/test-datasets/raw/modules/data/genomics/sarscov2/genome/db/maltextract/taxon_list.txt')
file(params.modules_testdata_base_path + 'delete_me/malt/test.rma6')
]
input[1] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/db/maltextract/taxon_list.txt')
input[2] = UNZIP.out.unzipped_archive.map { it[1] }
"""
}
Expand All @@ -35,12 +36,10 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match('version') },
// snapshots dont work, because the results channel contains a log file that changes with each run
{ assert snapshot(
path("${process.out.results.get(0).get(1)}/ScanSummary.txt"),
).match('results')
}
process.out.versions,
path("${process.out.results.get(0).get(1)}/ScanSummary.txt")
).match() },
)
}
}
Expand Down
17 changes: 4 additions & 13 deletions modules/nf-core/maltextract/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
{
"version": {
"test_maltextract": {
"content": [
[
"versions.yml:md5,4d87de5def1287321effde6545901cf6"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.0"
},
"timestamp": "2024-03-19T13:58:17.979106"
},
"results": {
"content": [
],
"ScanSummary.txt:md5,209fb35426f6a459db0f4af0dc544b10"
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.0"
"nextflow": "24.04.2"
},
"timestamp": "2024-03-19T14:03:56.643826"
"timestamp": "2024-07-01T08:19:20.696046683"
}
}
14 changes: 13 additions & 1 deletion modules/nf-core/unzip/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ process UNZIP {
script:
def args = task.ext.args ?: ''
if ( archive instanceof List && archive.name.size > 1 ) { error "[UNZIP] error: 7za only accepts a single archive as input. Please check module input." }

prefix = task.ext.prefix ?: ( meta.id ? "${meta.id}" : archive.baseName)
"""
7za \\
Expand All @@ -34,4 +33,17 @@ process UNZIP {
7za: \$(echo \$(7za --help) | sed 's/.*p7zip Version //; s/(.*//')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
if ( archive instanceof List && archive.name.size > 1 ) { error "[UNZIP] error: 7za only accepts a single archive as input. Please check module input." }
prefix = task.ext.prefix ?: ( meta.id ? "${meta.id}" : archive.baseName)
"""
mkdir "${prefix}"
cat <<-END_VERSIONS > versions.yml
"${task.process}":
7za: \$(echo \$(7za --help) | sed 's/.*p7zip Version //; s/(.*//')
END_VERSIONS
"""
}
54 changes: 54 additions & 0 deletions modules/nf-core/unzip/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "unzip"

test("generic [tar] [tar_gz]") {

when {
process {
"""
input[0] = [
[ id: 'hello' ],
file(params.modules_testdata_base_path + 'generic/tar/hello.tar.gz', checkIfExists: true)
]
"""
}
}

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

test("generic [tar] [tar_gz] stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id: 'hello' ],
file(params.modules_testdata_base_path + 'generic/tar/hello.tar.gz', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
76 changes: 76 additions & 0 deletions modules/nf-core/unzip/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"generic [tar] [tar_gz] stub": {
"content": [
{
"0": [
[
{
"id": "hello"
},
[

]
]
],
"1": [
"versions.yml:md5,52c55ce814e8bc9edc5a6c625ed794b8"
],
"unzipped_archive": [
[
{
"id": "hello"
},
[

]
]
],
"versions": [
"versions.yml:md5,52c55ce814e8bc9edc5a6c625ed794b8"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-30T19:16:37.11550986"
},
"generic [tar] [tar_gz]": {
"content": [
{
"0": [
[
{
"id": "hello"
},
[
"hello.tar:md5,80c66db79a773bc87b3346035ff9593e"
]
]
],
"1": [
"versions.yml:md5,52c55ce814e8bc9edc5a6c625ed794b8"
],
"unzipped_archive": [
[
{
"id": "hello"
},
[
"hello.tar:md5,80c66db79a773bc87b3346035ff9593e"
]
]
],
"versions": [
"versions.yml:md5,52c55ce814e8bc9edc5a6c625ed794b8"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-30T19:16:25.120242571"
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/unzip/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
unzip:
- "modules/nf-core/unzip/**"
12 changes: 12 additions & 0 deletions modules/nf-core/unzipfiles/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,16 @@ process UNZIPFILES {
7za: \$(echo \$(7za --help) | sed 's/.*p7zip Version //; s/(.*//')
END_VERSIONS
"""

stub:
prefix = task.ext.prefix ?: ( meta.id ? "${meta.id}" : archive.baseName)
"""
mkdir "${prefix}"
touch "${prefix}/hello.txt"
cat <<-END_VERSIONS > versions.yml
"${task.process}":
7za: \$(echo \$(7za --help) | sed 's/.*p7zip Version //; s/(.*//')
END_VERSIONS
"""
}
Loading

0 comments on commit b0c3ff2

Please sign in to comment.