Browse Source

Implemented bridge search algorithm

Thomas Forest 5 years ago
parent
commit
d745b942bd
2 changed files with 45 additions and 23 deletions
  1. 38 22
      src/atom.py
  2. 7 1
      src/dssp.py

+ 38 - 22
src/atom.py View File

262
     links = []
262
     links = []
263
     for bridge in ladd_1['bridges']:
263
     for bridge in ladd_1['bridges']:
264
         if bridge.res_partner in res_list(ladd_2):
264
         if bridge.res_partner in res_list(ladd_2):
265
-            return([ladd_1['i'], ladd_1['j'], bridge.i, bridge.j,
266
-                    ladd_2['i'], ladd_2['j']])
265
+            # return([ladd_1['i'], ladd_1['j'], bridge.i, bridge.j,
266
+            #         ladd_2['i'], ladd_2['j']])
267
+            return ladd_2
267
 
268
 
268
     return False
269
     return False
269
 
270
 
276
     """
277
     """
277
     ladds = [ elem for elem in ladders.values() ]
278
     ladds = [ elem for elem in ladders.values() ]
278
     sheets = {}
279
     sheets = {}
279
-    i = 0
280
-    while i < len(ladds):
281
-        j = i+1
282
-        ladd = ladds[i]
283
-        ladd1 = ladds[i]
284
-        ladd2 = ladds[j]
285
 
280
 
286
-        while j < len(ladds):
287
-            print(connected_ladders(ladd1, ladd2))
281
+    corresp = {}
282
+    for ladd1 in ladds:
283
+        for ladd2 in ladds:
288
             if connected_ladders(ladd1, ladd2)!=False:
284
             if connected_ladders(ladd1, ladd2)!=False:
289
-                ladd1 = ladd2
290
-                #print(connected_ladders(ladd1, ladd2)[4])
291
-                ladd2 = ladders[connected_ladders(ladd1, ladd2)[4]]
292
-            j+=1
293
-        print(ladd['i'], ladd2['i'])
294
-        i+=1
295
-    # for ladder in ladders:
296
-    #     for ladd2 in ladders:
297
-    #        if connected_ladders(ladders[ladder], ladders[ladd2]):
298
-    #            pass
299
-               #print("ladder",ladders[ladder]['i'], ladders[ladder]['j'],"bridge",bridge.i, bridge.j,
300
-               #      "ladder 2",ladders[ladd2]['i'], ladders[ladd2]['j'])
285
+                corresp_list = [ elem for elem in corresp.keys() ]
286
+                if ladd1['i'] not in corresp_list and ladd2['i'] not in corresp_list:
287
+                    ind = len(sheets.keys())
288
+                    sheets[ind] = []
289
+                    sheets[ind].append(ladd1)
290
+                    sheets[ind].append(ladd2)
291
+                    corresp[ladd1['i']] = ind
292
+                    corresp[ladd2['i']] = ind
293
+                elif ladd2 not in corresp_list and ladd1 in corresp_list:
294
+                    sheets[corresp[ladd1['i']]].append(ladd2)
295
+                    corresp[ladd2['i']] = corresp[ladd1['i']]
296
+                elif ladd1 not in corresp_list and ladd2 in corresp_list:
297
+                    sheets[corresp[ladd2['i']]].append(ladd1)
298
+                    corresp[ladd1['i']] = corresp[ladd2['i']]
299
+                    
300
+    return sheets
301
+
302
+def get_sheets2(ladders):
303
+    """
304
+    Bridges between ladders.
305
+    Check if 1 bridge between one ladder and one or more other ladders.
306
+    Iterate over all residues of one ladder and check if bridge with other residues
307
+    of the other ladders.
308
+    """
309
+    sheets = {}    
310
+    for ladder in ladders:
311
+        for ladd2 in ladders:
312
+           if connected_ladders(ladders[ladder], ladders[ladd2]):
313
+               pass
314
+               print("ladder",ladders[ladder]['i'], ladders[ladder]['j'],"bridge",bridge.i, bridge.j,
315
+                    "ladder 2",ladders[ladd2]['i'], ladders[ladd2]['j'])
301
 
316
 
317
+               
302
 def res_list(ladder):
318
 def res_list(ladder):
303
     # TODO : method in ladder class
319
     # TODO : method in ladder class
304
     l=[]
320
     l=[]

+ 7 - 1
src/dssp.py View File

28
     # get_chirality(pdb_file.residues)
28
     # get_chirality(pdb_file.residues)
29
     bridges = get_bridges(pdb_file.residues)
29
     bridges = get_bridges(pdb_file.residues)
30
     ladders = get_ladders(bridges, pdb_file.residues)
30
     ladders = get_ladders(bridges, pdb_file.residues)
31
-    get_sheets(ladders)  
31
+    sheets = get_sheets(ladders)  
32
 
32
 
33
     # print("NBRIDGES",len(bridges))
33
     # print("NBRIDGES",len(bridges))
34
 
34
 
59
 for i,ladder in enumerate(ladders.values()):
59
 for i,ladder in enumerate(ladders.values()):
60
     print(chr(65+i))
60
     print(chr(65+i))
61
     
61
     
62
+for ind, sheet in sheets.items():
63
+    print(ind, sheet)
64
+    for ladder in sheet:
65
+        print(ladder['start'], ladder['end'])
66
+
67
+