-
Notifications
You must be signed in to change notification settings - Fork 0
/
opt_jobs.py
155 lines (123 loc) · 4.65 KB
/
opt_jobs.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
import os
import numpy as np
class Work:
def __init__(self, seq, grid, name):
self.seq = seq
self.grid = grid
self.name = name
def minimization(self):
text = """Stage 1 - minimisation
&cntrl
imin=1, maxcyc=1000, ncyc=500,
cut=999., rgbmax=999.,igb=1, ntb=0,
ntpr=100
/
"""
g = open('min1.in','w')
g.write(text)
g.close()
def heating(self):
f = open('heat1.in','w')
f.write("""Stage 1 heating from 0 to 325K
&cntrl
imin=0, irest=0, ntx=1,
nstlim=100000, dt=0.0005,
ntc=2, ntf=2,
ntt=1, tautp=1.0,
tempi=0.0, temp0=325.0,
ntpr=50, ntwx=50,
ntb=0, igb=1,
cut=999.,rgbmax=999.
/
""")
f.close()
def equillibrium(self):
f = open('equil1.in','w')
f.write("""Stage 2 equilibration 25000-ps
&cntrl
imin=0, irest=1, ntx=5,
nstlim=1000000, dt=0.002,
ntc=2, ntf=2,
ntt=1, tautp=0.5,
tempi=325.0, temp0=325.0,
ntpr=500, ntwx=500,
ntb=0, igb=1,
cut=999.,rgbmax=999.
/
""")
f.close()
def gen_CA_pdb(self):
st = 'MODEL 0\n'
for i in range (len(self.seq)):
l = ['ATOM', str(i+1), 'CA', self.seq[i], 'A', str(i+1), self.grid[i][0], self.grid[i][1], self.grid[i][2], '1.00', '0.00', 'C']
#print ("{:>4}{:>7}{:>2} {:>5}{:>2}{:>4}{:>12}{:>8}{:>8}{:>6}{:>6}{:>12}".format(*l))
st += "{:>4}{:>7}{:>4} {:>4}{:>2}{:>4}{:>12}{:>8}{:>8}{:>6}{:>6}{:>12}".format(*l)+'\n'
st += 'ENDMDL'
g = open(self.name+'_CA.pdb','w')
g.write(st)
g.close()
#os.system('java apps.BBQ -ip='+self.name+'_CA.pdb')
#os.system('/users/nirajv/scwrl4/Scwrl4 -i '+self.name+'_CA-bb.pdb'+ ' -o '+self.name+'_gen.pdb')
#os.system('/Users/47510753/Downloads/Scwrl4 -i '+self.name+'_CA-bb.pdb'+ ' -o '+self.name+'_gen.pdb')
#tf = open(self.name+'_gen.pdb', 'r')
#lines = tf.readlines()
#tf.close()
#os.system('reduce '+ self.name + '_gen.pdb' + ' -trim > ' + self.name + '_gen.pdb')
#tf2 = open(self.name+'_gen.pdb', 'r')
#lines2 = tf2.readlines()
#tf2.close()
#if len(lines2) < 3:
# g = open(self.name+'_gen.pdb', 'w')
# g.write(''.join(lines))
# g.close()
st=''
st+='source leaprc.protein.ff14SB\n'
st+='pro = loadpdb '+self.name+'_CA.pdb'+'\n'
st+='savepdb pro '+' '+self.name+'_init.pdb\n'
st+='saveamberparm pro '+self.name+'.prmtop'+' '+self.name+'.inpcrd\n'
st+='quit\n'
g = open('xleap_input','w')
g.write(st)
g.close()
os.system('tleap -f xleap_input')
print ('Initial Minimization of the structure ...')
self.minimization()
st = 'sander -O -i min1.in -o min1.out -p name.prmtop -c name.inpcrd -r min1.rst'
st = st.replace('name',self.name)
os.system(st)
print ('Heating ...')
self.heating()
st = 'sander -O -i heat1.in -o heat1.out -p name.prmtop -c min1.rst -r heat1.rst -x heat1.mdcrd'
st = st.replace('name',self.name)
os.system(st)
print ('Equillibrium structure simulation ...')
self.equillibrium()
st = """sander -O -i equil1.in -p name.prmtop -c heat1.rst -r equil1.rst -o equil1.out -x equil1.mdcrd"""
st = st.replace('name',self.name)
os.system(st)
print ('Saving pdb file ...')
st = "ambpdb -p name.prmtop -c equil1.rst > name_gen.pdb"
st = st.replace('name',self.name)
os.system(st)
if __name__ == '__main__':
name = '1k43'
seq = ['ARG', 'GLY', 'LYS', 'TRP', 'THR', 'TYR', 'ASN', 'GLY', 'ILE', 'THR', 'TYR', 'GLU', 'GLY', 'ARG']
grid = np.array([[0.0, 0.0, 0.0],
[3.78, 0.0, 0.0],
[7.56, 0.0, 0.0],
[11.35, 0.0, 0.0],
[15.14, 0.0, 0.0],
[18.92, 0.0, 0.0],
[22.71, 0.0, 0.0],
[26.49, 0.0, 0.0],
[30.28, 0.0, 0.0],
[34.06, 0.0, 0.0],
[37.84, 0.0, 0.0],
[41.63, 0.0, 0.0],
[45.42, 0.0, 0.0],
[49.20, 0.0, 0.0]])
w = Work(seq, grid, name)
w.gen_CA_pdb()
# for making pdb from CA
# java apps.BBQ -bbq.fix_r12=T -ip=1k43_CA.pdb
# add side chains via SCWRL