Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#40 - Catch exit code error for betcrop/synthstrip + stub run test #70

Merged
merged 4 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions modules/nf-neuro/betcrop/synthbet/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,21 @@ 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

cat <<-END_VERSIONS > versions.yml
"${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
"""
}
37 changes: 34 additions & 3 deletions modules/nf-neuro/betcrop/synthbet/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -26,7 +25,6 @@ nextflow_process {
}
}
}

when {
process {
"""
Expand All @@ -40,12 +38,45 @@ nextflow_process {
"""
}
}

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

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() }
)
}
}
}
14 changes: 13 additions & 1 deletion modules/nf-neuro/betcrop/synthbet/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -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": [
{
Expand Down Expand Up @@ -52,4 +64,4 @@
},
"timestamp": "2024-11-25T18:19:01.459548926"
}
}
}
Loading