From e4551a9ab3bf4317a485ddfe0cd867b1a9baabb0 Mon Sep 17 00:00:00 2001 From: "Moritz E. Beber" Date: Wed, 11 May 2022 14:07:18 +0200 Subject: [PATCH] refactor: always output settings --- modules/sratools/ncbisettings/main.nf | 4 ++-- modules/sratools/ncbisettings/meta.yml | 4 ++-- .../templates/detect_ncbi_settings.sh | 6 ++++++ tests/modules/sratools/ncbisettings/main.nf | 5 ----- .../sratools/ncbisettings/nextflow.config | 12 ------------ .../sratools/ncbisettings/nextflow_mount.config | 17 +++++++++++++++++ tests/modules/sratools/ncbisettings/test.yml | 6 +++--- 7 files changed, 30 insertions(+), 24 deletions(-) create mode 100644 tests/modules/sratools/ncbisettings/nextflow_mount.config diff --git a/modules/sratools/ncbisettings/main.nf b/modules/sratools/ncbisettings/main.nf index 9d905f8b..f3015c74 100644 --- a/modules/sratools/ncbisettings/main.nf +++ b/modules/sratools/ncbisettings/main.nf @@ -8,8 +8,8 @@ process SRATOOLS_NCBISETTINGS { 'quay.io/biocontainers/sra-tools:2.11.0--pl5321ha49a11a_3' }" output: - path('user-settings.mkfg'), optional: true, emit: ncbi_settings - path 'versions.yml' , emit: versions + path('*.mkfg') , emit: ncbi_settings + path 'versions.yml', emit: versions when: task.ext.when == null || task.ext.when diff --git a/modules/sratools/ncbisettings/meta.yml b/modules/sratools/ncbisettings/meta.yml index 29bcfe34..6043ece4 100644 --- a/modules/sratools/ncbisettings/meta.yml +++ b/modules/sratools/ncbisettings/meta.yml @@ -21,8 +21,8 @@ output: pattern: "versions.yml" - ncbi_settings: type: file - description: An optional, minimal NCBI settings file. - pattern: "user-settings.mkfg" + description: An NCBI user settings file. + pattern: "*.mkfg" authors: - "@Midnighter" diff --git a/modules/sratools/ncbisettings/templates/detect_ncbi_settings.sh b/modules/sratools/ncbisettings/templates/detect_ncbi_settings.sh index b1b51c1f..cfe3a324 100644 --- a/modules/sratools/ncbisettings/templates/detect_ncbi_settings.sh +++ b/modules/sratools/ncbisettings/templates/detect_ncbi_settings.sh @@ -31,6 +31,12 @@ else echo "$(printf '!{config}')" >&2 exit 1 fi + if [[ "${NCBI_SETTINGS}" != *.mkfg ]]; then + echo "The detected settings '${NCBI_SETTINGS}' do not have the required"\ + "file extension '.mkfg'." >&2 + exit 1 + fi + cp "${NCBI_SETTINGS}" ./ fi cat <<-END_VERSIONS > versions.yml diff --git a/tests/modules/sratools/ncbisettings/main.nf b/tests/modules/sratools/ncbisettings/main.nf index 08968bb9..e52c993e 100644 --- a/tests/modules/sratools/ncbisettings/main.nf +++ b/tests/modules/sratools/ncbisettings/main.nf @@ -37,10 +37,5 @@ workflow test_sratools_ncbisettings_with_bad_existing { } workflow test_sratools_ncbisettings_with_nonexisting { - - file(params.settings_path).mkdirs() - def settings = file(params.settings_file) - settings.delete() - SRATOOLS_NCBISETTINGS() } diff --git a/tests/modules/sratools/ncbisettings/nextflow.config b/tests/modules/sratools/ncbisettings/nextflow.config index 823082c0..8730f1c4 100644 --- a/tests/modules/sratools/ncbisettings/nextflow.config +++ b/tests/modules/sratools/ncbisettings/nextflow.config @@ -1,17 +1,5 @@ -params.settings_path = '/tmp/.ncbi' -params.settings_file = "${params.settings_path}/user-settings.mkfg" - -env.NCBI_SETTINGS = params.settings_file - process { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - withName: SRATOOLS_NCBISETTINGS { - containerOptions = { - (workflow.containerEngine == 'singularity') ? - "-B ${params.settings_path}:${params.settings_path}" : - "-v ${params.settings_path}:${params.settings_path}" - } - } } diff --git a/tests/modules/sratools/ncbisettings/nextflow_mount.config b/tests/modules/sratools/ncbisettings/nextflow_mount.config new file mode 100644 index 00000000..823082c0 --- /dev/null +++ b/tests/modules/sratools/ncbisettings/nextflow_mount.config @@ -0,0 +1,17 @@ +params.settings_path = '/tmp/.ncbi' +params.settings_file = "${params.settings_path}/user-settings.mkfg" + +env.NCBI_SETTINGS = params.settings_file + +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + + withName: SRATOOLS_NCBISETTINGS { + containerOptions = { + (workflow.containerEngine == 'singularity') ? + "-B ${params.settings_path}:${params.settings_path}" : + "-v ${params.settings_path}:${params.settings_path}" + } + } +} diff --git a/tests/modules/sratools/ncbisettings/test.yml b/tests/modules/sratools/ncbisettings/test.yml index 07c45dc7..891ebb58 100644 --- a/tests/modules/sratools/ncbisettings/test.yml +++ b/tests/modules/sratools/ncbisettings/test.yml @@ -1,17 +1,17 @@ - name: "sratools ncbisettings test_sratools_ncbisettings_with_good_existing" - command: nextflow run ./tests/modules/sratools/ncbisettings -entry test_sratools_ncbisettings_with_good_existing -c ./tests/config/nextflow.config -c ./tests/modules/sratools/ncbisettings/nextflow.config + command: nextflow run ./tests/modules/sratools/ncbisettings -entry test_sratools_ncbisettings_with_good_existing -c ./tests/config/nextflow.config -c ./tests/modules/sratools/ncbisettings/nextflow_mount.config tags: - "sratools" - "sratools/ncbisettings" files: - path: "output/sratools/user-settings.mkfg" - should_exist: false + md5sum: 955e27aff2c277c2f1f0943a098888c1 - path: output/sratools/versions.yml contains: - "sratools: 2.11.0" - name: "sratools ncbisettings test_sratools_ncbisettings_with_bad_existing" - command: nextflow run ./tests/modules/sratools/ncbisettings -entry test_sratools_ncbisettings_with_bad_existing -c ./tests/config/nextflow.config -c ./tests/modules/sratools/ncbisettings/nextflow.config + command: nextflow run ./tests/modules/sratools/ncbisettings -entry test_sratools_ncbisettings_with_bad_existing -c ./tests/config/nextflow.config -c ./tests/modules/sratools/ncbisettings/nextflow_mount.config tags: - "sratools" - "sratools/ncbisettings"