#!/bin/bash
##This script optimizes the santalucia96 dataset
##SantaLucia, John, Hatim T. Allawi, and P. Ananda Seneviratne. 
##"Improved nearest-neighbor parameters for predicting DNA duplex stability." 
##Biochemistry 35.11 (1996): 3555-3562.
set -e
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
export WD=${VER}SL96-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-SL96.par and data/BOP-SL96.par"
echo " ******* Edit this script and set MRR=1000 and ASL=0.0001 and be prepared for 1 or 2 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-SL96.dat -gn=1 \
-me=3000 -minmethod=gsl -mm=6 -mrr=${MRR} \
-o=${WD}/BOP-SL96 -zlog=0 -par=${DATA}/init_s96.par \
-parid=BOP-SL96 -randominitial=0.5 -randomizedataset=0 -rs=1234 \
-var=AT_AT:entropy,AT_CG:entropy,AT_GC:entropy,AT_TA:entropy,CG_AT:entropy,\
CG_CG:entropy,CG_GC:entropy,GC_AT:entropy,GC_CG:entropy,TA_AT:entropy,\
AT_AT:enthalpy,AT_CG:enthalpy,AT_GC:enthalpy,AT_TA:enthalpy,CG_AT:enthalpy,\
CG_CG:enthalpy,CG_GC:enthalpy,GC_AT:enthalpy,GC_CG:enthalpy,TA_AT:enthalpy,\
initiation_CG_entropy,initiation_AT_entropy,\
terminal_5TA3_enthalpy,symmetry_correction_entropy
echo " ******* "
echo " ******* "
echo " ******* Starting Global Minimization Round 2"
echo " ******* "
echo " ******* "

$BIN  -asl=${ASL} -calc=minglobal -cl=10 -data=${DATA}/D-SL96.dat -gn=1 -ee=0.3 -me=3000 -minmethod=gsl -mm=6 \
-o=${WD}/AOP-SL96 -zlog=0 -par=${WD}/BOP-SL96.par.best -parid=AOP-SL96 \
-randomizedataset=1 -rs=1234 \
-var=AT_AT:entropy,AT_CG:entropy,AT_GC:entropy,AT_TA:entropy,CG_AT:entropy,\
CG_CG:entropy,CG_GC:entropy,GC_AT:entropy,GC_CG:entropy,TA_AT:entropy,\
AT_AT:enthalpy,AT_CG:enthalpy,AT_GC:enthalpy,AT_TA:enthalpy,CG_AT:enthalpy,\
CG_CG:enthalpy,CG_GC:enthalpy,GC_AT:enthalpy,GC_CG:enthalpy,TA_AT:enthalpy,\
initiation_CG_entropy,initiation_AT_entropy,\
terminal_5TA3_enthalpy,symmetry_correction_entropy
echo " ******* "
echo " ******* "
echo " ******* Calculating predictions with new parameters "
echo " ******* "
echo " ******* "

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