#!/bin/sh
#
# cifstats,v 1.3 2002/06/19 01:55:05 dsg Exp
# unix shell script to run the gathering mmcif file statistics
#
# Copyright 2001 Douglas S. Greer
#

# set local variable definitions
execname=`echo $0`
execdir=`dirname ${execname}`
. ${execdir}/_vars.sh

#  public static void main class
rclass=org.rcsb.openmms.apps.stats.CifStats

# defaults
data_dir="${TEST_CIF_DATA_DIR}"
exactness=LenientParse
dictionary=${DICTIONARY_DIR}/${CIF_MM_DICTIONARY_NAME}
ofile=CIFSTATS.TXT
vm_size=1000M
verbosity=3

continue=""
time=""
pcmd=""

# process command line
while getopts c:d:m:o:tps:v: option
do
    case "${option}"
    in
	c)   continue=${OPTARG};;
	d)   data_dir=${OPTARG};;
	m)   dictionary=${OPTARG};;
	o)   ofile=${OPTARG};;
	t)   time=Time;;
	p)   pcmd="-pXrofAbort";;
	s)   vm_size=${OPTARG};;
	v)   verbosity=${OPTARG};;
	\?)  echo "Usage: $0 [-d ddir] [-m dict] [-o ofile] [-c cont_id]"
		echo "    [-t] [-p] [-s vm_size] [-v verbosity]"
		echo "\t   ddir = mmcif data directory"
		echo "\t   dict = mmCIF dictionary\c"
		echo " (default = ${CIF_MM_DICTIONARY_NAME})"
		echo "\t   ofile = output file (default = CIFSTATS.TXT)"
		echo "\t   cont_id = continue stats beginning with this id"
		echo "\t   -t = report mmcif file parse times"
		echo "\t   -p = run profiling"
		echo "\t   vm_size = java virtual machine memory size\c"
		echo " (default = 1000M)"
		echo "\t   verbosity = message verbosity level (default = 3)"
		exit 1;;
    esac
done

# continuation
if [ -n "${continue}" ]    
then
    ccmd="start=${continue}"
else
    ccmd=""
fi

cmd_line="${RUN_JAVA} -Xmx${vm_size} ${pcmd} ${rclass} dct=${dictionary} \
	    data=${data_dir} output=${ofile} ${ccmd} ${time} \
	    debug=${verbosity}"

if [ "${verbosity}" -ge 4 ]
then
    echo ${cmd_line}
fi

${cmd_line}

