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

Refactor prefetch #1631

Merged
merged 8 commits into from
May 11, 2022
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
5 changes: 2 additions & 3 deletions modules/sratools/prefetch/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ process SRATOOLS_PREFETCH {

input:
tuple val(meta), val(id)
path ncbi_settings

output:
tuple val(meta), path(id), emit: sra
path "versions.yml" , emit: versions
path 'versions.yml' , emit: versions

when:
task.ext.when == null || task.ext.when

shell:
args = task.ext.args ?: ''
args2 = task.ext.args2 ?: '5 1 100' // <num retries> <base delay in seconds> <max delay in seconds>
config = "/LIBS/GUID = \"${UUID.randomUUID().toString()}\"\\n/libs/cloud/report_instance_identity = \"true\"\\n"

template 'retry_with_backoff.sh'
}
7 changes: 6 additions & 1 deletion modules/sratools/prefetch/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tools:
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: ["US-Government-Work"]
licence: ["Public Domain"]

input:
- meta:
Expand All @@ -22,6 +22,11 @@ input:
type: val
description: >
A string denoting an SRA id.
- ncbi_settings:
type: file
description: >
An NCBI user settings file.
pattern: "*.mkfg"

output:
- meta:
Expand Down
6 changes: 1 addition & 5 deletions modules/sratools/prefetch/templates/retry_with_backoff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ retry_with_backoff() {
echo "${output}"
}

eval "$(vdb-config -o n NCBI_SETTINGS | sed 's/[" ]//g')"
if [[ ! -f "${NCBI_SETTINGS}" ]]; then
mkdir -p "$(dirname "${NCBI_SETTINGS}")"
printf '!{config}' > "${NCBI_SETTINGS}"
fi
export NCBI_SETTINGS="$PWD/!{ncbi_settings}"

retry_with_backoff !{args2} \
prefetch \
Expand Down
3 changes: 3 additions & 0 deletions tests/config/test_data.config
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ params {
test_merge_cool_cp2 = "${test_data_dir}/genomics/homo_sapiens/cooler/merge/toy/toy.symm.upper.2.cp2.cool"

}
'config' {
ncbi_user_settings = "${test_data_dir}/generic/config/ncbi_user_settings.mkfg"
}
}
}
}
4 changes: 2 additions & 2 deletions tests/modules/sratools/prefetch/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ workflow test_sratools_prefetch {

input = [
[ id:'test', single_end:false ], // meta map
'ERR2815334'
'DRR000774'
]

SRATOOLS_PREFETCH ( input )
SRATOOLS_PREFETCH(input, file(params.test_data['generic']['config']['ncbi_user_settings'], checkIfExists: true))
}
7 changes: 5 additions & 2 deletions tests/modules/sratools/prefetch/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
- sratools/prefetch
- sratools
files:
- path: output/sratools/ERR2815334/ERR2815334.sra
md5sum: 9a98c7f6f4774b7ef94aa915b92a54ea
- path: output/sratools/DRR000774/DRR000774.sra
md5sum: 7647dba20c89c0e3d7ad13842f060eb0
- path: output/sratools/versions.yml
contains:
- "sratools: 2.11.0"