From 84922e42e698c8c26a217e01d8f35a2f770219b2 Mon Sep 17 00:00:00 2001 From: replikation Date: Tue, 5 May 2020 22:01:11 +0200 Subject: [PATCH] validations and fixes for singularity setup --- bin/download_singularity.sh | 12 ++++++++++-- modules/setup_container.nf | 7 ++++++- phage.nf | 11 +++++++---- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/bin/download_singularity.sh b/bin/download_singularity.sh index 7be4050..0d0ba14 100755 --- a/bin/download_singularity.sh +++ b/bin/download_singularity.sh @@ -1,6 +1,14 @@ -grep "withLabel:" $1 | cut -f2 -d "'" > .container_list.tmp +grep "withLabel:" $1 | cut -f2 -d "'" > .container_list.tmp cachedir="$2" while read container; do - singularity pull --dir $cachedir docker://${container} + name=${container//[\:\/]/-} + + if [ -e ${cachedir}/${name}.img ] + then + echo "${name}.img image exists" + else + singularity pull --name ${name}.img --dir "${cachedir}" "docker://${container}" + fi + done < ".container_list.tmp" \ No newline at end of file diff --git a/modules/setup_container.nf b/modules/setup_container.nf index 63ee9a1..7d5164c 100644 --- a/modules/setup_container.nf +++ b/modules/setup_container.nf @@ -1,5 +1,9 @@ process setup_container { label 'noContainer' + def slash = "/" + def cachdirloc = workflow.launchDir + slash + params.cachedir + println cachdirloc + println slash input: file(config_file) output: @@ -12,8 +16,9 @@ process setup_container { touch everything_done.txt """ else if (workflow.profile.contains('singularity')) + """ - download_singularity.sh ${config_file} + download_singularity.sh ${config_file} ${workflow.launchDir}/${params.cachedir} touch everything_done.txt """ diff --git a/phage.nf b/phage.nf index dff9c55..c3fd530 100755 --- a/phage.nf +++ b/phage.nf @@ -38,8 +38,9 @@ println " $params.databases\u001B[0m" if (workflow.profile.contains('singularity')) { println "\033[2mSingularity cache location [--cachedir]:" println " $params.cachedir" +println " " println "\u001B[33m WARNING: Singularity image building sometimes fails!" -println " Rerun WtP via -resume to retry the failed image build" +println " Please download all images first via --setup --cachedir IMAGE-LOCATION" println " Manually remove faulty images in $params.cachedir for a rebuild\u001B[0m" } println " " @@ -691,6 +692,8 @@ def helpMSG() { """.stripIndent() } -workflow.onComplete { - log.info ( workflow.success ? "\nDone! Results are stored here --> $params.output \n" : "Oops .. something went wrong" ) -} +if (!params.setup) { + workflow.onComplete { + log.info ( workflow.success ? "\nDone! Results are stored here --> $params.output \n" : "Oops .. something went wrong" ) + } +} \ No newline at end of file