Slurm with Python

Slurm scripts may written in Python. However, some extra code is need to set up environment variables, as shown in the script below:

#!/usr/bin/python

#SBATCH --job-name=batch_python
#SBATCH --mail-user=dummyuser@zedat.fu-berlin.de
#SBATCH --mail-type=end
#SBATCH --mem=3000

import os
execfile(os.environ['MODULESHOME'] + '/init/python')

module('load','mrbayes')

os.system("mb -i test.nex > test.out")