MrBayes is a program for Bayesian inference and model choice across a wide range of phylogenetic and evolutionary models. MrBayes uses Markov chain Monte Carlo (MCMC) methods to estimate the posterior distribution of model parameters.
#!/bin/sh
#$ -pe openmpi 4
#$ -cwd
#$ -N myname
source /usr/modules/init/bash
module load openmpi openmpi-apps/1.6.4/mrbayes
mpirun -np $NSLOTS mb myfile.nex
#!/bin/sh
#SBATCH -N 4
#SBATCH -J myname
source /usr/modules/init/bash
module load openmpi openmpi-apps/1.10.2/mrbayes
mpirun mb myfile.nex
not for slurm
The autobayes tool is made up of two simple scripts.
The first script (autobayes.sh) is a submission script which reads a list file and parses the instructions to find the number of defined chains to figure out the optimal number of processors to ask for in the submission. Make sure you change the permissions to make it executable after you create the file (chmod 755 autobayes.sh)
The second is the script that is actually submitted to the scheduling system in order to run the job.
Autobayes for PBS
#!/bin/sh
# Check to see if we have the filelist specified
if [ $# -ne 1 ] ; then
echo "Usage: $0 [filelist]"
exit 1
fi
# Does the filelist exist?
if [ ! -f "$1" ] ; then
echo "File: $1 does not exist"
exit 1
fi
ORIGPATH=$PWD
for i in `grep -v "^;" $1` ; do
echo "------------------------------------------------------------"
if [ -f "$i" ] ; then
MBPATH=`dirname $i`
MBFILE=`basename $i`
MBNAME="mb-`basename $i .nex`"
echo "Moving to $MBPATH"
cd $MBPATH
if [ -f "$MBFILE.log" ] ; then rm -f "$MBFILE.log" ; fi
# Get the number of chains from the mb instructions
NCHAINS=`grep nchains $MBFILE | sed -e 's/^.*nchains=\(.*\) .*/\1/'`
NCHAINS=`grep nchains $MBFILE | sed -e 's/^.*nchains=\([1-9\)\s.*$/\1/'`
# The optimal amount of processors to run is #chains*#runs
# the default for number of runs is 2. If this is different the
# following needs variable to be changed
if [ "x" == "x$NCHAINS" ] ; then
NCHAINS=1
fi
NRUNS=2
NPROCS=$((NCHAINS*NRUNS))
echo "Submitting $MBFILE with $NPROCS processors"
qsub \
-l nodes=$NPROCS \
-o $MBFILE.log \
-j oe \
-v FILE=$MBFILE,DIR=$MBPATH \
-N $MBNAME \
$ORIGPATH/mrbayes.qsub
else
echo "File not found: $i"
echo "...............SKIPPING!!!!"
fi
sleep 1
done
exit 0
mrbayes.qsub
#!/bin/sh
#PBS -q default
. /usr/modules/init/bash
module load openmpi openmpi-apps/1.6.4/mrbayes
cd $DIR
mpirun mb $FILE
Autobayes for SGE
autobayes.sh
#!/bin/sh
# Check to see if we have the filelist specified
if [ $# -ne 1 ] ; then
echo "Usage: $0 [filelist]"
exit 1
fi
# Does the filelist exist?
if [ ! -f "$1" ] ; then
echo "File: $1 does not exist"
exit 1
fi
MYPATH=$PWD
MPIENV="openmpi"
QSUBPE="orte"
# Check to see if we are on the OSX cluster
if [ "$(uname)" == "Darwin" ] ; then
MPIENV="lam-mpi"
QSUBPE="lam-mpi-new"
fi
for i in `grep -v "^;" $1` ; do
echo "------------------------------------------------------------"
if [ -f "$i" ] ; then
###################################################################
MBPATH=`dirname $i`
MBFILE=`basename $i`
echo "Moving to $MBPATH"
cd $MBPATH
if [ -f "$MBFILE.out" ] ; then rm -f "$MBFILE.out" ; fi
if [ -f "$MBFILE.err" ] ; then rm -f "$MBFILE.err" ; fi
# Get the number of chains from the mb instructions
NCHAINS=`grep nchains $MBFILE | sed -e 's/^.*nchains=\(.*\) .*/\1/'`
# The optimal amount of processors to run is #chains*#runs
# the default for number of runs is 2. If this is different the
# following needs variable to be changed
NRUNS=2
NPROCS=$((NCHAINS*NRUNS))
echo "Submitting $MBFILE with $NPROCS processors"
qsub -pe $QSUBPE $NPROCS \
-o $MBFILE.out \
-e $MBFILE.err \
-v MBFILE=$MBFILE \
-v MPIENV=$MPIENV \
$MYPATH/mrbayes.qsub
###################################################################
else
###################################################################
echo "File not found: $i"
echo "...............SKIPPING!!!!"
###################################################################
fi
sleep 1
done
exit 0
#!/bin/sh
#$ -cwd
#$ -N autobayes
. /usr/modules/init/bash
module load $MPIENV
mpirun -np $NSLOTS `which mb` $MBFILE
Running autobayes
An autobayes list is simply a file which contains the path to the mb instruction file (can be the nexus file if the mb instructions are embedded). It uses a ';' semicolon for its comment character. Example:
; my_mb_files.list
; This is the auto-bayes list file
; Comments begin with a semi-colon and are ignored
; To work correctly you must use the full path to the mr. bayes
; instruction file (or nex file if you've embedded your
; instructions there.
/mnt/home/rlyon/test/manual/mrbayes.1.test
/mnt/home/rlyon/test/manual/mrbayes.2.test
Once you have created the list you can use the auto-bash.sh script to submit all the files in the list to the cluster.
# ./autobayes.sh my_mb_files.list
#!/bin/sh
#$ -pe openmpi 4
#$ -cwd
#$ -N myname
. /usr/modules/init/bash
module load openmpi openmpi-apps/1.6.4/mrbayes
mpirun -np $NSLOTS mb myfile.nex