diff --git a/modules/nf-neuro/betcrop/synthbet/main.nf b/modules/nf-neuro/betcrop/synthbet/main.nf index b122b226..cbbeddeb 100644 --- a/modules/nf-neuro/betcrop/synthbet/main.nf +++ b/modules/nf-neuro/betcrop/synthbet/main.nf @@ -40,8 +40,6 @@ process BETCROP_SYNTHBET { def prefix = task.ext.prefix ?: "${meta.id}" """ - mri_synthstrip -h - touch ${prefix}__bet_image.nii.gz touch ${prefix}__brain_mask.nii.gz @@ -49,5 +47,14 @@ process BETCROP_SYNTHBET { "${task.process}": Freesurfer: \$(mri_convert -version | grep "freesurfer" | sed -E 's/.* ([0-9]+\\.[0-9]+\\.[0-9]+).*/\\1/') END_VERSIONS + + function handle_code () { + local code=\$? + ignore=( 1 ) + exit \$([[ " \${ignore[@]} " =~ " \$code " ]] && echo 0 || echo \$code) + } + trap 'handle_code' ERR + + mri_synthstrip -h """ } diff --git a/modules/nf-neuro/betcrop/synthbet/tests/main.nf.test b/modules/nf-neuro/betcrop/synthbet/tests/main.nf.test index 6fae76ab..7e71d665 100644 --- a/modules/nf-neuro/betcrop/synthbet/tests/main.nf.test +++ b/modules/nf-neuro/betcrop/synthbet/tests/main.nf.test @@ -14,7 +14,6 @@ nextflow_process { tag "subworkflows/load_test_data" test("betcrop - synthbet") { - setup { run("LOAD_TEST_DATA", alias: "LOAD_DATA") { script "../../../../../subworkflows/nf-neuro/load_test_data/main.nf" @@ -26,7 +25,6 @@ nextflow_process { } } } - when { process { """ @@ -40,7 +38,6 @@ nextflow_process { """ } } - then { assertAll( { assert process.success }, @@ -48,4 +45,38 @@ nextflow_process { ) } } + + test("betcrop - synthbet - stub-run") { + options "-stub-run" + setup { + run("LOAD_TEST_DATA", alias: "LOAD_DATA") { + script "../../../../../subworkflows/nf-neuro/load_test_data/main.nf" + process { + """ + input[0] = Channel.from( [ "freesurfer.zip" ] ) + input[1] = "test.load-test-data" + """ + } + } + } + when { + process { + """ + input[0] = LOAD_DATA.out.test_data_directory.map{ + test_data_directory -> [ + [ id:'test', single_end:false ], // meta map + file("\${test_data_directory}/anat_image.nii.gz"), + [] + ] + } + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.versions).match() } + ) + } + } } diff --git a/modules/nf-neuro/betcrop/synthbet/tests/main.nf.test.snap b/modules/nf-neuro/betcrop/synthbet/tests/main.nf.test.snap index 8be3fb46..94588233 100644 --- a/modules/nf-neuro/betcrop/synthbet/tests/main.nf.test.snap +++ b/modules/nf-neuro/betcrop/synthbet/tests/main.nf.test.snap @@ -1,4 +1,16 @@ { + "betcrop - synthbet - stub-run": { + "content": [ + [ + "versions.yml:md5,c639461870ca534b5105f61d672f740f" + ] + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.10.1" + }, + "timestamp": "2024-12-12T10:54:37.644838" + }, "betcrop - synthbet": { "content": [ { @@ -52,4 +64,4 @@ }, "timestamp": "2024-11-25T18:19:01.459548926" } -} +} \ No newline at end of file