I got tired of doing this manually so I wrote a bash script for Linux hippo_setup.sh which automates the setup/copying task. Basically you tell it where you unpacked hippo (set the variable HIPPO_HOME either in the script, as environment variable or on the commandline (-D HIPPO_HOME), the name of the working directory, and any additional files that are needed. A typical invocation would be
Code: Select all
hippo_setup -w WORK_DIR hippo-input.txt ../coord/my.pdb
The script automatically finds the hippo binary that runs on the current cpu. If you need an OpenMP enabled one then set the -m flag. If no suitable binary is found an error is raised.
The full usage can be obtained with -h:
Install the script below somewhere in your PATH, add executable permission (chmod a+x hippo_setup), hard code HIPPO_HOME in the script and it should work.hippo_setup 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
Code: Select all
#!/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"