Commit c5fd75e9 by Riccardo Vicedomini

scripts are automatically run locally if --sge option is not used

parent 53c6ca05
...@@ -13,6 +13,12 @@ ...@@ -13,6 +13,12 @@
# with MetaCLADE2. If not, see <https://cecill.info/>. # with MetaCLADE2. If not, see <https://cecill.info/>.
# #
# Pressing CTRL-C will stop the whole execution of the script
trap ctrl_c INT; function ctrl_c() { exit 5; }
# Exit from this script causes child processes (pending jobs) to stop execution
trap 'kill $(jobs -p)' EXIT
CMD_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd) CMD_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd)
CMD_NAME=$(basename "${BASH_SOURCE[0]}") CMD_NAME=$(basename "${BASH_SOURCE[0]}")
SCRIPTS_DIR="${CMD_DIR}"/scripts SCRIPTS_DIR="${CMD_DIR}"/scripts
...@@ -20,9 +26,6 @@ SCRIPTS_DIR="${CMD_DIR}"/scripts ...@@ -20,9 +26,6 @@ SCRIPTS_DIR="${CMD_DIR}"/scripts
# Include common definitions # Include common definitions
source "${CMD_DIR}/metaclade2-common" source "${CMD_DIR}/metaclade2-common"
# Pressing CTRL-C will stop the whole execution of the script
trap ctrl_c INT; function ctrl_c() { exit 5; }
# Definition of functions and global variables specific to this script # Definition of functions and global variables specific to this script
MCLADE_LIB_PATH="" MCLADE_LIB_PATH=""
...@@ -235,47 +238,56 @@ print_status "MetaCLADE working directory: ${MCLADE_WORKDIR}" ...@@ -235,47 +238,56 @@ print_status "MetaCLADE working directory: ${MCLADE_WORKDIR}"
print_status "creating MetaCLADE script/job files" print_status "creating MetaCLADE script/job files"
python3 "${SCRIPTS_DIR}/mclade_create_jobs.py" -i "${INPUT_FASTA}" -N "${MCLADE_JOBNAME}" ${MCLADE_DOMARG} -W "${MCLADE_WORKDIR}" -e "${MCLADE_EVALUECUTOFF}" -E "${MCLADE_EVALUECUTCONF}" -j "${NJOBS}" ${MCLADE_DAMAARG} python3 "${SCRIPTS_DIR}/mclade_create_jobs.py" -i "${INPUT_FASTA}" -N "${MCLADE_JOBNAME}" ${MCLADE_DOMARG} -W "${MCLADE_WORKDIR}" -e "${MCLADE_EVALUECUTOFF}" -E "${MCLADE_EVALUECUTCONF}" -j "${NJOBS}" ${MCLADE_DAMAARG}
# Possibly run MetaCLADE scripts in a SGE environment # Run MetaCLADE scripts (possibly using SGE)
if [ "${MCLADE_USESGE}" = true ] ; then
# submit search jobs ## SEARCH JOBS
print_status "submitting search jobs" print_status "running search jobs"
pidarr=() pidarr=()
for i in $(seq 1 ${NJOBS}); do for i in $(seq 1 ${NJOBS}); do
f="${MCLADE_WORKDIR}/jobs/1_search/${MCLADE_JOBNAME}_${i}.sh" f="${MCLADE_WORKDIR}/jobs/1_search/${MCLADE_JOBNAME}_${i}.sh"
# run a qsub job for each non-empty script # run a qsub job for each non-empty script
if [ -f "${f}" ] && [ -s "${f}" ]; then if [ -f "${f}" ] && [ -s "${f}" ]; then
CMD="${PEXEC_CMD} ${f}" CMD="${PEXEC_CMD} ${f}"
qsub $SGE_QUEUEARG $SGE_TIMELIMARG -e ${MCLADE_WORKDIR}/log/search_${i}.err -o ${MCLADE_WORKDIR}/log/search_${i}.out -cwd -sync yes -N ${MCLADE_JOBNAME} -pe ${SGE_PENAME} ${NTHREADS} -b y "${CMD}" 2>&1 >"${MCLADE_WORKDIR}/log/search_qsub_${i}.log" & if [ "${MCLADE_USESGE}" = true ]; then
(qsub $SGE_QUEUEARG $SGE_TIMELIMARG -e ${MCLADE_WORKDIR}/log/search_${i}.err -o ${MCLADE_WORKDIR}/log/search_${i}.out -cwd -sync yes -N ${MCLADE_JOBNAME} -pe ${SGE_PENAME} ${NTHREADS} -b y "${CMD}" &>"${MCLADE_WORKDIR}/log/search_qsub_${i}.log") &
pid=$! pid=$!
pidarr[$i]=$pid pidarr[$i]=$pid
else
${CMD} >"${MCLADE_WORKDIR}/log/search_${i}.out" 2>"${MCLADE_WORKDIR}/log/search_${i}.err"
cmdret=$?; if (( cmdret != 0 )); then print_error "search job ${i} failed (exit status: ${cmdret})"; exit 1; fi
fi fi
done fi
# wait search jobs to finish done
print_status "waiting the search jobs to finish" # wait search jobs to finish
if [ "${MCLADE_USESGE}" = true ]; then
print_status "waiting search jobs to finish"
for i in ${!pidarr[@]}; do for i in ${!pidarr[@]}; do
wait ${pidarr[${i}]} wait ${pidarr[${i}]}
pret=$? pret=$?; if ((pret != 0)); then print_error "search job ${i} failed (exit status: ${pret})"; exit 1; fi
if ((pret != 0)); then
echo "search job ${i} failed (exit status: ${pret})"
exit 1
fi
done done
print_status "search jobs finished successfully" fi
print_status "search jobs finished successfully"
# submit filter jobs ## FILTER JOBS
print_status "submitting filter ijobs" print_status "running filter jobs"
unset pidarr; pidarr=() unset pidarr; pidarr=()
for i in $(seq 1 ${NJOBS}); do for i in $(seq 1 ${NJOBS}); do
f="${MCLADE_WORKDIR}/jobs/2_filter/${MCLADE_JOBNAME}_${i}.sh" f="${MCLADE_WORKDIR}/jobs/2_filter/${MCLADE_JOBNAME}_${i}.sh"
# run a qsub job for each non-empty script # run a qsub job for each non-empty script
if [ -f "${f}" ] && [ -s "${f}" ]; then if [ -f "${f}" ] && [ -s "${f}" ]; then
CMD="${PEXEC_CMD} ${f}" CMD="${PEXEC_CMD} ${f}"
if [ "${MCLADE_USESGE}" = true ]; then
qsub $SGE_QUEUEARG $SGE_TIMELIMARG -e "${MCLADE_WORKDIR}/log/filter_${i}.err" -o "${MCLADE_WORKDIR}/log/filter_${i}.out" -cwd -sync yes -N ${MCLADE_JOBNAME} -pe ${SGE_PENAME} ${NTHREADS} -b y "${CMD}" 2>&1 >"${MCLADE_WORKDIR}/log/filter_qsub_${i}.log" & qsub $SGE_QUEUEARG $SGE_TIMELIMARG -e "${MCLADE_WORKDIR}/log/filter_${i}.err" -o "${MCLADE_WORKDIR}/log/filter_${i}.out" -cwd -sync yes -N ${MCLADE_JOBNAME} -pe ${SGE_PENAME} ${NTHREADS} -b y "${CMD}" 2>&1 >"${MCLADE_WORKDIR}/log/filter_qsub_${i}.log" &
pid=$! pid=$!
pidarr[$i]=$pid pidarr[$i]=$pid
else
${CMD} >"${MCLADE_WORKDIR}/log/filter_${i}.out" 2>"${MCLADE_WORKDIR}/log/filter_${i}.err"
cmdret=$?; if (( cmdret != 0 )); then print_error "filter job ${i} failed (exit status: ${cmdret})"; exit 1; fi
fi fi
done fi
# wait search jobs to finish done
# wait search jobs to finish
if [ "${MCLADE_USESGE}" = true ]; then
print_status "waiting the filter jobs to finish" print_status "waiting the filter jobs to finish"
for i in ${!pidarr[@]}; do for i in ${!pidarr[@]}; do
wait ${pidarr[${i}]} wait ${pidarr[${i}]}
...@@ -285,16 +297,19 @@ if [ "${MCLADE_USESGE}" = true ] ; then ...@@ -285,16 +297,19 @@ if [ "${MCLADE_USESGE}" = true ] ; then
exit 1 exit 1
fi fi
done done
print_status "search jobs finished successfully" fi
print_status "search jobs finished successfully"
# create architecture ## ARCHITECTURE JOBS
print_status "computing architecture" print_status "running architecture job"
f="${MCLADE_WORKDIR}/jobs/3_arch/${MCLADE_JOBNAME}.sh" f="${MCLADE_WORKDIR}/jobs/3_arch/${MCLADE_JOBNAME}.sh"
if [ "${MCLADE_USESGE}" = true ]; then
qsub $SGE_QUEUEARG $SGE_TIMELIMARG -e "${MCLADE_WORKDIR}/log/arch.err" -o "${MCLADE_WORKDIR}/log/arch.out" -cwd -sync yes -N ${MCLADE_JOBNAME} -pe ${SGE_PENAME} 1 -b y ${PEXEC_CMD} ${f} 2>&1 >>"${MCLADE_WORKDIR}/log/arch_qsub.log" qsub $SGE_QUEUEARG $SGE_TIMELIMARG -e "${MCLADE_WORKDIR}/log/arch.err" -o "${MCLADE_WORKDIR}/log/arch.out" -cwd -sync yes -N ${MCLADE_JOBNAME} -pe ${SGE_PENAME} 1 -b y ${PEXEC_CMD} ${f} 2>&1 >>"${MCLADE_WORKDIR}/log/arch_qsub.log"
qret=$? qret=$?; if ((qret != 0)); then print_error "architecture job failed (exit status: ${qret})"; exit 1; fi
if ((qret != 0)); then else
echo "architecture job failed (exit status: ${qret})" ${PEXEC_CMD} ${f} 2>"${MCLADE_WORKDIR}/log/arch.out" >"${MCLADE_WORKDIR}/log/arch.err"
exit 1 cmdret=$?; if (( cmdret != 0 )); then print_error "architecture job failed (exit status: ${cmdret})"; exit 1; fi
fi
print_status "architecture job finished successfully"
fi fi
print_status "architecture job finished successfully"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment