From 64ff23f3c1d26e22742e13e93da29b52a82da8d2 Mon Sep 17 00:00:00 2001 From: "Moritz E. Beber" Date: Sun, 8 May 2022 15:44:13 +0200 Subject: [PATCH 1/7] feat: add module that verifies NCBI settings --- modules/sratools/ncbisettings/main.nf | 20 ++++++++ modules/sratools/ncbisettings/meta.yml | 28 +++++++++++ .../templates/detect_ncbi_settings.sh | 39 ++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/sratools/ncbisettings/main.nf | 46 +++++++++++++++++++ .../sratools/ncbisettings/nextflow.config | 17 +++++++ tests/modules/sratools/ncbisettings/test.yml | 44 ++++++++++++++++++ 7 files changed, 198 insertions(+) create mode 100644 modules/sratools/ncbisettings/main.nf create mode 100644 modules/sratools/ncbisettings/meta.yml create mode 100644 modules/sratools/ncbisettings/templates/detect_ncbi_settings.sh create mode 100644 tests/modules/sratools/ncbisettings/main.nf create mode 100644 tests/modules/sratools/ncbisettings/nextflow.config create mode 100644 tests/modules/sratools/ncbisettings/test.yml diff --git a/modules/sratools/ncbisettings/main.nf b/modules/sratools/ncbisettings/main.nf new file mode 100644 index 00000000..9d905f8b --- /dev/null +++ b/modules/sratools/ncbisettings/main.nf @@ -0,0 +1,20 @@ +process SRATOOLS_NCBISETTINGS { + tag 'ncbi-settings' + label 'process_low' + + conda (params.enable_conda ? 'bioconda::sra-tools=2.11.0' : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/sra-tools:2.11.0--pl5321ha49a11a_3' : + '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 + + when: + task.ext.when == null || task.ext.when + + shell: + config = "/LIBS/GUID = \"${UUID.randomUUID().toString()}\"\\n/libs/cloud/report_instance_identity = \"true\"\\n" + template 'detect_ncbi_settings.sh' +} diff --git a/modules/sratools/ncbisettings/meta.yml b/modules/sratools/ncbisettings/meta.yml new file mode 100644 index 00000000..29bcfe34 --- /dev/null +++ b/modules/sratools/ncbisettings/meta.yml @@ -0,0 +1,28 @@ +name: "sratools_ncbisettings" +description: Test for the presence of suitable NCBI settings or create them on the fly. +keywords: + - NCBI + - settings + - sra-tools + - prefetch + - fasterq-dump +tools: + - "sratools": + description: "SRA Toolkit and SDK from NCBI" + homepage: https://github.com/ncbi/sra-tools + documentation: https://github.com/ncbi/sra-tools/wiki + tool_dev_url: https://github.com/ncbi/sra-tools + licence: "['Public Domain']" + +output: + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - ncbi_settings: + type: file + description: An optional, minimal NCBI settings file. + pattern: "user-settings.mkfg" + +authors: + - "@Midnighter" diff --git a/modules/sratools/ncbisettings/templates/detect_ncbi_settings.sh b/modules/sratools/ncbisettings/templates/detect_ncbi_settings.sh new file mode 100644 index 00000000..b1b51c1f --- /dev/null +++ b/modules/sratools/ncbisettings/templates/detect_ncbi_settings.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +set -u + + +# Get the expected NCBI settings path and define the environment variable +# `NCBI_SETTINGS`. +eval "$(vdb-config -o n NCBI_SETTINGS | sed 's/[" ]//g')" + +# If the user settings do not exist yet, create a file suitable for `prefetch` +# and `fasterq-dump`. If an existing settings file does not contain the required +# values, error out with a helpful message. +if [[ ! -f "${NCBI_SETTINGS}" ]]; then + printf '!{config}' > 'user-settings.mkfg' +else + prefetch --help &> /dev/null + if [[ $? = 78 ]]; then + echo "You have an existing vdb-config at '${NCBI_SETTINGS}' but it is"\ + "missing the required entries for /LIBS/GUID and"\ + "/libs/cloud/report_instance_identity."\ + "Feel free to add the following to your settings file:" >&2 + echo "$(printf '!{config}')" >&2 + exit 1 + fi + fasterq-dump --help &> /dev/null + if [[ $? = 78 ]]; then + echo "You have an existing vdb-config at '${NCBI_SETTINGS}' but it is"\ + "missing the required entries for /LIBS/GUID and"\ + "/libs/cloud/report_instance_identity."\ + "Feel free to add the following to your settings file:" >&2 + echo "$(printf '!{config}')" >&2 + exit 1 + fi +fi + +cat <<-END_VERSIONS > versions.yml +"!{task.process}": + sratools: $(vdb-config --version 2>&1 | grep -Eo '[0-9.]+') +END_VERSIONS diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 9afe83fd..4a922a4d 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1819,6 +1819,10 @@ sratools/fasterqdump: - modules/sratools/fasterqdump/** - tests/modules/sratools/fasterqdump/** +sratools/ncbisettings: + - modules/sratools/ncbisettings/** + - tests/modules/sratools/ncbisettings/** + sratools/prefetch: - modules/sratools/prefetch/** - tests/modules/sratools/prefetch/** diff --git a/tests/modules/sratools/ncbisettings/main.nf b/tests/modules/sratools/ncbisettings/main.nf new file mode 100644 index 00000000..08968bb9 --- /dev/null +++ b/tests/modules/sratools/ncbisettings/main.nf @@ -0,0 +1,46 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { SRATOOLS_NCBISETTINGS } from '../../../../modules/sratools/ncbisettings/main.nf' + +workflow test_sratools_ncbisettings_with_good_existing { + + file(params.settings_path).mkdirs() + def settings = file(params.settings_file) + settings.text = "/LIBS/GUID = \"5b0d4b7d-88c7-4802-98fd-e3afd06feb32\"\n/libs/cloud/report_instance_identity = \"true\"\n" + + SRATOOLS_NCBISETTINGS() +} + +workflow test_sratools_ncbisettings_with_bad_existing { + + file(params.settings_path).mkdirs() + def settings = file(params.settings_file) + settings.text = ''' + ## auto-generated configuration file - DO NOT EDIT ## + + config/default = "false" + /repository/remote/main/CGI/resolver-cgi = "https://trace.ncbi.nlm.nih.gov/Traces/names/names.fcgi" + /repository/remote/protected/CGI/resolver-cgi = "https://trace.ncbi.nlm.nih.gov/Traces/names/names.fcgi" + /repository/user/ad/public/apps/file/volumes/flatAd = "." + /repository/user/ad/public/apps/refseq/volumes/refseqAd = "." + /repository/user/ad/public/apps/sra/volumes/sraAd = "." + /repository/user/ad/public/apps/sraPileup/volumes/ad = "." + /repository/user/ad/public/apps/sraRealign/volumes/ad = "." + /repository/user/ad/public/apps/wgs/volumes/wgsAd = "." + /repository/user/ad/public/root = "." + /repository/user/default-path = "/root/ncbi" + '''.stripIndent() + + SRATOOLS_NCBISETTINGS() +} + +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 new file mode 100644 index 00000000..823082c0 --- /dev/null +++ b/tests/modules/sratools/ncbisettings/nextflow.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 new file mode 100644 index 00000000..07c45dc7 --- /dev/null +++ b/tests/modules/sratools/ncbisettings/test.yml @@ -0,0 +1,44 @@ +- 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 + tags: + - "sratools" + - "sratools/ncbisettings" + files: + - path: "output/sratools/user-settings.mkfg" + should_exist: false + - 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 + tags: + - "sratools" + - "sratools/ncbisettings" + exit_code: 1 + stdout: + contains: + - "Command error:" + - "missing the required entries" + - "/LIBS/GUID" + - "/libs/cloud/report_instance_identity" + - "Feel free to add the following" + files: + - path: "output/sratools/user-settings.mkfg" + should_exist: false + - path: output/sratools/versions.yml + should_exist: false + +- name: "sratools ncbisettings test_sratools_ncbisettings_with_nonexisting" + command: nextflow run ./tests/modules/sratools/ncbisettings -entry test_sratools_ncbisettings_with_nonexisting -c ./tests/config/nextflow.config -c ./tests/modules/sratools/ncbisettings/nextflow.config + tags: + - "sratools" + - "sratools/ncbisettings" + files: + - path: "output/sratools/user-settings.mkfg" + contains: + - "/LIBS/GUID" + - "/libs/cloud/report_instance_identity" + - path: output/sratools/versions.yml + contains: + - "sratools: 2.11.0" From e4551a9ab3bf4317a485ddfe0cd867b1a9baabb0 Mon Sep 17 00:00:00 2001 From: "Moritz E. Beber" Date: Wed, 11 May 2022 14:07:18 +0200 Subject: [PATCH 2/7] 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" From a83dd33a7ef63a362786c3943bb02d3cc43eb8d3 Mon Sep 17 00:00:00 2001 From: "Moritz E. Beber" Date: Wed, 11 May 2022 14:13:50 +0200 Subject: [PATCH 3/7] tests: use remove settings file --- tests/modules/sratools/ncbisettings/main.nf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/modules/sratools/ncbisettings/main.nf b/tests/modules/sratools/ncbisettings/main.nf index e52c993e..f4d1fcfd 100644 --- a/tests/modules/sratools/ncbisettings/main.nf +++ b/tests/modules/sratools/ncbisettings/main.nf @@ -7,8 +7,8 @@ include { SRATOOLS_NCBISETTINGS } from '../../../../modules/sratools/ncbisetting workflow test_sratools_ncbisettings_with_good_existing { file(params.settings_path).mkdirs() - def settings = file(params.settings_file) - settings.text = "/LIBS/GUID = \"5b0d4b7d-88c7-4802-98fd-e3afd06feb32\"\n/libs/cloud/report_instance_identity = \"true\"\n" + def settings = file(params.test_data['generic']['config']['ncbi_user_settings'], checkIfExists: true) + settings.copyTo(params.settings_file) SRATOOLS_NCBISETTINGS() } From 23091aabdaa8815ed86e57e7aa40dd4a44593745 Mon Sep 17 00:00:00 2001 From: "Moritz E. Beber" Date: Wed, 11 May 2022 17:07:59 +0200 Subject: [PATCH 4/7] refactor: move files to custom section --- modules/{sratools => custom}/ncbisettings/main.nf | 0 modules/{sratools => custom}/ncbisettings/meta.yml | 0 .../ncbisettings/templates/detect_ncbi_settings.sh | 0 tests/modules/{sratools => custom}/ncbisettings/main.nf | 0 tests/modules/{sratools => custom}/ncbisettings/nextflow.config | 0 .../{sratools => custom}/ncbisettings/nextflow_mount.config | 0 tests/modules/{sratools => custom}/ncbisettings/test.yml | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename modules/{sratools => custom}/ncbisettings/main.nf (100%) rename modules/{sratools => custom}/ncbisettings/meta.yml (100%) rename modules/{sratools => custom}/ncbisettings/templates/detect_ncbi_settings.sh (100%) rename tests/modules/{sratools => custom}/ncbisettings/main.nf (100%) rename tests/modules/{sratools => custom}/ncbisettings/nextflow.config (100%) rename tests/modules/{sratools => custom}/ncbisettings/nextflow_mount.config (100%) rename tests/modules/{sratools => custom}/ncbisettings/test.yml (100%) diff --git a/modules/sratools/ncbisettings/main.nf b/modules/custom/ncbisettings/main.nf similarity index 100% rename from modules/sratools/ncbisettings/main.nf rename to modules/custom/ncbisettings/main.nf diff --git a/modules/sratools/ncbisettings/meta.yml b/modules/custom/ncbisettings/meta.yml similarity index 100% rename from modules/sratools/ncbisettings/meta.yml rename to modules/custom/ncbisettings/meta.yml diff --git a/modules/sratools/ncbisettings/templates/detect_ncbi_settings.sh b/modules/custom/ncbisettings/templates/detect_ncbi_settings.sh similarity index 100% rename from modules/sratools/ncbisettings/templates/detect_ncbi_settings.sh rename to modules/custom/ncbisettings/templates/detect_ncbi_settings.sh diff --git a/tests/modules/sratools/ncbisettings/main.nf b/tests/modules/custom/ncbisettings/main.nf similarity index 100% rename from tests/modules/sratools/ncbisettings/main.nf rename to tests/modules/custom/ncbisettings/main.nf diff --git a/tests/modules/sratools/ncbisettings/nextflow.config b/tests/modules/custom/ncbisettings/nextflow.config similarity index 100% rename from tests/modules/sratools/ncbisettings/nextflow.config rename to tests/modules/custom/ncbisettings/nextflow.config diff --git a/tests/modules/sratools/ncbisettings/nextflow_mount.config b/tests/modules/custom/ncbisettings/nextflow_mount.config similarity index 100% rename from tests/modules/sratools/ncbisettings/nextflow_mount.config rename to tests/modules/custom/ncbisettings/nextflow_mount.config diff --git a/tests/modules/sratools/ncbisettings/test.yml b/tests/modules/custom/ncbisettings/test.yml similarity index 100% rename from tests/modules/sratools/ncbisettings/test.yml rename to tests/modules/custom/ncbisettings/test.yml From b2dbaa99309a2057efc32ef9d029ed91140068df Mon Sep 17 00:00:00 2001 From: "Moritz E. Beber" Date: Wed, 11 May 2022 17:32:50 +0200 Subject: [PATCH 5/7] refactor: rename module --- .../main.nf | 2 +- .../meta.yml | 2 +- .../templates/detect_ncbi_settings.sh | 0 tests/config/pytest_modules.yml | 8 ++-- tests/modules/custom/ncbisettings/test.yml | 44 ------------------- .../main.nf | 14 +++--- .../nextflow.config | 0 .../nextflow_mount.config | 2 +- .../custom/sratoolsncbisettings/test.yml | 44 +++++++++++++++++++ 9 files changed, 58 insertions(+), 58 deletions(-) rename modules/custom/{ncbisettings => sratoolsncbisettings}/main.nf (94%) rename modules/custom/{ncbisettings => sratoolsncbisettings}/meta.yml (95%) rename modules/custom/{ncbisettings => sratoolsncbisettings}/templates/detect_ncbi_settings.sh (100%) delete mode 100644 tests/modules/custom/ncbisettings/test.yml rename tests/modules/custom/{ncbisettings => sratoolsncbisettings}/main.nf (75%) rename tests/modules/custom/{ncbisettings => sratoolsncbisettings}/nextflow.config (100%) rename tests/modules/custom/{ncbisettings => sratoolsncbisettings}/nextflow_mount.config (91%) create mode 100644 tests/modules/custom/sratoolsncbisettings/test.yml diff --git a/modules/custom/ncbisettings/main.nf b/modules/custom/sratoolsncbisettings/main.nf similarity index 94% rename from modules/custom/ncbisettings/main.nf rename to modules/custom/sratoolsncbisettings/main.nf index f3015c74..21bf3005 100644 --- a/modules/custom/ncbisettings/main.nf +++ b/modules/custom/sratoolsncbisettings/main.nf @@ -1,4 +1,4 @@ -process SRATOOLS_NCBISETTINGS { +process CUSTOM_SRATOOLSNCBISETTINGS { tag 'ncbi-settings' label 'process_low' diff --git a/modules/custom/ncbisettings/meta.yml b/modules/custom/sratoolsncbisettings/meta.yml similarity index 95% rename from modules/custom/ncbisettings/meta.yml rename to modules/custom/sratoolsncbisettings/meta.yml index 6043ece4..01e98856 100644 --- a/modules/custom/ncbisettings/meta.yml +++ b/modules/custom/sratoolsncbisettings/meta.yml @@ -1,4 +1,4 @@ -name: "sratools_ncbisettings" +name: "sratoolsncbisettings" description: Test for the presence of suitable NCBI settings or create them on the fly. keywords: - NCBI diff --git a/modules/custom/ncbisettings/templates/detect_ncbi_settings.sh b/modules/custom/sratoolsncbisettings/templates/detect_ncbi_settings.sh similarity index 100% rename from modules/custom/ncbisettings/templates/detect_ncbi_settings.sh rename to modules/custom/sratoolsncbisettings/templates/detect_ncbi_settings.sh diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 4a922a4d..428c3652 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -495,6 +495,10 @@ custom/getchromsizes: - modules/custom/getchromsizes/** - tests/modules/custom/getchromsizes/** +custom/sratoolsncbisettings: + - modules/custom/sratoolsncbisettings/** + - tests/modules/custom/sratoolsncbisettings/** + cutadapt: - modules/cutadapt/** - tests/modules/cutadapt/** @@ -1819,10 +1823,6 @@ sratools/fasterqdump: - modules/sratools/fasterqdump/** - tests/modules/sratools/fasterqdump/** -sratools/ncbisettings: - - modules/sratools/ncbisettings/** - - tests/modules/sratools/ncbisettings/** - sratools/prefetch: - modules/sratools/prefetch/** - tests/modules/sratools/prefetch/** diff --git a/tests/modules/custom/ncbisettings/test.yml b/tests/modules/custom/ncbisettings/test.yml deleted file mode 100644 index 891ebb58..00000000 --- a/tests/modules/custom/ncbisettings/test.yml +++ /dev/null @@ -1,44 +0,0 @@ -- 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_mount.config - tags: - - "sratools" - - "sratools/ncbisettings" - files: - - path: "output/sratools/user-settings.mkfg" - 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_mount.config - tags: - - "sratools" - - "sratools/ncbisettings" - exit_code: 1 - stdout: - contains: - - "Command error:" - - "missing the required entries" - - "/LIBS/GUID" - - "/libs/cloud/report_instance_identity" - - "Feel free to add the following" - files: - - path: "output/sratools/user-settings.mkfg" - should_exist: false - - path: output/sratools/versions.yml - should_exist: false - -- name: "sratools ncbisettings test_sratools_ncbisettings_with_nonexisting" - command: nextflow run ./tests/modules/sratools/ncbisettings -entry test_sratools_ncbisettings_with_nonexisting -c ./tests/config/nextflow.config -c ./tests/modules/sratools/ncbisettings/nextflow.config - tags: - - "sratools" - - "sratools/ncbisettings" - files: - - path: "output/sratools/user-settings.mkfg" - contains: - - "/LIBS/GUID" - - "/libs/cloud/report_instance_identity" - - path: output/sratools/versions.yml - contains: - - "sratools: 2.11.0" diff --git a/tests/modules/custom/ncbisettings/main.nf b/tests/modules/custom/sratoolsncbisettings/main.nf similarity index 75% rename from tests/modules/custom/ncbisettings/main.nf rename to tests/modules/custom/sratoolsncbisettings/main.nf index f4d1fcfd..be316a39 100644 --- a/tests/modules/custom/ncbisettings/main.nf +++ b/tests/modules/custom/sratoolsncbisettings/main.nf @@ -2,18 +2,18 @@ nextflow.enable.dsl = 2 -include { SRATOOLS_NCBISETTINGS } from '../../../../modules/sratools/ncbisettings/main.nf' +include { CUSTOM_SRATOOLSNCBISETTINGS } from '../../../../modules/custom/sratoolsncbisettings/main.nf' -workflow test_sratools_ncbisettings_with_good_existing { +workflow test_sratoolsncbisettings_with_good_existing { file(params.settings_path).mkdirs() def settings = file(params.test_data['generic']['config']['ncbi_user_settings'], checkIfExists: true) settings.copyTo(params.settings_file) - SRATOOLS_NCBISETTINGS() + CUSTOM_SRATOOLSNCBISETTINGS() } -workflow test_sratools_ncbisettings_with_bad_existing { +workflow test_sratoolsncbisettings_with_bad_existing { file(params.settings_path).mkdirs() def settings = file(params.settings_file) @@ -33,9 +33,9 @@ workflow test_sratools_ncbisettings_with_bad_existing { /repository/user/default-path = "/root/ncbi" '''.stripIndent() - SRATOOLS_NCBISETTINGS() + CUSTOM_SRATOOLSNCBISETTINGS() } -workflow test_sratools_ncbisettings_with_nonexisting { - SRATOOLS_NCBISETTINGS() +workflow test_sratoolsncbisettings_with_nonexisting { + CUSTOM_SRATOOLSNCBISETTINGS() } diff --git a/tests/modules/custom/ncbisettings/nextflow.config b/tests/modules/custom/sratoolsncbisettings/nextflow.config similarity index 100% rename from tests/modules/custom/ncbisettings/nextflow.config rename to tests/modules/custom/sratoolsncbisettings/nextflow.config diff --git a/tests/modules/custom/ncbisettings/nextflow_mount.config b/tests/modules/custom/sratoolsncbisettings/nextflow_mount.config similarity index 91% rename from tests/modules/custom/ncbisettings/nextflow_mount.config rename to tests/modules/custom/sratoolsncbisettings/nextflow_mount.config index 823082c0..853844c5 100644 --- a/tests/modules/custom/ncbisettings/nextflow_mount.config +++ b/tests/modules/custom/sratoolsncbisettings/nextflow_mount.config @@ -7,7 +7,7 @@ process { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - withName: SRATOOLS_NCBISETTINGS { + withName: CUSTOM_SRATOOLSNCBISETTINGS { containerOptions = { (workflow.containerEngine == 'singularity') ? "-B ${params.settings_path}:${params.settings_path}" : diff --git a/tests/modules/custom/sratoolsncbisettings/test.yml b/tests/modules/custom/sratoolsncbisettings/test.yml new file mode 100644 index 00000000..df3cd936 --- /dev/null +++ b/tests/modules/custom/sratoolsncbisettings/test.yml @@ -0,0 +1,44 @@ +- name: "custom sratoolsncbisettings test_sratoolsncbisettings_with_good_existing" + command: nextflow run ./tests/modules/custom/sratoolsncbisettings -entry test_sratoolsncbisettings_with_good_existing -c ./tests/config/nextflow.config -c ./tests/modules/custom/sratoolsncbisettings/nextflow_mount.config + tags: + - "custom" + - "custom/sratoolsncbisettings" + files: + - path: "output/custom/user-settings.mkfg" + md5sum: 955e27aff2c277c2f1f0943a098888c1 + - path: output/custom/versions.yml + contains: + - "sratools: 2.11.0" + +- name: "custom sratoolsncbisettings test_sratoolsncbisettings_with_bad_existing" + command: nextflow run ./tests/modules/custom/sratoolsncbisettings -entry test_sratoolsncbisettings_with_bad_existing -c ./tests/config/nextflow.config -c ./tests/modules/custom/sratoolsncbisettings/nextflow_mount.config + tags: + - "custom" + - "custom/sratoolsncbisettings" + exit_code: 1 + stdout: + contains: + - "Command error:" + - "missing the required entries" + - "/LIBS/GUID" + - "/libs/cloud/report_instance_identity" + - "Feel free to add the following" + files: + - path: "output/custom/user-settings.mkfg" + should_exist: false + - path: output/custom/versions.yml + should_exist: false + +- name: "custom sratoolsncbisettings test_sratoolsncbisettings_with_nonexisting" + command: nextflow run ./tests/modules/custom/sratoolsncbisettings -entry test_sratoolsncbisettings_with_nonexisting -c ./tests/config/nextflow.config -c ./tests/modules/custom/sratoolsncbisettings/nextflow.config + tags: + - "custom" + - "custom/sratoolsncbisettings" + files: + - path: "output/custom/user-settings.mkfg" + contains: + - "/LIBS/GUID" + - "/libs/cloud/report_instance_identity" + - path: output/custom/versions.yml + contains: + - "sratools: 2.11.0" From 888620063bb67a1645b54de1dba022a409f9a44f Mon Sep 17 00:00:00 2001 From: "Moritz E. Beber" Date: Wed, 11 May 2022 17:44:49 +0200 Subject: [PATCH 6/7] tests: delete settings for conda --- tests/modules/custom/sratoolsncbisettings/main.nf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/modules/custom/sratoolsncbisettings/main.nf b/tests/modules/custom/sratoolsncbisettings/main.nf index be316a39..9f49f20e 100644 --- a/tests/modules/custom/sratoolsncbisettings/main.nf +++ b/tests/modules/custom/sratoolsncbisettings/main.nf @@ -37,5 +37,8 @@ workflow test_sratoolsncbisettings_with_bad_existing { } workflow test_sratoolsncbisettings_with_nonexisting { + def settings = file(params.settings_file) + settings.delete() + CUSTOM_SRATOOLSNCBISETTINGS() } From 98d8a741ec574823a799e9c375ec2c62da654cf5 Mon Sep 17 00:00:00 2001 From: "Moritz E. Beber" Date: Wed, 11 May 2022 18:17:27 +0200 Subject: [PATCH 7/7] tests: add missing paths to config --- tests/modules/custom/sratoolsncbisettings/nextflow.config | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/modules/custom/sratoolsncbisettings/nextflow.config b/tests/modules/custom/sratoolsncbisettings/nextflow.config index 8730f1c4..a6c70bd3 100644 --- a/tests/modules/custom/sratoolsncbisettings/nextflow.config +++ b/tests/modules/custom/sratoolsncbisettings/nextflow.config @@ -1,3 +1,6 @@ +params.settings_path = '/tmp/.ncbi' +params.settings_file = "${params.settings_path}/user-settings.mkfg" + process { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }