Hippo setup.sh
From Biowerkzeug Wiki
Jump to navigationJump to search
The hippo_setup.sh bash script automates the setup of hippo simulations.
Copy and paste the script below into a file, name it setup_hippo.sh, make it executable, install it in your PATH. Set the variable HIPPO_HOME to the directory that you got when unpacking the downloaded hippo.zip file.
Example use:
hippo_setup.sh -w ProteinX_GBSA_MC ${HIPPO_HOME}/testjobs/test/trpzip2_GBSA_MC/hippo_input.txt ../coord/protein_X.pdb
This would
- create the working directory ProteinX_GBSA_MC (and because of the -w (`wipe') option it would delete everything in this directory before copying files)
- copy data files
- copy a working executable (the -m (mpi) option would indicate that we want an executable that can run in parallel)
- copy a template for the input file hippo_input.txt from one of the test jobs
- copy the protein structure
Then you would edit the command input file ProteinX_GBSA_MC/hippo_input.txt to suit your needs. Finally, run hippo:
./hippo
#!/bin/bash # Copyright (c) 2008 Oliver Beckstein <orbeckst@gmail.com> # This script is made available under the terms of the GNU Public License v2. # http://www.gnu.org/licenses/gpl-2.0.html#SEC1 # # # prepare for a hippo run by setting up the local working directory #------------------------------------------------------------ # CUSTOMIZATION # - set HIPPO_HOME to the directory where the hippo executables and # support files are located, eg '${HOME}/hippo' # - put this script somewhere into your PATH # : ${HIPPO_HOME:="${HOME}/Library/hippo"} # #------------------------------------------------------------ # # HIPPO_HOME can be set from environment or commandline -D HIPPO_HOME #: ${HIPPO_HOME:=$(dirname "$0")/../hippo_r26} usage="$0 [options] work_dir [input_files ...] This script sets up the work_dir for a run of hippo. work_dir is created unless it exists already. It hard-links the hippo executable and the data files into the directory. Options: -h help -D HIPPO_HOME directory where hippo and files reside -m look for mpi-enabled binaries -w wipe the work_dir ('rm -rf work_dir') before setting up making sure that we start from a clean slate " function die () { local msg="$1" err=${2:-1} echo 1>&2 "ERROR: $msg [status=$err]" exit $err } function pick_binary () { # find working executable # we'll use the first one that only complains about missing input file local hippo_dir="$1" use_mpi="$2" local _hippo_binaries="hippo hippo_p3" local hippo="not_found" local tmpdir=`mktemp -d` pushd >/dev/null "$tmpdir" || die "Failed to set up testing area" for h in ${_hippo_binaries}; do if [ "${use_mpi}" = 1 ]; then exe="${hippo_dir}/${h}_mpi" else exe="${hippo_dir}/${h}" fi if ${exe} 2>&1 | egrep "Could not open file: hippo_input.txt" >/dev/null; then hippo=${exe} break fi done if [ "${hippo}" = "not_found" ]; then ARCH=$(uname -m); OS=$(uname -s); die "No usable hippo executable found (MPI=${use_mpi}); see if there is one at http://www.biowerkzeug.com for your architecture ${ARCH} and operating system ${OS}. " fi popd >/dev/null rm -r "${tmpdir}" || die "Failed to remove tmpdir... weird" echo "${hippo}" return 0 } #set -x # defaults USE_MPI=0 WIPE_WORK_DIR=0 # arg processing TEMP=`getopt -o hmwD: -n 'hippo_setup.sh' -- "$@"` opterr=$? [ $opterr != 0 ] && die "Error parsing the commandline." $opterr eval set -- "$TEMP" while true; do case "$1" in -h) echo -e "${usage}"; exit 0;; -D) HIPPO_HOME="$2"; shift;; -m) USE_MPI=1;; -w) WIPE_WORK_DIR=1;; --) shift; break;; esac shift done [ -d "${HIPPO_HOME}" ] || die "HIPPO_HOME=${HIPPO_HOME} not found" 1 HIPPO_EXE=`pick_binary "${HIPPO_HOME}" ${USE_MPI}` HIPPO_TOPOLOGY="${HIPPO_HOME}/hippo_protein_database.dat" HIPPO_FF="${HIPPO_HOME}/oplsaa_forcefield.dat" test -n "${HIPPO_EXE}" || die "No hippo executable found. Did you set HIPPO_HOME or the -D option?" function setup_hippo () { cp -lf ${HIPPO_EXE} ./hippo && chmod a+x ./hippo || return 1 cp -lf ${HIPPO_TOPOLOGY} . || return 2 cp -lf ${HIPPO_FF} . || return 3 return 0 } WORK_DIR="$1" shift INPUTFILES="$*" test -n "${WORK_DIR}" || die "No work_dir, see $0 -h for help" echo "Setting up Hippo run" echo "------------------------------------------------------------" echo "working directory ${WORK_DIR}" echo "HIPPO_HOME ${HIPPO_HOME}" echo "executable ${HIPPO_EXE} --> ./hippo" echo "force field ${HIPPO_FF}" echo "topology ${HIPPO_TOPOLOGY}" echo "------------------------------------------------------------" echo "additional files ${INPUTFILES}" echo "------------------------------------------------------------" curdir="${PWD}" if [ ${WIPE_WORK_DIR} = 1 ] && [ -d "${WORK_DIR}" ]; then case "${WORK_DIR}" in "."|".."|"/"|${curdir}) \ die "Refusing to 'rm -r WORK_DIR=${WORK_DIR}'";; esac echo "Wiping WORK_DIR='${WORK_DIR}' first." rm -r "${WORK_DIR}" fi if ! [ -d "${WORK_DIR}" ]; then mkdir -p "${WORK_DIR}" || die "Failed mkdir $WORK_DIR" echo "Created WORK_DIR='${WORK_DIR}'." fi cd "${WORK_DIR}" || die "Failed 'cd $WORK_DIR'" echo "Linking hippo files..." setup_hippo || die "Failed to link required files." echo "Copying additional files..." for f in ${INPUTFILES}; do cp "${curdir}/${f}" . || die "Failed copying additional file $f" done echo "Done"