Skip to content

Commit

Permalink
nf-test for ashlar (#6931)
Browse files Browse the repository at this point in the history
* nf-test for ashlar

* Update modules/nf-core/ashlar/main.nf

Co-authored-by: Simon Pearce <[email protected]>

* added multiple tests

* pin tifffile version

---------

Co-authored-by: Simon Pearce <[email protected]>
  • Loading branch information
kbestak and SPPearce authored Nov 14, 2024
1 parent 0e2d0c6 commit 7548250
Show file tree
Hide file tree
Showing 9 changed files with 348 additions and 146 deletions.
1 change: 1 addition & 0 deletions modules/nf-core/ashlar/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ channels:
- bioconda
dependencies:
- bioconda::ashlar=1.18.0
- tifffile=2024.1.30
20 changes: 20 additions & 0 deletions modules/nf-core/ashlar/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,24 @@ process ASHLAR {
ashlar: \$(ashlar --version | sed 's/^.*ashlar //' )
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
def num_files = images instanceof List ? images.size() : 1
def opt_dfp_size = opt_dfp instanceof List ? opt_dfp.size() : 1
def opt_ffp_size = opt_ffp instanceof List ? opt_ffp.size() : 1
def dfp_validated = (opt_dfp_size == 0 || opt_dfp_size == 1 || opt_dfp_size == num_files) ? true : false
def ffp_validated = (opt_ffp_size == 0 || opt_ffp_size == 1 || opt_ffp_size == num_files) ? true : false

if ( !dfp_validated ) { error "Please input only zero, one, or N dfp files, where N is the number of input images" }
if ( !ffp_validated ) { error "Please input only zero, one, or N ffp files, where N is the number of input images" }

"""
touch ${prefix}.ome.tif
cat <<-END_VERSIONS > versions.yml
"${task.process}":
ashlar: \$(ashlar --version | sed 's/^.*ashlar //' )
END_VERSIONS
"""
}
155 changes: 155 additions & 0 deletions modules/nf-core/ashlar/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "ashlar"

test("ashlar - with fields") {

when {
process {
"""
input[0] = [
[ id:'test_all' ],
file(params.modules_testdata_base_path + 'imaging/ome-tiff/cycif-tonsil-cycle1.ome.tif', checkIfExists: true)
]
input[1] = [
file(params.modules_testdata_base_path + 'imaging/ome-tiff/cycif-tonsil-dfp.ome.tif', checkIfExists: true)
]
input[2] = [
file(params.modules_testdata_base_path + 'imaging/ome-tiff/cycif-tonsil-ffp.ome.tif', checkIfExists: true)
]
"""
}
}

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

}

test("ashlar - 1 cycle - ome-tif") {

when {
process {
"""
input[0] = [
[ id:'test_1' ],
file(params.modules_testdata_base_path + 'imaging/ome-tiff/cycif-tonsil-cycle1.ome.tif', checkIfExists: true)
]
input[1] = []
input[2] = []
"""
}
}

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

}

test("ashlar - all cycles - ome-tif") {

when {
process {
"""
input[0] = [
[ id:'test_1' ],
[
file(params.modules_testdata_base_path + 'imaging/ome-tiff/cycif-tonsil-cycle1.ome.tif', checkIfExists: true),
file(params.modules_testdata_base_path + 'imaging/ome-tiff/cycif-tonsil-cycle2.ome.tif', checkIfExists: true),
file(params.modules_testdata_base_path + 'imaging/ome-tiff/cycif-tonsil-cycle3.ome.tif', checkIfExists: true)
]
]
input[1] = []
input[2] = []
"""
}
}

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

}

test("ashlar - all cycles - with fields - ome-tif") {

when {
process {
"""
input[0] = [
[ id:'test_1' ],
[
file(params.modules_testdata_base_path + 'imaging/ome-tiff/cycif-tonsil-cycle1.ome.tif', checkIfExists: true),
file(params.modules_testdata_base_path + 'imaging/ome-tiff/cycif-tonsil-cycle2.ome.tif', checkIfExists: true),
file(params.modules_testdata_base_path + 'imaging/ome-tiff/cycif-tonsil-cycle3.ome.tif', checkIfExists: true)
]
]
input[1] = [
file(params.modules_testdata_base_path + 'imaging/ome-tiff/cycif-tonsil-dfp.ome.tif', checkIfExists: true)
]
input[2] = [
file(params.modules_testdata_base_path + 'imaging/ome-tiff/cycif-tonsil-ffp.ome.tif', checkIfExists: true)
]
"""
}
}

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

}

test("ashlar - with fields - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test_all' ],
file(params.modules_testdata_base_path + 'imaging/ome-tiff/cycif-tonsil-cycle1.ome.tif', checkIfExists: true)
]
input[1] = [
file(params.modules_testdata_base_path + 'imaging/ome-tiff/cycif-tonsil-dfp.ome.tif', checkIfExists: true)
]
input[2] = [
file(params.modules_testdata_base_path + 'imaging/ome-tiff/cycif-tonsil-ffp.ome.tif', checkIfExists: true)
]
"""
}
}

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

}

}
167 changes: 167 additions & 0 deletions modules/nf-core/ashlar/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
{
"ashlar - with fields - stub": {
"content": [
{
"0": [
[
{
"id": "test_all"
},
"test_all.ome.tif:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
"versions.yml:md5,d5b1baeee01093ff65d37e155c9ce462"
],
"tif": [
[
{
"id": "test_all"
},
"test_all.ome.tif:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,d5b1baeee01093ff65d37e155c9ce462"
]
}
],
"meta": {
"nf-test": "0.9.1",
"nextflow": "24.10.0"
},
"timestamp": "2024-11-04T13:32:44.241620025"
},
"ashlar - 1 cycle - ome-tif": {
"content": [
{
"0": [
[
{
"id": "test_1"
},
"test_1.ome.tif:md5,988bbb2c74d47dc22a9f3ac348f53ef5"
]
],
"1": [
"versions.yml:md5,d5b1baeee01093ff65d37e155c9ce462"
],
"tif": [
[
{
"id": "test_1"
},
"test_1.ome.tif:md5,988bbb2c74d47dc22a9f3ac348f53ef5"
]
],
"versions": [
"versions.yml:md5,d5b1baeee01093ff65d37e155c9ce462"
]
}
],
"meta": {
"nf-test": "0.9.1",
"nextflow": "24.10.0"
},
"timestamp": "2024-11-06T11:13:49.614970275"
},
"ashlar - with fields": {
"content": [
{
"0": [
[
{
"id": "test_all"
},
"test_all.ome.tif:md5,988bbb2c74d47dc22a9f3ac348f53ef5"
]
],
"1": [
"versions.yml:md5,d5b1baeee01093ff65d37e155c9ce462"
],
"tif": [
[
{
"id": "test_all"
},
"test_all.ome.tif:md5,988bbb2c74d47dc22a9f3ac348f53ef5"
]
],
"versions": [
"versions.yml:md5,d5b1baeee01093ff65d37e155c9ce462"
]
}
],
"meta": {
"nf-test": "0.9.1",
"nextflow": "24.10.0"
},
"timestamp": "2024-11-04T13:28:26.923837754"
},
"ashlar - all cycles - ome-tif": {
"content": [
{
"0": [
[
{
"id": "test_1"
},
"test_1.ome.tif:md5,c01dda923325588ea34a4fe341b17e6e"
]
],
"1": [
"versions.yml:md5,d5b1baeee01093ff65d37e155c9ce462"
],
"tif": [
[
{
"id": "test_1"
},
"test_1.ome.tif:md5,c01dda923325588ea34a4fe341b17e6e"
]
],
"versions": [
"versions.yml:md5,d5b1baeee01093ff65d37e155c9ce462"
]
}
],
"meta": {
"nf-test": "0.9.1",
"nextflow": "24.10.0"
},
"timestamp": "2024-11-06T11:14:14.530220621"
},
"ashlar - all cycles - with fields - ome-tif": {
"content": [
{
"0": [
[
{
"id": "test_1"
},
"test_1.ome.tif:md5,c01dda923325588ea34a4fe341b17e6e"
]
],
"1": [
"versions.yml:md5,d5b1baeee01093ff65d37e155c9ce462"
],
"tif": [
[
{
"id": "test_1"
},
"test_1.ome.tif:md5,c01dda923325588ea34a4fe341b17e6e"
]
],
"versions": [
"versions.yml:md5,d5b1baeee01093ff65d37e155c9ce462"
]
}
],
"meta": {
"nf-test": "0.9.1",
"nextflow": "24.10.0"
},
"timestamp": "2024-11-06T11:14:56.268009236"
}
}
5 changes: 5 additions & 0 deletions modules/nf-core/ashlar/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: ASHLAR_TILE {
ext.args = "--tile-size 512"
}
}
3 changes: 0 additions & 3 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ artic/minion:
ascat:
- modules/nf-core/ascat/**
- tests/modules/nf-core/ascat/**
ashlar:
- modules/nf-core/ashlar/**
- tests/modules/nf-core/ashlar/**
ataqv/ataqv:
- modules/nf-core/ataqv/ataqv/**
- tests/modules/nf-core/ataqv/ataqv/**
Expand Down
Loading

0 comments on commit 7548250

Please sign in to comment.