Commit aa4b9770 by Riccardo Vicedomini

added the possibility to use SGE for search/filter, needs testing

parent 1f1aeaf5
......@@ -34,12 +34,6 @@ MCLADE_WORKDIR=${PWD}
NTHREADS=1
NJOBS=16
PEXEC_CMD="parallel --halt now,fail=1 -j ${NJOBS}"
if ! command -v parallel >/dev/null 2>&1; then
print_warning "cannot find GNU parallel, all jobs will be run sequentially"
PEXEC_CMD="/usr/bin/env bash --"
fi
function print_usage() {
echo -en "\n USAGE: ${CMD_NAME} -i <input_fasta> [options]\n"
echo -en "\n"
......@@ -143,6 +137,13 @@ done
# Input parameters validation
PEXEC_CMD="parallel --halt now,fail=1 -j ${NTHREADS} ::::"
if ! command -v parallel >/dev/null 2>&1; then
print_warning "cannot find GNU parallel, all jobs will be run sequentially"
NTHREADS=1
PEXEC_CMD="/usr/bin/env bash --"
fi
if [ -z "${INPUT_FASTA}" ] || [ ! -f ${INPUT_FASTA} ]; then
print_error "-i|--input file is missing or does not exist: ${INPUT_FASTA}"
exit 1
......@@ -181,24 +182,83 @@ fi
check_cmds "python3"
# Validate SGE parameters
if [ "${MCLADE_USESGE}" = true ] ; then
if [ -z ${SGE_PENAME} ]; then
print_error "you must set a parallel environment name with -P|--parallel-env option along with the --SGE option"
exit 1
fi
if [ ! -z ${SGE_QUEUE} ]; then
SGE_QUEUEARG="-q ${SGE_QUEUE}"
fi
if [ ! -z ${SGE_TIMELIM} ]; then
SGE_TIMELIMARG="-l h_rt=${SGE_TIMELIM}"
fi
fi
# Create Working directory
MCLADE_WORKDIR=${MCLADE_WORKDIR}"/"${MCLADE_JOBNAME}
mkdir -p ${MCLADE_WORKDIR}
mkdir -p "${MCLADE_WORKDIR}" "${MCLADE_WORKDIR}/log"
if [ $? -ne 0 ]; then
print_error "cannot create/access MetaCLADE working directory: ${MCLADE_WORKDIR}"
exit 1
fi
print_status "MetaCLADE working directory: ${MCLADE_WORKDIR}"
# Create MetaCLADE scripts
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}"
# Possibly run MetaCLADE scripts in a SGE environment
if [ "${MCLADE_USESGE}" = true ] ; then
# run search jobs
# submit search jobs
print_status "submitting search jobs"
pidarr=()
for i in $(seq 1 ${NJOBS}); do
f="${MCLADE_WORKDIR}/jobs/1_search/${MCLADE_JOBNAME}_${i}.sh"
# run a qsub job for each non-empty script
if [ -f "${f}" ] && [ -s "${f}" ]; 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 ${PEXEC_CMD} ${f} &
pid=$!
pidarr[$i]=$pid
((i++))
fi
done
# wait search jobs to finish
print_status "waiting the search jobs to finish"
for i in ${!pidtab[@]}; do
wait ${pidtab[${i}]}
ret=$?
if ((ret != 0)); then
echo "MetaCLADE search job ${i} failed (exit status: ${ret})"
exit 1
fi
done
echo "search jobs finished successfully"
# submit filter jobs
print_status "submitting filter ijobs"
unset pidarr
pidarr=()
for i in $(seq 1 ${NJOBS}); do
f="${MCLADE_WORKDIR}/jobs/1_filter/${MCLADE_JOBNAME}_${i}.sh"
# run a qsub job for each non-empty script
if [ -f "${f}" ] && [ -s "${f}" ]; then
echo "qsub -sync yes -b y ${f}"
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 ${PEXEC_CMD} ${f} &
pid=$!
pidarr[$i]=$pid
((i++))
fi
done
# wait search jobs to finish
print_status "waiting the filter jobs to finish"
for i in ${!pidtab[@]}; do
wait ${pidtab[${i}]}
ret=$?
if ((ret != 0)); then
echo "MetaCLADE filter job ${i} failed (exit status: ${ret})"
exit 1
fi
done
echo "search jobs finished successfully"
fi
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