#################
# JOB VARIABLES #
#################
start_expt = 1
end_expt = 27
substitution = 'C'
par_dir = '/mindstore/home33ext/kscopino/5JUP_PROTOCOL/PIGGYBACKING/COD1_' + substitution + '2_1S_50PS/'
data_dir = 'COD1_' + substitution + '2_'
#interval_starts = [0,10,20,30,40]
interval_starts = [0]
interval_size = 100
###############
# WRITE FILES #
###############
for i_start in interval_starts:
# file to submit to scheduler
# outfile = open('run_cpptraj_avg_' + str(i_start) + 'to' + str(i_start + interval_size) + '.sh','w')
outfile = open('run_cpptraj_1b_avgstruct.sh','w')
outfile.write('#!/bin/bash\n' +\
'#BSUB -e err_avgstruct\n' +\
'#BSUB -o out_avgstruct\n' +\
'#BSUB -q exx96\n' +\
#'#BSUB -J "cpptraj_' + str(i_start) + 'to' + str(i_start + interval_size) + '_CPU"\n' +\
'#BSUB -J avgstruct_CPU"\n' +\
'#BSUB -n 1\n\n' +\
'# env\n' +\
'export PATH=/home/apps/CENTOS7/amber/amber18/bin:$PATH\n' +\
'export LD_LIBRARY_PATH=/home/apps/CENTOS7/amber/amber18/lib:/home/apps/CENTOS7/amber/amber18/lib64:$LD_LIBRARY_PATH\n' +\
'export PATH=/share/apps/openmpi/1.4.4+intel-12/bin:$PATH\n' +\
'export LD_LIBRARY_PATH=/share/apps/openmpi/1.4.4+intel-12/lib:$LD_LIBRARY_PATH\n\n' +\
'# call cpptraj in Amber18\n' +\
'for i in {' + str(start_expt) + '..' + str(end_expt) + '}; do\n' +\
' cd ' + par_dir + data_dir + '$i/DATA/\n' +\
#' cpptraj -i cpptraj_avg_' + str(i_start) + 'to' + str(i_start + interval_size) + '.in\n' +\
'cpptraj -i cpptraj_1b_avgstruct.in\n' +\
'done\n\n')
outfile.close()
# experimental files
for i in range(start_expt,end_expt + 1):
#outfile = open(par_dir + data_dir + str(i) + '/DATA/cpptraj_avg_' + str(i_start) + 'to' + str(i_start + interval_size) + '.in', 'w')
outfile = open(par_dir + data_dir + str(i) + '/DATA/cpptraj_1b_avgstruct.in','w')
outfile.write('# This script is to create an average structure for each interval of a trajectory.\n\n' +\
'# prmtop file\n' +\
'parm ' + par_dir + '5JUP_GC_179' + substitution + '_nowat.prmtop\n\n' +\
'# experimental neutral dynamics trajectory\n' +\
'trajin ' + par_dir + data_dir + str(i) + '/mdcrd_nd_' + str(i) + '_strip ' + str((i_start*100)+1) + ' ' + str((i_start*100)+interval_size*100) + '\n\n' +\
'# make average\n' +\
#'average avg_struct_' + str(i_start) + 'to' + str(i_start + interval_size) + '.rst restart\n\n')
'average avg_struct.rst restart\n\n')
outfile.close()