From 161310a131961fe7cd2fd04e1ccc4e2251c472c2 Mon Sep 17 00:00:00 2001 From: jgugliel <julien.guglielmini@pasteur.fr> Date: Tue, 6 Jun 2023 14:04:27 +0200 Subject: [PATCH] Added more checks for the sbatch version (scratch folder existence, number of threads for the main script) --- wGRR | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/wGRR b/wGRR index a719527..02c7a5d 100755 --- a/wGRR +++ b/wGRR @@ -7,7 +7,7 @@ trap 'rm -rf "$tmp"' EXIT export LC_ALL=C SECONDS=0 -readonly VERSION=1.4 +readonly VERSION=1.4.1 bold=$(tput bold) green=$(tput setaf 2) @@ -136,7 +136,7 @@ while getopts :fTsji:p:o:t:a:m:l:C:I: option ; do case $option in i) PRT="$OPTARG"; if [[ ! -s $PRT ]]; then printf "${bold}${red}%-17s -- %s\n${normal}" "[ERROR]" "Fasta file '$PRT' not found or empty (option -i)." ; exit 1 ; fi ;; p) MMPATH="$OPTARG" ;; - o) OUT="$OPTARG"; if [[ -f "$OUT".wgrr.final.txt ]]; then printf "${bold}${red}%-17s -- %s\n${normal}" "[ERROR]" "File $OUT.wgrr.final.txt already exists. Change option -o or remove this file and relaunch." ; exit 1 ; fi ;; + o) OUT="$OPTARG"; if [[ -f "$OUT".wgrr.final.txt ]]; then printf "${bold}${red}%-17s -- %s\n${normal}" "[ERROR]" "File $OUT.wgrr.final.txt already exists. Change option -o or remove this file and relaunch." ; exit 1 ; elif [[ ${OUT} =~ / ]] ; then printf "${bold}${red}%-17s -- %s\n${normal}" "[ERROR]" "You cannot use a path as a prefix with -o option. Please use a simple string instead." ; exit 1 ; fi ;; t) THREADS="$OPTARG"; if [[ ! $THREADS =~ ^[0-9]+$ ]]; then printf "${bold}${red}%-17s -- %s\n${normal}" "[ERROR]" "Number of threads $THREADS must be an integer (option -t)." ; exit 1 ; fi ;; a) ARRAYSIZE="$OPTARG"; if [[ ! $ARRAYSIZE =~ ^[0-9]+$ ]]; then if [[ $ARRAYSIZE != "AUTO" ]] ; then printf "${bold}${red}%-17s -- %s\n${normal}" "[ERROR]" "Number of genomes comparisons $ARRAYSIZE must be an integer (option -a)." ; exit 1 ; fi ; fi ;; l) IDLIST="$OPTARG"; if [[ ! -s ${IDLIST} ]] ; then printf "${bold}${red}%-17s -- %s\n${normal}" "[ERROR]" "File ${IDLIST} not found or empty (option -l)." ; exit 1 ; fi ;; @@ -180,7 +180,10 @@ if [[ $? -eq 1 ]] ; then tmp=$(mktemp -d tmp-XXXXXX) else if [[ `hostname` == "maestro-"* ]] ; then - tmp=$(mktemp -p $MYSCRATCH -d tmp-XXXXXXXX) + if [[ ! -d ${APPASCRATCH}/${USER} ]] ; then + mkdir ${APPASCRATCH}/${USER} + fi + tmp=$(mktemp -p ${APPASCRATCH}/${USER} -d tmp-XXXXXXXX) else tmp=$(mktemp -d tmp-XXXXXXXX) fi @@ -198,7 +201,7 @@ fi # Get system total memory if not in sbatch TOTALMEM=0 -if [[ $BATCHFLAG==0 ]] ; then +if [[ $BATCHFLAG == 0 ]] ; then if [[ $SLURM_JOBID != "" ]] ; then TOTALMEM=$(sacct -j $SLURM_JOBID -o ReqMem | awk 'NR==3{print $1;exit}' | numfmt --from=iec) else @@ -212,6 +215,9 @@ if [[ $BATCHFLAG==0 ]] ; then fi fi fi +elif [[ $(nproc) -gt 1 ]] ; then + printf "${bold}${yellow}%-17s -- %s\n${normal}" "[WARNING]" "You requested $(nproc) threads (sbatch -c $(nproc)) but wGRR main script will use only one in sbatch mode." | tee -a ${OUT}.wgrr.log + printf "${bold}${yellow}%-17s -- %s\n${normal}" "[WARNING]" "You should not use the -c option of sbatch when running wGRR this way." | tee -a ${OUT}.wgrr.log fi printf "%-17s -- %s\n" "["$(textifyDuration $SECONDS)"]" "wGRR version ${VERSION}" | tee -a ${OUT}.wgrr.log -- GitLab