|
@@ -0,0 +1,507 @@
|
|
1
|
+import math
|
|
2
|
+#from structure import *
|
|
3
|
+from geom import *
|
|
4
|
+
|
|
5
|
+class Atom:
|
|
6
|
+
|
|
7
|
+ def dist_atoms(self, atom2):
|
|
8
|
+ return(math.sqrt((self.coord_x-atom2.coord_x)**2 +
|
|
9
|
+ (self.coord_y-atom2.coord_y)**2 +
|
|
10
|
+ (self.coord_z-atom2.coord_z)**2))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+ def __init__(self, atom_id, atom_name, res_name, chain_id,
|
|
14
|
+ res_seq_nb, insertion_code, coordinates):
|
|
15
|
+ self.atom_id = atom_id
|
|
16
|
+ self.atom_name = atom_name
|
|
17
|
+ self.res_name = res_name
|
|
18
|
+ self.chain_id = chain_id
|
|
19
|
+ self.res_seq_nb = res_seq_nb
|
|
20
|
+ self.insertion_code = insertion_code
|
|
21
|
+ self.coord_x = coordinates[0]
|
|
22
|
+ self.coord_y = coordinates[1]
|
|
23
|
+ self.coord_z = coordinates[2]
|
|
24
|
+ self.coords = coordinates
|
|
25
|
+
|
|
26
|
+class Structure:
|
|
27
|
+ def __init__(self, res):
|
|
28
|
+ self.res = res
|
|
29
|
+
|
|
30
|
+class Turn(Structure):
|
|
31
|
+
|
|
32
|
+ def __init__(self, turn_type, res):
|
|
33
|
+ self.turn_type = turn_type
|
|
34
|
+ Structure.res = res
|
|
35
|
+
|
|
36
|
+class Bridge(Structure):
|
|
37
|
+
|
|
38
|
+ def __init__(self, bridge_type, res_num, res_partner, indices):
|
|
39
|
+ self.bridge_type = bridge_type
|
|
40
|
+ self.res_num = res_num
|
|
41
|
+ self.res_partner = res_partner
|
|
42
|
+ Structure.res = res_num
|
|
43
|
+ self.i = indices[0]
|
|
44
|
+ self.j = indices[1]
|
|
45
|
+
|
|
46
|
+class Helix(Structure):
|
|
47
|
+
|
|
48
|
+ def __init__(self, residues, res_num, helix_type):
|
|
49
|
+ self.residues = residues
|
|
50
|
+ self.res_num = res_num
|
|
51
|
+ Structure.res = res_num
|
|
52
|
+ self.helix_type = helix_type
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+class Residue:
|
|
56
|
+ def __init__(self, atoms_list, indice):
|
|
57
|
+ self.atoms = {}
|
|
58
|
+ for atom in atoms_list:
|
|
59
|
+ self.atoms[atom.atom_name] = atom
|
|
60
|
+ self.resid = atom.res_seq_nb
|
|
61
|
+ self.res_name = atom.res_name
|
|
62
|
+ self.res_letter = self.get_amino_letter(atom.res_name)
|
|
63
|
+ self.chain_id = atom.chain_id
|
|
64
|
+ self.insertion_code = atom.insertion_code
|
|
65
|
+ self.indice = indice
|
|
66
|
+
|
|
67
|
+ def get_amino_letter(self, res_name):
|
|
68
|
+ code3 = ['ALA', 'ARG', 'ASN', 'ASP', 'CYS', 'GLU', 'GLN', 'GLY',
|
|
69
|
+ 'HIS', 'ILE', 'LEU', 'LYS', 'MET', 'PHE', 'PRO', 'SER',
|
|
70
|
+ 'THR', 'TRP', 'TYR', 'VAL']
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+ code1 = ['A','R','N','D','C','E','Q','G','H','I','L','K','M','F','P',
|
|
74
|
+ 'S','T','W','Y','V']
|
|
75
|
+
|
|
76
|
+ return code1[code3.index(res_name)]
|
|
77
|
+
|
|
78
|
+ def h_bond(self, res2):
|
|
79
|
+ if("H" not in res2.atoms.keys()):
|
|
80
|
+ return(False)
|
|
81
|
+ # dimensionnal factor, in kcal/mole
|
|
82
|
+ f = 332
|
|
83
|
+ # partial charges
|
|
84
|
+ q1 = 0.42
|
|
85
|
+ q2 = 0.20
|
|
86
|
+ # distance between O-N atoms, in angströms
|
|
87
|
+ r_ON = self.atoms["O"].dist_atoms(res2.atoms["N"])
|
|
88
|
+ # distance between C-H atoms, in angströms
|
|
89
|
+ r_CH = self.atoms["C"].dist_atoms(res2.atoms["H"])
|
|
90
|
+ # distance between O-H atoms, in angströms
|
|
91
|
+ r_OH = self.atoms["O"].dist_atoms(res2.atoms["H"])
|
|
92
|
+ # distance between C-N atoms, in angströms
|
|
93
|
+ r_CN = self.atoms["C"].dist_atoms(res2.atoms["N"])
|
|
94
|
+ # electrostatic interaction energy, in kcal/mole
|
|
95
|
+ E = q1*q2*(1/r_ON + 1/r_CH - 1/r_OH - 1/r_CN)*f
|
|
96
|
+ return(E)
|
|
97
|
+
|
|
98
|
+ def get_turns(self, residues):
|
|
99
|
+ """
|
|
100
|
+ Get all the turns from a specific residue.
|
|
101
|
+ """
|
|
102
|
+ turns = {}
|
|
103
|
+ i = residues.index(self)
|
|
104
|
+ k = 0
|
|
105
|
+ for j in range(3,6):
|
|
106
|
+ if(i+j<len(residues)):
|
|
107
|
+ if(self.h_bond(residues[i+j])<-0.5):
|
|
108
|
+ k = j
|
|
109
|
+ if k != 0:
|
|
110
|
+ #print(k,"TURN", residues[i].resid, residues[i+k].resid)
|
|
111
|
+ return Turn(k,residues[i].resid)
|
|
112
|
+
|
|
113
|
+ return False
|
|
114
|
+
|
|
115
|
+ def get_bends(self, residues):
|
|
116
|
+ i = residues.index(self)
|
|
117
|
+ if i >=2 and i <len(residues)-2:
|
|
118
|
+ angle = math.degrees(vector_angles(vectors_substr(position_vector(residues[i].atoms["CA"].coords),
|
|
119
|
+ position_vector(residues[i-2].atoms["CA"].coords)),
|
|
120
|
+ vectors_substr(position_vector(residues[i+2].atoms["CA"].coords),
|
|
121
|
+ position_vector(residues[i].atoms["CA"].coords))))
|
|
122
|
+ if(angle>70):
|
|
123
|
+ return [angle, 'S']
|
|
124
|
+ return [angle, '']
|
|
125
|
+ else:
|
|
126
|
+ return [360.0, '']
|
|
127
|
+
|
|
128
|
+ def get_bridges(self, residues):
|
|
129
|
+ bridges = {}
|
|
130
|
+ bridge = {}
|
|
131
|
+ strongest_bridge = {}
|
|
132
|
+ i = residues.index(self)
|
|
133
|
+ if(i >= 1 and i < len(residues)-4):
|
|
134
|
+ E_min = 0
|
|
135
|
+ for j in range(i+2,len(residues)-1):
|
|
136
|
+ # select triplet with the minimal energy
|
|
137
|
+
|
|
138
|
+ if(residues[i-1].h_bond(residues[j])<-0.5
|
|
139
|
+ and residues[j].h_bond(residues[i+1])<-0.5):
|
|
140
|
+ bridge = {'res1':residues[i-1].h_bond(residues[j]),
|
|
141
|
+ 'res2':residues[j].h_bond(residues[i+1]),
|
|
142
|
+ 'ipos':residues[i].resid,
|
|
143
|
+ 'jpos':residues[j].resid,
|
|
144
|
+ 'btype':"para"}
|
|
145
|
+
|
|
146
|
+ if(residues[j-1].h_bond(residues[i])<-0.5
|
|
147
|
+ and residues[i].h_bond(residues[j+1])<-0.5):
|
|
148
|
+ bridge = {'res1':residues[j-1].h_bond(residues[i]),
|
|
149
|
+ 'res2':residues[i].h_bond(residues[j+1]),
|
|
150
|
+ 'ipos':residues[i].resid,
|
|
151
|
+ 'jpos':residues[j].resid,
|
|
152
|
+ 'btype':"para"}
|
|
153
|
+
|
|
154
|
+ if(residues[i].h_bond(residues[j])<-0.5
|
|
155
|
+ and residues[j].h_bond(residues[i])<-0.5):
|
|
156
|
+ bridge = {'res1':residues[i].h_bond(residues[j]),
|
|
157
|
+ 'res2':residues[j].h_bond(residues[i]),
|
|
158
|
+ 'ipos':residues[i].resid,
|
|
159
|
+ 'jpos':residues[j].resid,
|
|
160
|
+ 'btype':"anti"}
|
|
161
|
+
|
|
162
|
+ if(residues[i-1].h_bond(residues[j+1])<-0.5
|
|
163
|
+ and residues[j-1].h_bond(residues[i+1])<-0.5):
|
|
164
|
+ bridge = {'res1':residues[i-1].h_bond(residues[j+1]),
|
|
165
|
+ 'res2':residues[j-1].h_bond(residues[i+1]),
|
|
166
|
+ 'ipos':residues[i].resid,
|
|
167
|
+ 'jpos':residues[j].resid,
|
|
168
|
+ 'btype':"anti"}
|
|
169
|
+
|
|
170
|
+ if(bridge):
|
|
171
|
+ if(bridge['res1']+bridge['res2']<E_min):
|
|
172
|
+ E_min = bridge['res1']+bridge['res2']
|
|
173
|
+ strongest_bridge = bridge
|
|
174
|
+ bridge = {}
|
|
175
|
+ coord_bridge = [i,j]
|
|
176
|
+ # finally add the strongest bridge at i and j pos
|
|
177
|
+ if(strongest_bridge):
|
|
178
|
+ bridges[coord_bridge[0]] = (Bridge(strongest_bridge['btype'],
|
|
179
|
+ strongest_bridge['ipos'],
|
|
180
|
+ strongest_bridge['jpos']))
|
|
181
|
+
|
|
182
|
+ bridges[coord_bridge[1]] = (Bridge(strongest_bridge['btype'],
|
|
183
|
+ strongest_bridge['jpos'],
|
|
184
|
+ strongest_bridge['ipos']))
|
|
185
|
+ if(len(bridges)>0):
|
|
186
|
+ return(bridges[coord_bridge[0]])
|
|
187
|
+ else:
|
|
188
|
+ return(False)
|
|
189
|
+
|
|
190
|
+ def get_helix(self, residues):
|
|
191
|
+ """
|
|
192
|
+ Return if there is an helix at a given residue,
|
|
193
|
+ as well as its type.
|
|
194
|
+ """
|
|
195
|
+ i = residues.index(self)
|
|
196
|
+ # if there are no turns or it is the first residue, skip
|
|
197
|
+ if i == 0:
|
|
198
|
+ return False
|
|
199
|
+
|
|
200
|
+ if(self.get_turns(residues) and residues[i-1].get_turns(residues)):
|
|
201
|
+ #print(self.get_turns(residues).turn_type,"- HELIX at", residues[i].indice)
|
|
202
|
+ return(self.get_turns(residues).turn_type, residues[i].indice)
|
|
203
|
+ return(False)
|
|
204
|
+
|
|
205
|
+ def get_ladder(self, residues):
|
|
206
|
+ #ladders = {}
|
|
207
|
+ i = residues.index(self)
|
|
208
|
+ if i != 0:
|
|
209
|
+ if self.get_bridges(residues):
|
|
210
|
+ if (residues[i-1].get_bridges(residues)):
|
|
211
|
+ local_bridge = self.get_bridges(residues)
|
|
212
|
+ consec_bridge = residues[i-1].get_bridges(residues)
|
|
213
|
+ if local_bridge.bridge_type == consec_bridge.bridge_type:
|
|
214
|
+ #print("ladder", consec_bridge.res_num, local_bridge.res_num)
|
|
215
|
+ ladder = {'start':consec_bridge.res_num,
|
|
216
|
+ 'end':local_bridge.res_num,
|
|
217
|
+ 'bridges':[consec_bridge, local_bridge]}
|
|
218
|
+ return ladder
|
|
219
|
+ return False
|
|
220
|
+
|
|
221
|
+ def get_tco(self, residues):
|
|
222
|
+ i = residues.index(self)
|
|
223
|
+ if(i!=0):
|
|
224
|
+ res2 = residues[i-1]
|
|
225
|
+ CO_res1 = vector_from_pos(self.atoms["C"].coords,
|
|
226
|
+ self.atoms["O"].coords)
|
|
227
|
+ CO_res2 = vector_from_pos(res2.atoms["C"].coords,
|
|
228
|
+ res2.atoms["O"].coords)
|
|
229
|
+ angle = vector_angles(CO_res1, CO_res2)
|
|
230
|
+ else:
|
|
231
|
+ angle = math.pi/2
|
|
232
|
+ return(math.cos(angle))
|
|
233
|
+
|
|
234
|
+ def get_chirality(self, residues):
|
|
235
|
+ i = residues.index(self)
|
|
236
|
+ if (i >=1 and i < len(residues)-2):
|
|
237
|
+ chirality = {}
|
|
238
|
+ angle = calc_dihedral(residues[i-1].atoms["CA"].coords,
|
|
239
|
+ residues[i].atoms["CA"].coords,
|
|
240
|
+ residues[i+1].atoms["CA"].coords,
|
|
241
|
+ residues[i+2].atoms["CA"].coords)
|
|
242
|
+
|
|
243
|
+ if(angle>0 and angle<=180):
|
|
244
|
+ sign="+"
|
|
245
|
+
|
|
246
|
+ if(angle<=0 and angle > -180):
|
|
247
|
+ sign="-"
|
|
248
|
+
|
|
249
|
+ else:
|
|
250
|
+ angle = 360.0
|
|
251
|
+ sign = ''
|
|
252
|
+
|
|
253
|
+ return [angle, sign]
|
|
254
|
+
|
|
255
|
+ def get_phi_psi(self, residues):
|
|
256
|
+ i = residues.index(self)
|
|
257
|
+ if(i==0):
|
|
258
|
+ phi = 360.0
|
|
259
|
+ else:
|
|
260
|
+ phi = calc_dihedral(residues[i-1].atoms["C"].coords,
|
|
261
|
+ residues[i].atoms["N"].coords,
|
|
262
|
+ residues[i].atoms["CA"].coords,
|
|
263
|
+ residues[i].atoms["C"].coords)
|
|
264
|
+ if(i==len(residues)-1):
|
|
265
|
+ psi = 360.0
|
|
266
|
+ else:
|
|
267
|
+ psi = calc_dihedral(residues[i].atoms["N"].coords,
|
|
268
|
+ residues[i].atoms["CA"].coords,
|
|
269
|
+ residues[i].atoms["C"].coords,
|
|
270
|
+ residues[i+1].atoms["N"].coords)
|
|
271
|
+
|
|
272
|
+ return((phi, psi))
|
|
273
|
+def get_bridges(residues):
|
|
274
|
+ bridges = {}
|
|
275
|
+ bridge = {}
|
|
276
|
+ strongest_bridge = {}
|
|
277
|
+ for i in range(1,len(residues)-4):
|
|
278
|
+ E_min = 0
|
|
279
|
+ for j in range(i+2,len(residues)-1):
|
|
280
|
+ # select triplet with the minimal energy
|
|
281
|
+
|
|
282
|
+ if(residues[i-1].h_bond(residues[j])<-0.5
|
|
283
|
+ and residues[j].h_bond(residues[i+1])<-0.5):
|
|
284
|
+ bridge = {'res1':residues[i-1].h_bond(residues[j]),
|
|
285
|
+ 'res2':residues[j].h_bond(residues[i+1]),
|
|
286
|
+ 'ipos':residues[i].resid,
|
|
287
|
+ 'jpos':residues[j].resid,
|
|
288
|
+ 'i':residues[i].indice,
|
|
289
|
+ 'j':residues[j].indice,
|
|
290
|
+ 'btype':"para"}
|
|
291
|
+
|
|
292
|
+ if(residues[j-1].h_bond(residues[i])<-0.5
|
|
293
|
+ and residues[i].h_bond(residues[j+1])<-0.5):
|
|
294
|
+ bridge = {'res1':residues[j-1].h_bond(residues[i]),
|
|
295
|
+ 'res2':residues[i].h_bond(residues[j+1]),
|
|
296
|
+ 'ipos':residues[i].resid,
|
|
297
|
+ 'jpos':residues[j].resid,
|
|
298
|
+ 'i':residues[i].indice,
|
|
299
|
+ 'j':residues[j].indice,
|
|
300
|
+ 'btype':"para"}
|
|
301
|
+
|
|
302
|
+ if(residues[i].h_bond(residues[j])<-0.5
|
|
303
|
+ and residues[j].h_bond(residues[i])<-0.5):
|
|
304
|
+ bridge = {'res1':residues[i].h_bond(residues[j]),
|
|
305
|
+ 'res2':residues[j].h_bond(residues[i]),
|
|
306
|
+ 'ipos':residues[i].resid,
|
|
307
|
+ 'jpos':residues[j].resid,
|
|
308
|
+ 'i':residues[i].indice,
|
|
309
|
+ 'j':residues[j].indice,
|
|
310
|
+ 'btype':"anti"}
|
|
311
|
+
|
|
312
|
+ if(residues[i-1].h_bond(residues[j+1])<-0.5
|
|
313
|
+ and residues[j-1].h_bond(residues[i+1])<-0.5):
|
|
314
|
+ bridge = {'res1':residues[i-1].h_bond(residues[j+1]),
|
|
315
|
+ 'res2':residues[j-1].h_bond(residues[i+1]),
|
|
316
|
+ 'ipos':residues[i].resid,
|
|
317
|
+ 'jpos':residues[j].resid,
|
|
318
|
+ 'i':residues[i].indice,
|
|
319
|
+ 'j':residues[j].indice,
|
|
320
|
+ 'btype':"anti"}
|
|
321
|
+
|
|
322
|
+ if(bridge):
|
|
323
|
+ if(bridge['res1']+bridge['res2']<E_min):
|
|
324
|
+ E_min = bridge['res1']+bridge['res2']
|
|
325
|
+ strongest_bridge = bridge
|
|
326
|
+ coord_bridge = [i,j]
|
|
327
|
+ bridge = {}
|
|
328
|
+
|
|
329
|
+ # finally add the strongest bridge at i and j pos
|
|
330
|
+ if(strongest_bridge):
|
|
331
|
+
|
|
332
|
+ bridges[strongest_bridge['i']] = (Bridge(strongest_bridge['btype'],
|
|
333
|
+ strongest_bridge['ipos'],
|
|
334
|
+ strongest_bridge['jpos'],
|
|
335
|
+ [strongest_bridge['i'],
|
|
336
|
+ strongest_bridge['j']]))
|
|
337
|
+
|
|
338
|
+ bridges[strongest_bridge['j']] = (Bridge(strongest_bridge['btype'],
|
|
339
|
+ strongest_bridge['ipos'],
|
|
340
|
+ strongest_bridge['jpos'],
|
|
341
|
+ [strongest_bridge['i'],
|
|
342
|
+ strongest_bridge['j']]))
|
|
343
|
+ if(len(bridges)>0):
|
|
344
|
+ return(bridges)
|
|
345
|
+ else:
|
|
346
|
+ return(False)
|
|
347
|
+
|
|
348
|
+def get_ladders(bridges, residues):
|
|
349
|
+ ladders = {}
|
|
350
|
+ i = 1
|
|
351
|
+ while i < len(residues):
|
|
352
|
+ k = 1
|
|
353
|
+ if i in bridges.keys():
|
|
354
|
+ temp_bridges = [bridges[i]]
|
|
355
|
+ while ((i+k in bridges.keys()) and
|
|
356
|
+ (bridges[i].bridge_type == bridges[i+k].bridge_type)):
|
|
357
|
+ temp_bridges.append(bridges[i+k])
|
|
358
|
+ k+=1
|
|
359
|
+ if k>1:
|
|
360
|
+ #print("ladder", bridges[i].res_num, bridges[i+k-1].res_num)
|
|
361
|
+ ladders[i] = {'start':bridges[i].res_num,
|
|
362
|
+ 'end':bridges[i+k-1].res_num,
|
|
363
|
+ 'bridges':temp_bridges,
|
|
364
|
+ 'i':i,
|
|
365
|
+ 'j':i+k-1}
|
|
366
|
+ i+=k-1
|
|
367
|
+ else:
|
|
368
|
+ i+=1
|
|
369
|
+ return ladders
|
|
370
|
+
|
|
371
|
+def connected_ladders(ladd_1, ladd_2):
|
|
372
|
+ links = []
|
|
373
|
+ for bridge in ladd_1['bridges']:
|
|
374
|
+ if bridge.res_partner in res_list(ladd_2):
|
|
375
|
+ return ladd_2
|
|
376
|
+
|
|
377
|
+ return False
|
|
378
|
+
|
|
379
|
+def connected_ladders2(ladd_1, ladd_2):
|
|
380
|
+ links = []
|
|
381
|
+ for bridge in ladd_1['bridges']:
|
|
382
|
+ if bridge.res_partner in res_list(ladd_2):
|
|
383
|
+ return([ladd_1['i'], ladd_1['j'], bridge.i, bridge.j,
|
|
384
|
+ ladd_2['i'], ladd_2['j']])
|
|
385
|
+ #return ladd_2
|
|
386
|
+
|
|
387
|
+ return False
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+def get_sheets(ladders):
|
|
391
|
+ """
|
|
392
|
+ Bridges between ladders.
|
|
393
|
+ Check if 1 bridge between one ladder and one or more other ladders.
|
|
394
|
+ Iterate over all residues of one ladder and check if bridge with other residues
|
|
395
|
+ of the other ladders.
|
|
396
|
+ """
|
|
397
|
+ ladds = [ elem for elem in ladders.values() ]
|
|
398
|
+ sheets = {}
|
|
399
|
+
|
|
400
|
+ corresp = {}
|
|
401
|
+ for ladd1 in ladds:
|
|
402
|
+ for ladd2 in ladds:
|
|
403
|
+ if connected_ladders(ladd1, ladd2)!=False:
|
|
404
|
+ corresp_list = [ elem for elem in corresp.keys() ]
|
|
405
|
+ if ladd1['i'] not in corresp_list and ladd2['i'] not in corresp_list:
|
|
406
|
+ ind = len(sheets.keys())
|
|
407
|
+ sheets[ind] = []
|
|
408
|
+ sheets[ind].append(ladd1)
|
|
409
|
+ sheets[ind].append(ladd2)
|
|
410
|
+ corresp[ladd1['i']] = ind
|
|
411
|
+ corresp[ladd2['i']] = ind
|
|
412
|
+ elif ladd2 not in corresp_list and ladd1 in corresp_list:
|
|
413
|
+ sheets[corresp[ladd1['i']]].append(ladd2)
|
|
414
|
+ corresp[ladd2['i']] = corresp[ladd1['i']]
|
|
415
|
+ elif ladd1 not in corresp_list and ladd2 in corresp_list:
|
|
416
|
+ sheets[corresp[ladd2['i']]].append(ladd1)
|
|
417
|
+ corresp[ladd1['i']] = corresp[ladd2['i']]
|
|
418
|
+
|
|
419
|
+ return sheets
|
|
420
|
+
|
|
421
|
+def get_sheets2(ladders):
|
|
422
|
+ """
|
|
423
|
+ Bridges between ladders.
|
|
424
|
+ Check if 1 bridge between one ladder and one or more other ladders.
|
|
425
|
+ Iterate over all residues of one ladder and check if bridge with other residues
|
|
426
|
+ of the other ladders.
|
|
427
|
+ """
|
|
428
|
+ sheets = {}
|
|
429
|
+ for ladder in ladders:
|
|
430
|
+ for ladd2 in ladders:
|
|
431
|
+ if connected_ladders(ladders[ladder], ladders[ladd2]):
|
|
432
|
+ bridge_i = connected_ladders2(ladders[ladder], ladders[ladd2])[2]
|
|
433
|
+ bridge_j = connected_ladders2(ladders[ladder], ladders[ladd2])[3]
|
|
434
|
+ print("ladder",ladders[ladder]['i'], ladders[ladder]['j'],"bridge",bridge_i, bridge_j,
|
|
435
|
+ "ladder 2",ladders[ladd2]['i'], ladders[ladd2]['j'])
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+def res_list(ladder):
|
|
439
|
+ # TODO : method in ladder class
|
|
440
|
+ l=[]
|
|
441
|
+ for i in range(ladder['i'], ladder['j']):
|
|
442
|
+ l.append(i)
|
|
443
|
+ return(l)
|
|
444
|
+
|
|
445
|
+def build_turns_patterns(residues):
|
|
446
|
+ turns_3 = {}
|
|
447
|
+ turns_4 = {}
|
|
448
|
+ turns_5 = {}
|
|
449
|
+ for i,res in enumerate(residues):
|
|
450
|
+ turn = residues[i].get_turns(residues)
|
|
451
|
+ if(turn):
|
|
452
|
+ for k in range(turn.turn_type):
|
|
453
|
+ if turn.turn_type == 3:
|
|
454
|
+ turns_3[i+1+k] = turn.turn_type
|
|
455
|
+ if turn.turn_type == 4:
|
|
456
|
+ turns_4[i+1+k] = turn.turn_type
|
|
457
|
+ if turn.turn_type == 5:
|
|
458
|
+ turns_5[i+1+k] = turn.turn_type
|
|
459
|
+ return[turns_3, turns_4, turns_5]
|
|
460
|
+
|
|
461
|
+def build_helix_patterns(residues):
|
|
462
|
+ helix_3 = {}
|
|
463
|
+ helix_4 = {}
|
|
464
|
+ helix_5 = {}
|
|
465
|
+ for i,res in enumerate(residues):
|
|
466
|
+ helix = residues[i].get_helix(residues)
|
|
467
|
+ if(helix):
|
|
468
|
+ helix_type = residues[i].get_helix(residues)[0]
|
|
469
|
+ helix_pos = residues[i].get_helix(residues)[1]
|
|
470
|
+ #print("TYPE", helix_type)
|
|
471
|
+ for k in range(helix_type):
|
|
472
|
+ if helix_type == 3:
|
|
473
|
+ helix_3[i+1+k] = "G"
|
|
474
|
+ if helix_type == 4:
|
|
475
|
+ helix_4[i+1+k] = "H"
|
|
476
|
+ if helix_type == 5:
|
|
477
|
+ helix_5[i+1+k] = "I"
|
|
478
|
+ #print(helix_3)
|
|
479
|
+ return[helix_3, helix_4, helix_5]
|
|
480
|
+
|
|
481
|
+def print_helix_pattern(residues, res, helix):
|
|
482
|
+ i = residues.index(res)+1
|
|
483
|
+ if i in helix.keys():
|
|
484
|
+ return (helix[i])
|
|
485
|
+ else:
|
|
486
|
+ return(' ')
|
|
487
|
+
|
|
488
|
+def print_turn_pattern(residues, res, turns):
|
|
489
|
+ i = residues.index(res)+1
|
|
490
|
+ if i in turns.keys() and not i-1 in turns.keys():
|
|
491
|
+ return(">")
|
|
492
|
+ elif i in turns.keys() and i-1 in turns.keys():
|
|
493
|
+ return(turns[i])
|
|
494
|
+ elif i not in turns.keys() and i-1 in turns.keys():
|
|
495
|
+ return("<")
|
|
496
|
+ else:
|
|
497
|
+ return(' ')
|
|
498
|
+
|
|
499
|
+def raw_ladders_print(ladders, ):
|
|
500
|
+ for ladd1 in ladders:
|
|
501
|
+ ladd_1 = ladders[ladd1]
|
|
502
|
+ for ladd2 in ladders:
|
|
503
|
+ ladd_2 = ladders[ladd2]
|
|
504
|
+ for bridge in ladd_1['bridges']:
|
|
505
|
+ if bridge.j in res_list(ladd_2):
|
|
506
|
+ print("ladder", ladd_1['i'],"-",ladd_1['j'], "|", bridge.i, "...", bridge.j, "| ladder", ladd_2['i'], ladd_2['j'])
|
|
507
|
+
|