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 in stub of betcrop/fslbetcrop #69

Merged
merged 2 commits into from
Dec 18, 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
20 changes: 13 additions & 7 deletions modules/nf-neuro/betcrop/fslbetcrop/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,9 @@ process BETCROP_FSLBETCROP {
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

"""
scil_dwi_extract_b0.py -h
bet -h
scil_volume_math.py -h
mrcalc -h
scil_volume_crop.py -h

touch ${prefix}__image_bet.nii.gz
touch ${prefix}__image_bet_mask.nii.gz
touch ${prefix}__image_boundingBox.pkl
Expand All @@ -89,5 +82,18 @@ process BETCROP_FSLBETCROP {
mrtrix: \$(mrcalc -version 2>&1 | sed -n 's/== mrcalc \\([0-9.]\\+\\).*/\\1/p')
fsl: \$(flirt -version 2>&1 | sed -n 's/FLIRT version \\([0-9.]\\+\\)/\\1/p')
END_VERSIONS

function handle_code () {
local code=\$?
ignore=( 1 )
exit \$([[ " \${ignore[@]} " =~ " \$code " ]] && echo 0 || echo \$code)
}
trap 'handle_code' ERR

bet
scil_dwi_extract_b0.py -h
scil_volume_math.py -h
mrcalc -h
scil_volume_crop.py -h
"""
}
28 changes: 28 additions & 0 deletions modules/nf-neuro/betcrop/fslbetcrop/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,32 @@ nextflow_process {

}

test("betcrop - fslbetcrop - stub-run") {

options "-stub-run"

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}/dwi/dwi.nii.gz"),
file("\${test_data_directory}/dwi/dwi.bval"),
file("\${test_data_directory}/dwi/dwi.bvec")
]
}
"""
}
}

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

}

}
12 changes: 12 additions & 0 deletions modules/nf-neuro/betcrop/fslbetcrop/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
{
"betcrop - fslbetcrop - stub-run": {
"content": [
[
"versions.yml:md5,cc45ab23921525536874337c1c88e5cf"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.1"
},
"timestamp": "2024-12-12T10:33:04.50811"
},
"betcrop - fslbetcrop - dwi": {
"content": [
{
Expand Down
Loading