#!/bin/sh
#
# $Id: prototype-pathway-tools,v 1.13 2011/09/22 01:08:50 pkarp Exp $
#
#  usage:  pathway-tools [-help  ...  and other arguments]
#
#  Arguments are described in detail in the User's Guide
#
#  o Run this script to invoke all versions of Pathway Tools.
#  o Please set the X-windows DISPLAY environment variable before execution.
#  o You may create a link from /usr/local/bin/ptools to this script to simplify
#    execution of the script.

# The conf-ptools script automatically inserts appropriate values into the following lines.
# This now sets up the ptools_local_path variable which is where all the user created pgdbs
# and ptools-init.dat script will be stored.
#
# gilham:Apr-09-2010 Changed to run under SH because CSH is no longer distributed
# by default with Linux.
# ong:Jun-09-2011 Increased the ulimit for stack for MacOSX

PTROOT=/home/psgendb/local/pkg/biocyc_eco_shigella_install/aic-export ; export PTROOT
PT_HOSTNAME="set if needed" ; export PT_HOSTNAME
PT_HTTP_ROOT=/home/psgendb/local/pkg/biocyc_eco_shigella_install/aic-export/htdocs ; export PT_HTTP_ROOT
PTOOLS_LOCAL_PATH=/home/psgendb/local/pkg/biocyc_eco_shigella_install/database ; export PTOOLS_LOCAL_PATH

# Use the software version so we can figure out the absolute pathname
# of the script.
VERSION=16.0

this_path="$PTROOT"/pathway-tools/ptools/"$VERSION"/

# BioCyc.org website uses a virtual frame buffer as its X server;
# set the DISPLAY environment variable.  Also create a
# ptools.pid file with the PID.
if [ "$PT_HOSTNAME" = "BioCyc.org" ]; then
  DISPLAY=':1' ; export DISPLAY
  echo $$ > $PTROOT/../ptools.pid 2>&1
fi

# so ptools can locate the libraries we supply.
if [ "`uname -s`" = "Darwin" ]; then
    if [ ! $?DYLD_LIBRARY_PATH ]; then
	DYLD_LIBRARY_PATH="" ; export DYLD_LIBRARY_PATH
    fi
    DYLD_LIBRARY_PATH="${this_path}/exe:${DYLD_LIBRARY_PATH}" ; export DYLD_LIBRARY_PATH

    # Give ptools some more stack space for Macs
    ulimit -s hard
else
    if [ ! $?LD_LIBRARY_PATH ]; then
	LD_LIBRARY_PATH="" ; export LD_LIBRARY_PATH
    fi
# interferes with ptools
    unset ORACLE_HOME
    LD_LIBRARY_PATH="${this_path}/exe:${LD_LIBRARY_PATH}" ; export LD_LIBRARY_PATH
fi

# at last, actually start up the lisp image
exec "${this_path}/exe/pathway-tools-runtime" -- -exe-quiet -patch -go $*