From 4d1384b5ad82a85206479bfe1f47b6e2c72a07b8 Mon Sep 17 00:00:00 2001 From: Anthony Gagnon Date: Fri, 22 Nov 2024 17:10:25 +0000 Subject: [PATCH 1/2] add automatic shell detection if not provided in powder average + add tests --- modules/nf-neuro/image/powderaverage/main.nf | 2 +- .../image/powderaverage/tests/main.nf.test | 8 +++++--- .../powderaverage/tests/main.nf.test.snap | 20 +++++++++---------- .../tests/nextflow_noshells.config | 6 ++++++ ...nextflow.config => nextflow_shells.config} | 0 5 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 modules/nf-neuro/image/powderaverage/tests/nextflow_noshells.config rename modules/nf-neuro/image/powderaverage/tests/{nextflow.config => nextflow_shells.config} (100%) diff --git a/modules/nf-neuro/image/powderaverage/main.nf b/modules/nf-neuro/image/powderaverage/main.nf index e83c765..fabdb20 100644 --- a/modules/nf-neuro/image/powderaverage/main.nf +++ b/modules/nf-neuro/image/powderaverage/main.nf @@ -21,7 +21,7 @@ process IMAGE_POWDERAVERAGE { def prefix = task.ext.prefix ?: "${meta.id}" def b0_thr = task.ext.b0_thr ? "--b0_thr ${task.ext.b0_thr}" : '' - def shells = task.ext.shells ? "--shells ${task.ext.shells}" : '' + def shells = task.ext.shells ? "--shells ${task.ext.shells}" : "--shells \$(cut -d ' ' --output-delimiter=\$'\\n' -f 1- $bval | awk -F' ' '{v=int(\$1)}{print v}' | uniq)" def shell_thr = task.ext.shell_thr ? "--shell_thr ${task.ext.shell_thr}" : '' if ( mask ) args += "--mask ${mask}" diff --git a/modules/nf-neuro/image/powderaverage/tests/main.nf.test b/modules/nf-neuro/image/powderaverage/tests/main.nf.test index a5e46a5..edef057 100644 --- a/modules/nf-neuro/image/powderaverage/tests/main.nf.test +++ b/modules/nf-neuro/image/powderaverage/tests/main.nf.test @@ -24,7 +24,9 @@ nextflow_process { } } - test("powderaverage - no mask") { + test("powderaverage - no mask and no shell") { + + config "./nextflow_noshells.config" when { process { @@ -49,9 +51,9 @@ nextflow_process { } } - test("powderaverage - with mask") { + test("powderaverage - with mask and shells") { - config "./nextflow.config" + config "./nextflow_shells.config" when { process { diff --git a/modules/nf-neuro/image/powderaverage/tests/main.nf.test.snap b/modules/nf-neuro/image/powderaverage/tests/main.nf.test.snap index f3c724f..a9d2c44 100644 --- a/modules/nf-neuro/image/powderaverage/tests/main.nf.test.snap +++ b/modules/nf-neuro/image/powderaverage/tests/main.nf.test.snap @@ -1,5 +1,5 @@ { - "powderaverage - with mask": { + "powderaverage - with mask and shells": { "content": [ { "0": [ @@ -29,12 +29,12 @@ } ], "meta": { - "nf-test": "0.9.0-rc1", - "nextflow": "24.04.3" + "nf-test": "0.9.0", + "nextflow": "24.04.4" }, - "timestamp": "2024-07-26T12:43:21.971071" + "timestamp": "2024-11-22T17:09:05.483883967" }, - "powderaverage - no mask": { + "powderaverage - no mask and no shell": { "content": [ { "0": [ @@ -43,7 +43,7 @@ "id": "test", "single_end": false }, - "test_pwd_avg.nii.gz:md5,168d711e7b84fad327966ca3d49ede0f" + "test_pwd_avg.nii.gz:md5,274a0826747914aa457c5a5363abffe5" ] ], "1": [ @@ -55,7 +55,7 @@ "id": "test", "single_end": false }, - "test_pwd_avg.nii.gz:md5,168d711e7b84fad327966ca3d49ede0f" + "test_pwd_avg.nii.gz:md5,274a0826747914aa457c5a5363abffe5" ] ], "versions": [ @@ -64,9 +64,9 @@ } ], "meta": { - "nf-test": "0.9.0-rc1", - "nextflow": "24.04.3" + "nf-test": "0.9.0", + "nextflow": "24.04.4" }, - "timestamp": "2024-07-25T14:32:47.643306" + "timestamp": "2024-11-22T17:09:00.254000809" } } \ No newline at end of file diff --git a/modules/nf-neuro/image/powderaverage/tests/nextflow_noshells.config b/modules/nf-neuro/image/powderaverage/tests/nextflow_noshells.config new file mode 100644 index 0000000..ba09ca3 --- /dev/null +++ b/modules/nf-neuro/image/powderaverage/tests/nextflow_noshells.config @@ -0,0 +1,6 @@ +process { + withName: "IMAGE_POWDERAVERAGE" { + ext.b0_thr = 50 + ext.shell_thr = 50 + } +} diff --git a/modules/nf-neuro/image/powderaverage/tests/nextflow.config b/modules/nf-neuro/image/powderaverage/tests/nextflow_shells.config similarity index 100% rename from modules/nf-neuro/image/powderaverage/tests/nextflow.config rename to modules/nf-neuro/image/powderaverage/tests/nextflow_shells.config From 9146c628d9a47e36deb507ae026c96877b9db436 Mon Sep 17 00:00:00 2001 From: Anthony Gagnon Date: Fri, 22 Nov 2024 19:45:51 +0000 Subject: [PATCH 2/2] revert shell change, update version fetching --- modules/nf-neuro/image/powderaverage/main.nf | 6 +++--- .../nf-neuro/image/powderaverage/tests/main.nf.test.snap | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/nf-neuro/image/powderaverage/main.nf b/modules/nf-neuro/image/powderaverage/main.nf index fabdb20..445ffa2 100644 --- a/modules/nf-neuro/image/powderaverage/main.nf +++ b/modules/nf-neuro/image/powderaverage/main.nf @@ -21,7 +21,7 @@ process IMAGE_POWDERAVERAGE { def prefix = task.ext.prefix ?: "${meta.id}" def b0_thr = task.ext.b0_thr ? "--b0_thr ${task.ext.b0_thr}" : '' - def shells = task.ext.shells ? "--shells ${task.ext.shells}" : "--shells \$(cut -d ' ' --output-delimiter=\$'\\n' -f 1- $bval | awk -F' ' '{v=int(\$1)}{print v}' | uniq)" + def shells = task.ext.shells ? "--shells ${task.ext.shells}" : '' def shell_thr = task.ext.shell_thr ? "--shell_thr ${task.ext.shell_thr}" : '' if ( mask ) args += "--mask ${mask}" @@ -32,7 +32,7 @@ process IMAGE_POWDERAVERAGE { cat <<-END_VERSIONS > versions.yml "${task.process}": - scilpy: 2.0.2 + scilpy: \$(pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2) END_VERSIONS """ @@ -46,7 +46,7 @@ process IMAGE_POWDERAVERAGE { cat <<-END_VERSIONS > versions.yml "${task.process}": - scilpy: 2.0.2 + scilpy: \$(pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2) END_VERSIONS """ } diff --git a/modules/nf-neuro/image/powderaverage/tests/main.nf.test.snap b/modules/nf-neuro/image/powderaverage/tests/main.nf.test.snap index a9d2c44..befe54a 100644 --- a/modules/nf-neuro/image/powderaverage/tests/main.nf.test.snap +++ b/modules/nf-neuro/image/powderaverage/tests/main.nf.test.snap @@ -43,7 +43,7 @@ "id": "test", "single_end": false }, - "test_pwd_avg.nii.gz:md5,274a0826747914aa457c5a5363abffe5" + "test_pwd_avg.nii.gz:md5,168d711e7b84fad327966ca3d49ede0f" ] ], "1": [ @@ -55,7 +55,7 @@ "id": "test", "single_end": false }, - "test_pwd_avg.nii.gz:md5,274a0826747914aa457c5a5363abffe5" + "test_pwd_avg.nii.gz:md5,168d711e7b84fad327966ca3d49ede0f" ] ], "versions": [ @@ -67,6 +67,6 @@ "nf-test": "0.9.0", "nextflow": "24.04.4" }, - "timestamp": "2024-11-22T17:09:00.254000809" + "timestamp": "2024-11-22T19:45:06.796263708" } } \ No newline at end of file