-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.py
executable file
·294 lines (251 loc) · 9.3 KB
/
make.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# 16 April 2018, Moeen Meigooni
# usage:
# if using structures straight from charmmgui:
# copy charmm-gui folder into dir
# set from_charmmgui to True
# python make_cg_lipid.py
# if using other structures i.e. building out of patches from charmmgui:
# mkdir 00-system
# name custom structure lipid.pdb, lipid.psf and place in 00-system
# set from_charmmgui to False
# python make_cg_lipid.py
#########################################################################
import os
# user defined var
sys = 'het_CDL1_20'
from_charmmgui = True # is structure file coming straight from charmm-gui?
solvent_x_dir = 0 # plus or minus solvation direction
solvent_y_dir = 0
solvent_z_dir = 50
spdb = '/Scr/meigoon2/curve/cg/files/02-solvate-ionize/cg-waterbox/cgwaterbox-90W-10WAF-100A-QQQ.pdb'
spsf = '/Scr/meigoon2/curve/cg/files/02-solvate-ionize/cg-waterbox/cgwaterbox-90W-10WAF-100A-QQQ.psf'
stop = '/Scr/meigoon2/curve/cg/files/04-cgc-top-par-files/martini-top/martini-water.top'
params = ['martini_v2.2.namd.prm',
'martini_CDL1.par',
'martini_DOPC.par']
prod1_run = 10000000 # 200 ns
os.system('mkdir 00-system 01-solvate-ionize 02-mineq 03-prod')
# 00
if from_charmmgui:
os.system('cp charmm-gui/step4_lipid.pdb 00-system/lipid.pdb')
os.system('cp charmm-gui/step4_lipid.psf 00-system/lipid.psf')
# 01
os.chdir('01-solvate-ionize')
os.system('cp /Scr/meigoon2/curve/cg/files/04-cgc-top-par-files/martini-top/martini-ions.top .')
with open('solvate-ionize.tcl', 'w') as f:
f.write('source /Scr/meigoon2/curve/cg/files/05-scripts/solvate.tcl \n')
if solvent_x_dir == 0 and solvent_y_dir == 0:
f.write('solvate ../00-system/lipid.psf ../00-system/lipid.pdb -o lipid_water -s W -b 5 -z %i +z %i -spsf %s -spdb %s -stop %s -ks "name W WAF" -ws 100 \n'%(solvent_z_dir, solvent_z_dir, spsf, spdb, stop))
elif solvent_x_dir != 0 and solvent_y_dir == 0:
f.write('solvate ../00-system/lipid.psf ../00-system/lipid.pdb -o lipid_water -s W -b 5 -x %i -z %i +x %i +z %i -spsf %s -spdb %s -stop %s -ks "name W WAF" -ws 100 \n'%(solvent_x_dir, solvent_z_dir, solvent_x_dir, solvent_z_dir, spsf, spdb, stop))
else:
f.write('solvate ../00-system/lipid.psf ../00-system/lipid.pdb -o lipid_water -s W -b 5 -x %i -y %i -z %i +x %i +y %i +z %i -spsf %s -spdb %s -stop %s -ks "name W WAF" -ws 100 \n'%(solvent_x_dir, solvent_y_dir, solvent_z_dir, solvent_x_dir, solvent_y_dir, solvent_z_dir, spsf, spdb, stop))
f.write('\n')
f.write('source /Scr/meigoon2/curve/cg/files/05-scripts/cg-ionize.tcl \n')
f.write('autoionize -psf lipid_water.psf -pdb lipid_water.pdb -sc 0.15 -o lipid_water_ions \n')
f.write('\n')
f.write('set all [atomselect top all] \n')
f.write('set minmax [measure minmax $all] \n')
f.write('puts "cellBasisVector1 [expr {[lindex [lindex $minmax 1] 0] - [lindex [lindex $minmax 0] 0]}] 0 0" \n')
f.write('puts "cellBasisVector2 0 [expr {[lindex [lindex $minmax 1] 1] - [lindex [lindex $minmax 0] 1]}] 0" \n')
f.write('puts "cellBasisVector3 0 0 [expr {[lindex [lindex $minmax 1] 2] - [lindex [lindex $minmax 0] 2]}]" \n')
f.write('puts "cellOrigin [measure center $all weight none]" \n')
f.write('exit \n')
f.write('\n')
with open('run.sh', 'w') as f:
f.write('vmd -dispdev text -e solvate-ionize.tcl > solvate-ionize.log & \n')
f.write('wait \n')
os.system('chmod +x run.sh')
os.system('./run.sh')
os.chdir('..')
# 02
os.chdir('02-mineq')
os.system('mkdir output')
pbcs = []
with open('../01-solvate-ionize/solvate-ionize.log', 'r') as f:
w = f.readlines()
for wi in w:
if wi[0:4] == 'cell':
pbcs.append(wi)
with open('mineq.namd', 'w') as f:
f.write("""#############################################################
## JOB DESCRIPTION ##
#############################################################
#
# Initial minimization and equilibration of the coarse-grained system.
#
#############################################################
## ADJUSTABLE PARAMETERS ##
#############################################################
set outputname output/mineq
set restart 0
set temperature 310
cosAngles on
structure ../01-solvate-ionize/lipid_water_ions.psf
coordinates ../01-solvate-ionize/lipid_water_ions.pdb
temperature $temperature
firsttimestep 0
#############################################################
## SIMULATION PARAMETERS ##
#############################################################
# Input
paraTypeCharmm on
""")
for param in params:
f.write('parameters ../toppar/%s \n'%param)
f.write("""
# Force-Field Parameters
exclude 1-2
1-4scaling 1.0
cutoff 12.0
martiniSwitching on
switching on
PME off
switchdist 9.0
pairlistdist 14.0
dielectric 15.0
# Integrator Parameters
timestep 20.0
nonbondedFreq 1
stepspercycle 10
# Constant Temperature Control
langevin yes ;# do langevin dynamics
langevinDamping 1 ;# damping coefficient (gamma) of 1/ps
langevinTemp $temperature
langevinHydrogen off ;# don't couple langevin bath to hydrogens
# Periodic Boundary Conditions
if {$restart == 0} {
""")
for pbc in pbcs:
f.write(pbc)
f.write("""}
wrapAll on
# Constant Pressure Control (variable volume)
useGroupPressure no
useFlexibleCell yes
useConstantArea no
useConstantRatio yes
langevinPiston yes
langevinPistonTarget 1.01325 ;# in bar -> 1 atm
langevinPistonPeriod 2000. #usually 2000 for RBCG system
langevinPistonDecay 1000. #usually 1000 for RBCG system
langevinPistonTemp $temperature
# Output
outputName $outputname
restartfreq 1000
dcdfreq 1000
xstFreq 1000
outputEnergies 1000
outputPressure 1000
#############################################################
## EXECUTION SCRIPT ##
#############################################################
if {$restart == 0} {
minimize 5000
reinitvels $temperature
}
run 50000
""")
os.chdir('..')
# 03
os.chdir('03-prod')
os.system('mkdir output')
with open('prod1.namd', 'w') as f:
f.write("""proc get_first_ts { xscfile } {
set fd [open $xscfile r]
gets $fd
gets $fd
gets $fd line
set ts [lindex $line 0]
close $fd
return $ts
}
#############################################################
## JOB DESCRIPTION ##
#############################################################
#
# Production simulation of the coarse-grained system.
#
#############################################################
## ADJUSTABLE PARAMETERS ##
#############################################################
set outputname output/prod1
set restart 1
set temperature 310
cosAngles on
structure ../01-solvate-ionize/lipid_water_ions.psf
coordinates ../01-solvate-ionize/lipid_water_ions.pdb
if {$restart == 1} {
set inputname ../02-mineq/output/mineq
binCoordinates $inputname.restart.coor
binVelocities $inputname.restart.vel ;# remove the "temperature" entry if you use this!
extendedSystem $inputname.restart.xsc
} else {
temperature $temperature
}
set firsttime [get_first_ts $inputname.restart.xsc]
firsttimestep $firsttime
#############################################################
## SIMULATION PARAMETERS ##
#############################################################
# Input
paraTypeCharmm on
""")
for param in params:
f.write('parameters ../toppar/%s \n'%param)
f.write("""
# Force-Field Parameters
exclude 1-2
1-4scaling 1.0
cutoff 12.0
martiniSwitching on
switching on
PME off
switchdist 9.0
pairlistdist 14.0
dielectric 15.0
# Integrator Parameters
timestep 20.0
nonbondedFreq 1
stepspercycle 10
# Constant Temperature Control
langevin yes ;# do langevin dynamics
langevinDamping 1 ;# damping coefficient (gamma) of 1/ps
langevinTemp $temperature
langevinHydrogen off ;# don't couple langevin bath to hydrogens
# Periodic Boundary Conditions
if {$restart == 0} {
cellBasisVector1 279.00 0 0
cellBasisVector2 0 271.76 0
cellBasisVector3 0 0 163.22
cellOrigin -0.2923417091 1.4583858251 -0.1471934169
}
wrapAll on
# Constant Pressure Control (variable volume)
useGroupPressure no
useFlexibleCell yes
useConstantArea yes
useConstantRatio no
langevinPiston yes
langevinPistonTarget 1.01325 ;# in bar -> 1 atm
langevinPistonPeriod 2000. #usually 2000 for RBCG system
langevinPistonDecay 1000. #usually 1000 for RBCG system
langevinPistonTemp $temperature
# Output
outputName $outputname
restartfreq 1000
dcdfreq 1000
xstFreq 1000
outputEnergies 1000
outputPressure 1000
#############################################################
## EXECUTION SCRIPT ##
#############################################################
if {$restart == 0} {
minimize 5000
reinitvels $temperature
}
run %i
"""%prod1_run)
os.chdir('..')
print('\nFinished!')