Sfoglia il codice sorgente

Before dropping bp2

Thomas Forest 5 anni fa
parent
commit
de6f723d2f
3 ha cambiato i file con 57 aggiunte e 14 eliminazioni
  1. 39 11
      src/atom.py
  2. 11 2
      src/dssp.py
  3. 7 1
      src/structure.py

+ 39 - 11
src/atom.py Vedi File

@@ -243,11 +243,12 @@ def get_bridges(residues):
243 243
     bridges = {}
244 244
     bridge = {}
245 245
     strongest_bridge = {}
246
+    selected_bridges = []
246 247
     for i in range(1,len(residues)-4):
247 248
         E_min = 0
248 249
         for j in range(i+2,len(residues)-1):
249 250
             # select triplet with the minimal energy 
250
-
251
+            
251 252
             if(residues[i-1].h_bond(residues[j])<-0.5
252 253
                and residues[j].h_bond(residues[i+1])<-0.5):
253 254
                 bridge = {'res1':residues[i-1].h_bond(residues[j]),
@@ -292,20 +293,47 @@ def get_bridges(residues):
292 293
                 if(bridge['res1']+bridge['res2']<E_min):
293 294
                     E_min = bridge['res1']+bridge['res2']
294 295
                     strongest_bridge = bridge
296
+                    if strongest_bridge not in selected_bridges:
297
+                        selected_bridges.append(strongest_bridge)
295 298
                     coord_bridge = [i,j]
296 299
                     bridge = {}
300
+
297 301
         # finally add the strongest bridge at i and j pos
298 302
         if(strongest_bridge):
299
-            bridges[strongest_bridge['i']] = (Bridge(strongest_bridge['btype'],
300
-                                                     strongest_bridge['ipos'],
301
-                                                     strongest_bridge['jpos'],
302
-                                                     [strongest_bridge['i'],
303
-                                                      strongest_bridge['j']]))
304
-            bridges[strongest_bridge['j']] = (Bridge(strongest_bridge['btype'],
305
-                                               strongest_bridge['jpos'],
306
-                                               strongest_bridge['ipos'],
307
-                                               [strongest_bridge['i'],
308
-                                               strongest_bridge['j']]))
303
+            if(len(selected_bridges)>1):
304
+                bridges[strongest_bridge['i']] = (Bridge(strongest_bridge['btype'],
305
+                                                         strongest_bridge['ipos'],
306
+                                                         strongest_bridge['jpos'],
307
+                                                         [strongest_bridge['i'],
308
+                                                          strongest_bridge['j']],
309
+                                                         selected_bridges[-2]['btype'],
310
+                                                         selected_bridges[-2]['ipos'],
311
+                                                         selected_bridges[-2]['jpos'],
312
+                                                         [selected_bridges[-2]['i'],
313
+                                                          selected_bridges[-2]['j']]))
314
+                                              
315
+                bridges[strongest_bridge['j']] = (Bridge(strongest_bridge['btype'],
316
+                                                         strongest_bridge['ipos'],
317
+                                                         strongest_bridge['jpos'],
318
+                                                         [strongest_bridge['i'],
319
+                                                          strongest_bridge['j']],
320
+                                                         selected_bridges[-2]['btype'],
321
+                                                         selected_bridges[-2]['ipos'],
322
+                                                         selected_bridges[-2]['jpos'],
323
+                                                         [selected_bridges[-2]['i'],
324
+                                                          selected_bridges[-2]['j']]))
325
+            else:
326
+                bridges[strongest_bridge['i']] = (Bridge(strongest_bridge['btype'],
327
+                                                         strongest_bridge['ipos'],
328
+                                                         strongest_bridge['jpos'],
329
+                                                         [strongest_bridge['i'],
330
+                                                          strongest_bridge['j']]))
331
+                                              
332
+                bridges[strongest_bridge['j']] = (Bridge(strongest_bridge['btype'],
333
+                                                         strongest_bridge['ipos'],
334
+                                                         strongest_bridge['jpos'],
335
+                                                         [strongest_bridge['i'],
336
+                                                          strongest_bridge['j']]))
309 337
     if(len(bridges)>0):
310 338
         return(bridges)
311 339
     else:

+ 11 - 2
src/dssp.py Vedi File

@@ -61,6 +61,8 @@ ladders = get_ladders(bridges, residues)
61 61
 sheets = get_sheets(ladders)  
62 62
 helix = build_helix_patterns(residues)
63 63
 # iterating over residues
64
+
65
+
64 66
 for i,res in enumerate(residues):
65 67
     #res.get_turns(residues, turns)
66 68
     kappa = res.get_bends(residues)[0]
@@ -81,6 +83,13 @@ for i,res in enumerate(residues):
81 83
     helix_3 = print_helix_pattern(residues, res, helix[0])
82 84
     helix_4 = print_helix_pattern(residues, res, helix[1])
83 85
     helix_5 = print_helix_pattern(residues, res, helix[2])
84
-    
85
-    print(i+1, res.resid, res.chain_id, res.res_letter, helix_3, helix_4, helix_5, turn_3, turn_4, turn_5, bend_symbol, chirality, round(t_co, 3), round(kappa,1),
86
+    if i in bridges.keys():
87
+        bp1 = bridges[i].j
88
+    else:
89
+        bp1 = 0
90
+    print(i+1, res.resid, res.chain_id, res.res_letter, helix_3, helix_4, helix_5, turn_3, turn_4, turn_5, bend_symbol, chirality, bp1,round(t_co, 3), round(kappa,1),
86 91
            round(alpha, 1), round(phi, 1), round(psi,1), round(x_ca,1), round(y_ca,1), round(z_ca,1))
92
+
93
+
94
+for bridge in bridges:
95
+    print(bridges[bridge].i, bridges[bridge].j)

+ 7 - 1
src/structure.py Vedi File

@@ -14,13 +14,19 @@ class Turn(Structure):
14 14
                         
15 15
 class Bridge(Structure):
16 16
 
17
-    def __init__(self, bridge_type, res_num, res_partner, indices):
17
+    def __init__(self, bridge_type, res_num, res_partner, indices,
18
+                 second_bridge_type=None, second_resnum=None,
19
+                 second_res_partner=None, second_indices=None):
18 20
         self.bridge_type = bridge_type
19 21
         self.res_num = res_num
20 22
         self.res_partner = res_partner
21 23
         Structure.res = res_num
22 24
         self.i = indices[0]
23 25
         self.j = indices[1]
26
+        self.second_bridge_type = second_bridge_type
27
+        self.second_resnum = second_resnum
28
+        self.second_res_partner = second_res_partner
29
+        self.second_indices = second_indices
24 30
 
25 31
 class Helix(Structure):
26 32