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

Migrate bundle/recognize module to scilpy 2.0.0 + nf-test #134

Merged
merged 2 commits into from
Apr 29, 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
7 changes: 7 additions & 0 deletions modules/nf-scil/bundle/recognize/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: "bundle_recognize"
channels:
- Docker
- Apptainer
dependencies:
- "Scilpy"
18 changes: 9 additions & 9 deletions modules/nf-scil/bundle/recognize/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ process BUNDLE_RECOGNIZE {
label 'process_single'

container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://scil.usherbrooke.ca/containers/scilus_1.6.0.sif':
'scilus/scilus:1.6.0' }"
'https://scil.usherbrooke.ca/containers/scilus_2.0.0.sif':
'scilus/scilus:2.0.0' }"

input:
tuple val(meta), path(tractograms), path(transform), path(config), path(directory)
Expand All @@ -26,33 +26,33 @@ process BUNDLE_RECOGNIZE {
def outlier_alpha = task.ext.outlier_alpha ? "--alpha " + task.ext.outlier_alpha : ""
"""
mkdir recobundles/
scil_recognize_multi_bundles.py ${tractograms} ${config} ${directory}/ ${transform} --inverse --out_dir recobundles/ \
--log_level DEBUG $minimal_vote_ratio $seed $rbx_processes
scil_tractogram_segment_bundles.py ${tractograms} ${config} ${directory}/ ${transform} --inverse --out_dir recobundles/ \
-v DEBUG $minimal_vote_ratio $seed $rbx_processes

for bundle_file in recobundles/*.trk; do
bname=\$(basename \${bundle_file} .trk)
out_cleaned=${prefix}__\${bname}_cleaned.trk
scil_outlier_rejection.py \${bundle_file} "\${out_cleaned}" ${outlier_alpha}
scil_bundle_reject_outliers.py \${bundle_file} "\${out_cleaned}" ${outlier_alpha}
done

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 1.6.0
scilpy: 2.0.0
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
scil_recognize_multi_bundles.py -h
scil_outlier_rejection.py -h
scil_tractogram_segment_bundles.py -h
scil_bundle_reject_outliers.py -h

# dummy output for single bundle
touch ${prefix}__AF_L_cleaned.trk

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 1.6.0
scilpy: 2.0.0
END_VERSIONS
"""
}
85 changes: 85 additions & 0 deletions modules/nf-scil/bundle/recognize/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "bundle"
tag "bundle/recognize"

tag "subworkflows"
tag "subworkflows/load_test_data"

setup {
run("LOAD_TEST_DATA", alias: "LOAD_DATA") {
script "../../../../../subworkflows/nf-scil/load_test_data/main.nf"
process {
"""
input[0] = Channel.from( [ "bundles.zip" ] )
input[1] = "test.load-test-data"
"""
}
}
}

