/
prop.py
343 lines (284 loc) · 10.6 KB
/
prop.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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
import logging
logger = logging.getLogger(__name__)
"""
everytime when adding a table, remember to add relevant info in
__tables__
class table_name(tables.IsDescription):
d (in the Property class)
than modify the h5.conf in the directory you are working on
"""
import tables
class e2ed(tables.IsDescription):
"""
end-to-end distance data along the time trjectory
VERY STRANGE: docstring doesn't work for subclass of tables.IsDescription 2012-12-13
"""
time = tables.Float32Col(pos=0)
e2ed = tables.Float32Col(pos=1)
e2edx = tables.Float32Col(pos=2)
e2edy = tables.Float32Col(pos=3)
e2edz = tables.Float32Col(pos=4)
class rama(tables.IsDescription):
"""
phi, psi: dihedral angles
aa: amino acid
"""
phi = tables.Float32Col(pos=0)
psi = tables.Float32Col(pos=1)
# For types with a non-fixed size, this sets the size in bytes of individual items in the column.
aa = tables.StringCol(itemsize=10, pos=2)
class rg(tables.IsDescription):
"""
Radius of gyration of C alpha along the time trjectory
"""
time = tables.Float32Col(pos=0)
rg = tables.Float32Col(pos=1)
rg_x = tables.Float32Col(pos=2)
rg_y = tables.Float32Col(pos=3)
rg_z = tables.Float32Col(pos=4)
class omega_percent(tables.IsDescription):
"""
percentage of: cis trans peptide bonds
"""
replica_id = tables.StringCol(itemsize=10, pos=0)
trans_x_pro = tables.Float32Col(pos=1)
cis_x_pro = tables.Float32Col(pos=2)
trans_y_x = tables.Float32Col(pos=3)
cis_y_x = tables.Float32Col(pos=4)
class omega_x_pro_percent(tables.IsDescription):
"""
percentage of: cis trans peptide bonds
"""
replica_id = tables.StringCol(itemsize=10, pos=0)
trans_x_pro = tables.Float32Col(pos=1)
cis_x_pro = tables.Float32Col(pos=2)
class omega_x_y_percent(tables.IsDescription):
"""
percentage of: cis trans peptide bonds
"""
replica_id = tables.StringCol(itemsize=10, pos=0)
trans_y_x = tables.Float32Col(pos=1)
cis_y_x = tables.Float32Col(pos=2)
class dssp(tables.IsDescription):
"""
# This table must be redesigned and do_dssp program modified if you want to
# do all secondary structure(ss) analysis, doing do_dssp for each ss is
# unacceptable.
dssp analysis,
E: extended conformation
H: alpha helix
T: turn
B: isolated bridge
G: 3-10 helix
I: pi helix
C: coil
S: Bend (ono-hydrogen-bond based assignment)
"""
time = tables.Float32Col(pos=0)
structure = tables.UInt32Col(pos=1)
# number of structure types vary, which is a headache!
# Coil = tables.UInt32Col(pos=2)
# b-sheet = tables.Float32Col(pos=3)
# rg_z = tables.Float32Col(pos=4)
class seqspacing(tables.IsDescription):
"""
sequence_spacing
"""
dij = tables.UInt32Col(pos=0)
ave_d = tables.Float32Col(pos=1)
std_d = tables.Float32Col(pos=2)
num_data_points = tables.UInt32Col(pos=3)
class pmf(tables.IsDescription):
"""potential of mean force"""
x = tables.Float32Col(pos=0)
pmf = tables.Float32Col(pos=1)
class entropy(tables.IsDescription):
time = tables.Float32Col(pos=0)
entropy = tables.Float32Col(pos=1)
# number of structure types vary, which is a headache!
# Coil = tables.UInt32Col(pos=2)
# b-sheet = tables.Float32Col(pos=3)
# rg_z = tables.Float32Col(pos=4)
# itemsize : int
# For types with a non-fixed size, this sets the size in bytes of individual items in the column.
# shape : tuple
# Sets the shape of the column. An integer shape of N is equivalent to the tuple (N,).
# dflt :
# Sets the default value for the column.
# pos : int
# Sets the position of column in table. If unspecified, the position will be randomly selected.
class upup(tables.IsDescription):
"""upup along the time trajectory"""
time = tables.Float32Col(pos=0)
upup = tables.UInt32Col(pos=1)
within_0_35nm = tables.UInt32Col(pos=2)
class upun(tables.IsDescription):
"""upun along the time trajectory"""
time = tables.Float32Col(pos=0)
upun = tables.UInt32Col(pos=1)
class unun(tables.IsDescription):
"""unun along the time trajectory"""
time = tables.Float32Col(pos=0)
unun = tables.UInt32Col(pos=1)
class upvp(tables.IsDescription):
"""upvp along the time trajectory"""
time = tables.Float32Col(pos=0)
upvp = tables.UInt32Col(pos=1)
upvp_within_0_35nm = tables.UInt32Col(pos=2)
class upvn(tables.IsDescription):
"""upvn along the time trajectory"""
time = tables.Float32Col(pos=0)
upvn = tables.UInt32Col(pos=1)
class unvn(tables.IsDescription):
"""unvn along the time trajectory"""
time = tables.Float32Col(pos=0)
unvn = tables.UInt32Col(pos=1)
class unvp(tables.IsDescription):
"""unvp along the time trajectory"""
time = tables.Float32Col(pos=0)
unvp = tables.UInt32Col(pos=1)
#################### upv unv ####################
class upv(tables.IsDescription):
"""upv along the time trajectory"""
time = tables.Float32Col(pos=0)
upv = tables.UInt32Col(pos=1)
class unv(tables.IsDescription):
"""unv along the time trajectory"""
time = tables.Float32Col(pos=0)
unv = tables.UInt32Col(pos=1)
######################################RDF######################################
class rdf(tables.IsDescription):
"""rdf along the time trajectory"""
radius = tables.Float32Col(pos=0)
rdf = tables.Float32Col(pos=1)
#############BELOW ARE SCHEMAS FOR PROPERTIES DURING EQUILIBRATION#############
class pot_ener(tables.IsDescription):
"""potential energy along the time during equilibration """
time = tables.Float32Col(pos=0)
pot_ener = tables.Float32Col(pos=1)
class g_mindist(tables.IsDescription):
time = tables.Float32Col(pos=0)
n = tables.UInt32Col(pos=1)
SCHEMA_DICT = {
'e2ed' : e2ed,
'e2ed_wl' : e2ed,
'rg_c_alpha' : rg,
'rg_c_alpha_wl' : rg,
# 'e2ed' : (e2ed, "e2ed"), # end-to-end distance data along the time trjectory
# 'rg_c_alpha' : (rg, "rg"), # Radius of gyration of C alpha along the time trjectory
# 'rg_backbone' : (rg, "rg"), # Radius of gyration of backbone along the time trjectory
'seqspacing' : seqspacing, # sequence spacing
'pmf_e2ed' : pmf, # potential_of_mean_force along e2ed
'omega_percent' : omega_percent, # percentage of cis trans peptide bonds
'omega_x_pro_percent': omega_x_pro_percent,
'omega_x_y_percent': omega_x_y_percent,
'dssp_E': dssp, # dssp_E (b-sheet)
'dssp_H': dssp, # dssp_H (alpha-helix)
'dssp_T': dssp, # dssp_T (hydrogen bonded turn)
'dssp_G': dssp, # dssp_G (3-helix)
'dssp_I': dssp, # dssp_I (5-helix)
'dssp_B': dssp, # dssp_B (residue in isolated beta-bridge)
'dssp_C': dssp, # dssp_C (coil)
'dssp_S': dssp, # dssp_S (Bend)
'dssp_X': dssp, # dssp_X (Bend)
'rama': rama,
'rama_GLY': rama,
'rama_VAL': rama,
'rama_PRO': rama,
'rama_ALA': rama,
'upup': upup,
# 'upun': upun,
'unun': unun,
'unun_wl': unun,
'upvp': upvp, # intermolecular hbond) along the time trajectory
'upvn': upvn, # upvn along the time trajectory
'unvn': unvn, # unvn along the time trajectory
'unvp': unvp, # unvp along the time trajectory
'upv': upv, # upv along the time trajectory',
'unv': unv, # unv along the time trajectory'
# 'rdf_upup': (rdf, 'rdf along the time trajectory'),
# 'rdf_upun': (rdf, 'rdf along the time trajectory'),
# 'rdf_unun': (rdf, 'rdf along the time trajectory'),
# 'rdf_upvp': (rdf, 'rdf along the time trajectory'),
# 'rdf_upvn': (rdf, 'rdf along the time trajectory'),
# 'rdf_unvp': (rdf, 'rdf along the time trajectory'),
# 'rdf_unvn': (rdf, 'rdf along the time trajectory'),
# 'rdf_un1vn': (rdf, 'rdf along the time trajectory'),
# 'rdf_un2vn': (rdf, 'rdf along the time trajectory'),
# 'rdf_un3vn': (rdf, 'rdf along the time trajectory'),
# 'rdf_un1vp': (rdf, 'rdf along the time trajectory'),
# 'rdf_un2vp': (rdf, 'rdf along the time trajectory'),
# 'rdf_un3vp': (rdf, 'rdf along the time trajectory'),
'rdf_c1vn': rdf,
'rdf_c2vn': rdf,
'rdf_c3vn': rdf,
'rdf_c1vp': rdf,
'rdf_c2vp': rdf,
'rdf_c3vp': rdf,
# 'conf_entropy': (entropy, 'entropy with increasing sampling'),
'pot_ener_em': pot_ener,
'g_mindist_HP_W': g_mindist,
'g_mindist_XL_W': g_mindist,
'g_mindist_LYS_W': g_mindist,
'myg_mindist_diff_chain_LYS_LYS': g_mindist,
}
INTERESTED_FIELDS = {
'e2ed' : 'e2ed',
'e2ed_wl' : 'e2ed',
'rg_c_alpha' : 'rg',
'rg_c_alpha_wl' : 'rg',
'upup' : 'upup',
'unun' : 'unun',
'unun_wl' : 'unun',
'upvp': 'upvp',
'upvn': 'upvn',
'unvn': 'unvn',
'unvp': 'unvp',
'upv': 'upv',
'unv': 'unv',
'dssp_E': 'structure',
'dssp_E': 'structure',
'dssp_H': 'structure',
'dssp_T': 'structure',
'dssp_G': 'structure',
'dssp_I': 'structure',
'dssp_B': 'structure',
'dssp_C': 'structure',
'dssp_S': 'structure',
'dssp_X': 'structure',
'seqspacing' : 'ave_d',
'rdf_c1vn': 'rdf',
'rdf_c2vn': 'rdf',
'rdf_c3vn': 'rdf',
'rdf_c1vp': 'rdf',
'rdf_c2vp': 'rdf',
'rdf_c3vp': 'rdf',
'pot_ener_em': 'pot_ener',
'g_mindist_HP_W': 'n',
'g_mindist_XL_W': 'n',
'g_mindist_LYS_W': 'n',
'myg_mindist_diff_chain_LYS_LYS': 'n',
}
# from mysys import read_mysys
# mysys = read_mysys.read()
NO_SCHEMA = ['upup_map', 'unun_map']
class Property(object):
def __init__(self, pn): # p: property name
"""values of d contain two parts: the table class & its description"""
self.name = pn
self.schema = None if pn in NO_SCHEMA else SCHEMA_DICT[pn]
if pn in INTERESTED_FIELDS.keys():
self.ifield = INTERESTED_FIELDS[pn]
# def norm(self, x):
# # x could be sq1, sq2; w, m, etc. depending on mysys
# # THIS design is ugly and not very useful
# if self.name in ['rg_c_alpha', 'rg_wl']:
# return 1
# elif self.name in ['upup', 'upup_map']:
# return mysys[x].hbg
# elif self.name == 'unun':
# return mysys[x].scnpg
# else:
# raise ValueError("unknown norm for analysis: {0}".format(x))
if __name__ == "__main__":
a = e2ed