I’m submitting a module for nf-core (see PR). My nf-test takes the output file from my first module preparesegmentation
and uses it as input for my second module runsegmentationontile
. I have checked the nf-test docs on writing chained modules and am using a similar structure. Here is my test:
test("nuclei - json, images") {
setup {
run("VIZGENPOSTPROCESSING_PREPARESEGMENTATION") {
script "../../preparesegmentation/main.nf"
params {
module_args = '--tile-size 200 --tile-overlap 20'
}
process {
"""
// Create test directory and files before process execution
testDir = file("tmpdir", type: 'dir')
testDir.mkdir()
// Download source file
sourceUrl = 'https://github.com/nf-core/test-datasets/raw/modules/data/imaging/segmentation/nuclear_image.tif'
sourceFile = file(sourceUrl)
// Create renamed copies
sourceFile.copyTo(file("\${testDir}/mosaic_DAPI_z3.tif"))
sourceFile.copyTo(file("\${testDir}/mosaic_PolyT_z3.tif"))
// Create transform file
transformFile = file("\${testDir}/micron_to_mosaic_pixel_transform.csv")
transformFile.text = "2 0 0\\n0 2 0\\n0 0 1"
input[0] = [
[ id:'test' ],
testDir,
transformFile
]
input[1] = file('https://raw.githubusercontent.com/Vizgen/vpt-plugin-cellpose2/refs/heads/develop/example_analysis_algorithm/cellpose2_nuclei.json', checkIfExists: true)
input[2] = "mosaic_(?P<stain>[\\\\w|-]+)_z(?P<z>[0-9]+).tif"
"""
}
}
}
when {
process {
"""
input[0] = [
[ id:'test' ],
file("tmpdir", type: 'dir'),
VIZGENPOSTPROCESSING_PREPARESEGMENTATION.out.segmentation_files[0][1], // Segmentation parameters
0 // Tile index
]
input[1] = file('https://raw.githubusercontent.com/Vizgen/vpt-plugin-cellpose2/refs/heads/develop/example_analysis_algorithm/cellpose2_nuclei.json', checkIfExists: true)
input[2] = []
"""
}
}
However, I can’t seem to get the main nf-test to pass (see here):
Assertion failed:
assert process.success
| |
| false
VIZGENPOSTPROCESSING_RUNSEGMENTATIONONTILE
java.lang.RuntimeException: Process has no output channels. process.out can not be used.
and in my nextflow.log
:
ERROR ~ Unexpected error [StackOverflowError]
I can get the test to work by removing the setup block and using a config file on disk, so it is something to do with the module chaining. I know my first module works correctly and passes nf-test, creating the correct output file so I am quite puzzled by this error. I have also tried using map
and take
in case it was some issue with accessing the channel using [0]
, but this leads to the same issue. Any ideas?