test("bundle - recognize - base") {

config "./nextflow.config"

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}/bundle_all_1mm.trk"),
file("\${test_data_directory}/affine.txt"),
file("\${test_data_directory}/config.json"),
file("\${test_data_directory}/fibercup_atlas/")
]
}
"""
}
}

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

}

test("bundle - recognize - params") {

config "./nextflow_params.config"

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}/bundle_all_1mm.trk"),
file("\${test_data_directory}/affine.txt"),
file("\${test_data_directory}/config.json"),
file("\${test_data_directory}/fibercup_atlas/")
]
}
"""
}
}

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

}

}
96 changes: 96 additions & 0 deletions modules/nf-scil/bundle/recognize/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"bundle - recognize - params": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false
},
[
"test__bundle_1_cleaned.trk:md5,4f5cb88d05f175d6b55509d0ad307ab3",
"test__bundle_2_cleaned.trk:md5,58b4c1381603d72ad6e72cc705b4606e",
"test__bundle_3_cleaned.trk:md5,8f24a8c534b6e2386bcc755bd8f0c4b9",
"test__bundle_4_cleaned.trk:md5,eafac0796051d6ada4bfc5a5c576c536",
"test__bundle_5_cleaned.trk:md5,0d512bcaaf49325415a1f4860a167f5e"
]
]
],
"1": [
"versions.yml:md5,33bf1f04d87c84bb617311a892ba882a"
],
"bundles": [
[
{
"id": "test",
"single_end": false
},
[
"test__bundle_1_cleaned.trk:md5,4f5cb88d05f175d6b55509d0ad307ab3",
"test__bundle_2_cleaned.trk:md5,58b4c1381603d72ad6e72cc705b4606e",
"test__bundle_3_cleaned.trk:md5,8f24a8c534b6e2386bcc755bd8f0c4b9",
"test__bundle_4_cleaned.trk:md5,eafac0796051d6ada4bfc5a5c576c536",
"test__bundle_5_cleaned.trk:md5,0d512bcaaf49325415a1f4860a167f5e"
]
]
],
"versions": [
"versions.yml:md5,33bf1f04d87c84bb617311a892ba882a"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-24T10:58:28.42142"
},
"bundle - recognize - base": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false
},
[
"test__bundle_1_cleaned.trk:md5,6a5c47dccc9f51087572a8de006183ae",
"test__bundle_2_cleaned.trk:md5,08e2bd3fe0432d4dd58b7db771c8080d",
"test__bundle_3_cleaned.trk:md5,313c4401e7771a966c26be3f73ea7730",
"test__bundle_4_cleaned.trk:md5,b2e8e5a6b9077d6a36552b6bfa579de4",
"test__bundle_5_cleaned.trk:md5,3b975ace291d6fd4fd434ce37cc2263a"
]
]
],
"1": [
"versions.yml:md5,33bf1f04d87c84bb617311a892ba882a"
],
"bundles": [
[
{
"id": "test",
"single_end": false
},
[
"test__bundle_1_cleaned.trk:md5,6a5c47dccc9f51087572a8de006183ae",
"test__bundle_2_cleaned.trk:md5,08e2bd3fe0432d4dd58b7db771c8080d",
"test__bundle_3_cleaned.trk:md5,313c4401e7771a966c26be3f73ea7730",
"test__bundle_4_cleaned.trk:md5,b2e8e5a6b9077d6a36552b6bfa579de4",
"test__bundle_5_cleaned.trk:md5,3b975ace291d6fd4fd434ce37cc2263a"
]
]
],
"versions": [
"versions.yml:md5,33bf1f04d87c84bb617311a892ba882a"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-24T10:55:40.819871"
}
}
5 changes: 5 additions & 0 deletions modules/nf-scil/bundle/recognize/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: "BUNDLE_RECOGNIZE" {
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
process {
withName: "BUNDLE_RECOGNIZE" {
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }
}

withName: "BUNDLE_RECOGNIZE_PARAMS" {
ext.minimal_vote_ratio = 0.6
ext.seed = 1234
ext.outlier_alpha = 0.4
}
}
}
2 changes: 2 additions & 0 deletions modules/nf-scil/bundle/recognize/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bundle/recognize:
- "modules/nf-scil/bundle/recognize/**"
3 changes: 0 additions & 3 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ betcrop/cropvolume:
betcrop/fslbetcrop:
- modules/nf-scil/betcrop/fslbetcrop/**
- tests/modules/nf-scil/betcrop/fslbetcrop/**
bundle/recognize:
- modules/nf-scil/bundle/recognize/**
- tests/modules/nf-scil/bundle/recognize/**
denoising/mppca:
- modules/nf-scil/denoising/mppca/**
- tests/modules/nf-scil/denoising/mppca/**
Expand Down
44 changes: 0 additions & 44 deletions tests/modules/nf-scil/bundle/recognize/main.nf

This file was deleted.

35 changes: 0 additions & 35 deletions tests/modules/nf-scil/bundle/recognize/test.yml

This file was deleted.

Loading