mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2025-01-02 20:52:07 -05:00
feat: add module that verifies NCBI settings
This commit is contained in:
parent
64dad04b9b
commit
64ff23f3c1
7 changed files with 198 additions and 0 deletions
20
modules/sratools/ncbisettings/main.nf
Normal file
20
modules/sratools/ncbisettings/main.nf
Normal file
|
@ -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'
|
||||
}
|
28
modules/sratools/ncbisettings/meta.yml
Normal file
28
modules/sratools/ncbisettings/meta.yml
Normal file
|
@ -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"
|
|
@ -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
|
|
@ -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/**
|
||||
|
|
46
tests/modules/sratools/ncbisettings/main.nf
Normal file
46
tests/modules/sratools/ncbisettings/main.nf
Normal file
|
@ -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()
|
||||
}
|
17
tests/modules/sratools/ncbisettings/nextflow.config
Normal file
17
tests/modules/sratools/ncbisettings/nextflow.config
Normal file
|
@ -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}"
|
||||
}
|
||||
}
|
||||
}
|
44
tests/modules/sratools/ncbisettings/test.yml
Normal file
44
tests/modules/sratools/ncbisettings/test.yml
Normal file
|
@ -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"
|
Loading…
Reference in a new issue