#!/bin/bash
if [ -z "$1" ]; then export DATA=../data; else export DATA=$1; fi
if [ -z $BIN ]; then export BIN=vargibbs; fi
if [ -z $VER ]; then export VER=./; fi
set -e
export WD=${VER}XIA98-global
mkdir -p ${WD}
echo " ******* "
echo " ******* "
echo " ******* This script takes about 5 minutes to run"
echo " ******* "
echo " ******* If you wish to reproduce the files data/AOP-XIA98.par and data/BOP-XIA98.par"
echo " ******* Edit this script and set MRR=1000 and ASL=0.0001 and be prepared for several days of processing"
export MRR=10
export ASL=0.1
echo " ******* "
echo " ******* Starting Global Minimization Round 1"
$BIN  -calc=minglobal -cl=10 -data=${DATA}/D-XIA98.dat -gn=0 \
-me=3000 -minmethod=gsl -mm=6 -mrr=${MRR} -v=1 \
-o=${WD}/BOP-XIA98 -par=${DATA}/P-XIA98.par \
-parid=BOP-XIA98 -randominitial=0.5 -randomizedataset=0 -rs=1234 \
-var=AU_AU:entropy,AU_CG:entropy,AU_GC:entropy,AU_UA:entropy,CG_AU:entropy,CG_CG:entropy,CG_GC:entropy,GC_AU:entropy,GC_CG:entropy,UA_AU:entropy,AU_AU:enthalpy,AU_CG:enthalpy,AU_GC:enthalpy,AU_UA:enthalpy,CG_AU:enthalpy,CG_CG:enthalpy,CG_GC:enthalpy,GC_AU:enthalpy,GC_CG:enthalpy,UA_AU:enthalpy,terminal_AU_enthalpy,terminal_AU_entropy,symmetry_correction_entropy
echo " ******* "
echo " ******* "
echo " ******* Starting Global Minimization Round 2"
echo " ******* "
echo " ******* "
$BIN  -asl=${ASL} -calc=minglobal -cl=10 -data=${DATA}/D-XIA98.dat \
-gn=0 -ee=0.3 -me=3000 -minmethod=gsl -mm=6 \
-o=${WD}/AOP-XIA98 -par=${WD}/BOP-XIA98.par.best -parid=AOP-XIA98 -mrr=${MRR} \
-randomizedataset=1 -rs=1234 -v=1 \
-var=AU_AU:entropy,AU_CG:entropy,AU_GC:entropy,AU_UA:entropy,CG_AU:entropy,CG_CG:entropy,CG_GC:entropy,GC_AU:entropy,GC_CG:entropy,UA_AU:entropy,AU_AU:enthalpy,AU_CG:enthalpy,AU_GC:enthalpy,AU_UA:enthalpy,CG_AU:enthalpy,CG_CG:enthalpy,CG_GC:enthalpy,GC_AU:enthalpy,GC_CG:enthalpy,UA_AU:enthalpy,terminal_AU_enthalpy,terminal_AU_entropy,symmetry_correction_entropy
echo " ******* "
echo " ******* "
echo " ******* Calculating predictions with new parameters "
echo " ******* "
echo " ******* "

$BIN  -o=${WD}/XIA98-global-prediction -par=${WD}/AOP-XIA98.par.best  \
-calc=prediction -data=${DATA}/D-XIA98.dat
