#!/bin/bash

#### JUST CHANGE THE 'NEW' FIELDS !!!

pref='helix'
newpref='helix'

suf='zwit'
newsuf='zwit' # Must be the same 

oldpatt='helix'
newpatt='helix'

#oldpatt2='nter'
#newpatt2='nteh'
  
export pref
export newpref
export suf
export newsuf                                                                                             
export oldpatt
export newpatt

nbstep='6000'
                                                                                              
i=1
#./subst.csh $oldpatt $newpatt ${pref}_${i}_${suf}.inp  > ${newpref}_${i}_${newsuf}.inp
/net/orinoco/apps/charmm/c33b1/exec/gnu/charmm_xxlarge < ${newpref}_${i}_${newsuf}.inp > ${newpref}_${i}_${newsuf}.out 
./grepEnergie.sh ${newpref}_${i}_${newsuf}.out > ${newpref}_${i}_${newsuf}.txt
#nbstep=wc ${newpref}_${i}_${newsuf}.txt|awk '{print $1}'
R --no-save --args ${newpref}_${i}_${newsuf}.txt ${nbstep} < calc_energy.r > ${newpref}_${i}_${newsuf}.R_output.txt

i=2
#./subst.csh $oldpatt $newpatt ${pref}_${i}_${suf}.inp  > ${newpref}_${i}_${newsuf}.inp
/net/orinoco/apps/charmm/c33b1/exec/gnu/charmm_xxlarge < ${newpref}_${i}_${newsuf}.inp > ${newpref}_${i}_${newsuf}.out 
./grepEnergie.sh ${newpref}_${i}_${newsuf}.out > ${newpref}_${i}_${newsuf}.txt
R --no-save --args ${newpref}_${i}_${newsuf}.txt ${nbstep} < calc_energy.r > ${newpref}_${i}_${newsuf}.R_output.txt

                                                                                
i=3
#./subst.csh $oldpatt $newpatt ${pref}_${i}_${suf}.inp  > ${newpref}_${i}_${newsuf}.inp
#./subst.csh $oldpatt2 $newpatt2 ${newpref}_${i}_${newsuf}.inp_tmp  > ${newpref}_${i}_${newsuf}.inp
/net/orinoco/apps/charmm/c33b1/exec/gnu/charmm_xxlarge < ${newpref}_${i}_${newsuf}.inp > ${newpref}_${i}_${newsuf}.out 
./grepEnergie.sh ${newpref}_${i}_${newsuf}.out > ${newpref}_${i}_${newsuf}.txt
R --no-save --args ${newpref}_${i}_${newsuf}.txt ${nbstep}< calc_energy.r > ${newpref}_${i}_${newsuf}.R_output.txt


i=4
#./subst.csh $oldpatt $newpatt ${pref}_${i}_${suf}.inp  > ${newpref}_${i}_${newsuf}.inp
/net/orinoco/apps/charmm/c33b1/exec/gnu/charmm_xxlarge < ${newpref}_${i}_${newsuf}.inp > ${newpref}_${i}_${newsuf}.out 
./grepEnergie.sh ${newpref}_${i}_${newsuf}.out > ${newpref}_${i}_${newsuf}.txt
R --no-save --args ${newpref}_${i}_${newsuf}.txt ${nbstep}< calc_energy.r > ${newpref}_${i}_${newsuf}.R_output.txt


i=5
#./subst.csh $oldpatt $newpatt ${pref}_${i}_${suf}.inp  > ${newpref}_${i}_${newsuf}.inp
/net/orinoco/apps/charmm/c33b1/exec/gnu/charmm_xxlarge < ${newpref}_${i}_${newsuf}.inp > ${newpref}_${i}_${newsuf}.out 
./grepEnergie.sh ${newpref}_${i}_${newsuf}.out > ${newpref}_${i}_${newsuf}.txt
R --no-save --args ${newpref}_${i}_${newsuf}.txt ${nbstep} < calc_energy.r > ${newpref}_${i}_${newsuf}.R_output.txt


i=6
#./subst.csh $oldpatt $newpatt ${pref}_${i}_${suf}.inp  > ${newpref}_${i}_${newsuf}.inp
#./subst.csh $oldpatt2 $newpatt2 ${newpref}_${i}_${newsuf}.inp_tmp  > ${newpref}_${i}_${newsuf}.inp
/net/orinoco/apps/charmm/c33b1/exec/gnu/charmm_xxlarge < ${newpref}_${i}_${newsuf}.inp > ${newpref}_${i}_${newsuf}.out 
./grepEnergie.sh ${newpref}_${i}_${newsuf}.out > ${newpref}_${i}_${newsuf}.txt
R --no-save --args ${newpref}_${i}_${newsuf}.txt ${nbstep}< calc_energy.r > ${newpref}_${i}_${newsuf}.R_output.txt 
                                                                                          
#rm *tmp*
