Last active
March 24, 2023 15:35
-
-
Save toniher/65ccf76a8903bf432435d490b2025fab to your computer and use it in GitHub Desktop.
Simple script for predownloading Singularity images in order to be convenient to be used by Nextflow. Useful for issues like this: https://github.com/nextflow-io/nextflow/issues/1210
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
CONFILE=${1:-nextflow.config} | |
OUTDIR=${2:-./singularity} | |
if [ ! -e $CONFILE ]; then | |
echo "$CONFILE does not exist" | |
exit | |
fi | |
TMPFILE=`mktemp` | |
CURDIR=$(pwd) | |
mkdir -p $OUTDIR | |
cat ${CONFILE}|grep 'container'|perl -lane 'if ( $_=~/container\s*\=\s*\"(\S+)\"/ ) { $_=~/container\s*\=\s*\"(\S+)\"/; print $1 unless ( $1=~/^\s*$/ or $1=~/\.sif/ or $1=~/\.img/ ) ; }' > $TMPFILE | |
cd ${OUTDIR} | |
while IFS= read -r line; do | |
name=$line | |
name=${name/:/-} | |
name=${name//\//-} | |
echo $name | |
singularity pull ${name}.img docker://$line | |
done < $TMPFILE | |
cd $CURDIR | |
~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment