Skip to content

Commit

Permalink
Merge pull request #1631 from nf-core/refactor-prefetch
Browse files Browse the repository at this point in the history
Refactor prefetch
  • Loading branch information
drpatelh authored May 11, 2022
2 parents ae55653 + 7be7f40 commit 79bf60f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
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"

0 comments on commit 79bf60f

Please sign in to comment.