Kaynağa Gözat

new ladders print

Thomas Forest 5 yıl önce
ebeveyn
işleme
7f1ecf4472

BIN
src/__pycache__/atom.cpython-37.pyc Dosyayı Görüntüle


BIN
src/__pycache__/geom.cpython-37.pyc Dosyayı Görüntüle


BIN
src/__pycache__/pdb.cpython-37.pyc Dosyayı Görüntüle


BIN
src/__pycache__/structure.cpython-37.pyc Dosyayı Görüntüle


+ 28 - 105
src/atom.py Dosyayı Görüntüle

@@ -243,7 +243,6 @@ def get_bridges(residues):
243 243
     bridges = {}
244 244
     bridge = {}
245 245
     strongest_bridge = {}
246
-    selected_bridges = []
247 246
     for i in range(1,len(residues)-4):
248 247
         E_min = 0
249 248
         for j in range(i+2,len(residues)-1):
@@ -293,47 +292,23 @@ def get_bridges(residues):
293 292
                 if(bridge['res1']+bridge['res2']<E_min):
294 293
                     E_min = bridge['res1']+bridge['res2']
295 294
                     strongest_bridge = bridge
296
-                    if strongest_bridge not in selected_bridges:
297
-                        selected_bridges.append(strongest_bridge)
298 295
                     coord_bridge = [i,j]
299 296
                     bridge = {}
300 297
 
301 298
         # finally add the strongest bridge at i and j pos
302 299
         if(strongest_bridge):
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']]))
300
+
301
+            bridges[strongest_bridge['i']] = (Bridge(strongest_bridge['btype'],
302
+                                                     strongest_bridge['ipos'],
303
+                                                     strongest_bridge['jpos'],
304
+                                                     [strongest_bridge['i'],
305
+                                                      strongest_bridge['j']]))
331 306
                                               
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']]))
307
+            bridges[strongest_bridge['j']] = (Bridge(strongest_bridge['btype'],
308
+                                                     strongest_bridge['ipos'],
309
+                                                     strongest_bridge['jpos'],
310
+                                                     [strongest_bridge['i'],
311
+                                                      strongest_bridge['j']]))
337 312
     if(len(bridges)>0):
338 313
         return(bridges)
339 314
     else:
@@ -366,12 +341,21 @@ def connected_ladders(ladd_1, ladd_2):
366 341
     links = []
367 342
     for bridge in ladd_1['bridges']:
368 343
         if bridge.res_partner in res_list(ladd_2):
369
-            # return([ladd_1['i'], ladd_1['j'], bridge.i, bridge.j,
370
-            #         ladd_2['i'], ladd_2['j']])
371 344
             return ladd_2
372 345
 
373 346
     return False
374 347
 
348
+def connected_ladders2(ladd_1, ladd_2):
349
+    links = []
350
+    for bridge in ladd_1['bridges']:
351
+        if bridge.res_partner in res_list(ladd_2):
352
+            return([ladd_1['i'], ladd_1['j'], bridge.i, bridge.j,
353
+                    ladd_2['i'], ladd_2['j']])
354
+            #return ladd_2
355
+
356
+    return False
357
+
358
+
375 359
 def get_sheets(ladders):
376 360
     """
377 361
     Bridges between ladders.
@@ -413,80 +397,19 @@ def get_sheets2(ladders):
413 397
     sheets = {}    
414 398
     for ladder in ladders:
415 399
         for ladd2 in ladders:
416
-           if connected_ladders(ladders[ladder], ladders[ladd2]):
417
-               pass
418
-               print("ladder",ladders[ladder]['i'], ladders[ladder]['j'],"bridge",bridge.i, bridge.j,
419
-                    "ladder 2",ladders[ladd2]['i'], ladders[ladd2]['j'])
400
+            if connected_ladders(ladders[ladder], ladders[ladd2]):
401
+                bridge_i = connected_ladders2(ladders[ladder], ladders[ladd2])[2]
402
+                bridge_j = connected_ladders2(ladders[ladder], ladders[ladd2])[3]
403
+                print("ladder",ladders[ladder]['i'], ladders[ladder]['j'],"bridge",bridge_i, bridge_j,
404
+                      "ladder 2",ladders[ladd2]['i'], ladders[ladd2]['j'])
420 405
 
421 406
                
422 407
 def res_list(ladder):
423 408
     # TODO : method in ladder class
424 409
     l=[]
425
-    for i in range(ladder['start'], ladder['end']):
410
+    for i in range(ladder['i'], ladder['j']):
426 411
         l.append(i)
427 412
     return(l)
428
-                   
429
-def get_bends(residues):
430
-    bends = {}
431
-    for i in range(2,len(residues)-2):
432
-        angle = math.degrees(vector_angles(vectors_substr(position_vector(residues[i].atoms["CA"].coords),
433
-                                                          position_vector(residues[i-2].atoms["CA"].coords)),
434
-                                           vectors_substr(position_vector(residues[i+2].atoms["CA"].coords),
435
-                                                          position_vector(residues[i].atoms["CA"].coords))))
436
-        if(angle>70):
437
-            print("angle", residues[i].resid, angle)
438
-            bends[residues[i].resid] = angle
439
-    return(bends)
440
-
441
-def get_chirality(residues):
442
-
443
-    for i in range(1,len(residues)-2):
444
-        chirality = {}
445
-        angle = calc_dihedral(residues[i-1].atoms["CA"].coords,
446
-                              residues[i].atoms["CA"].coords,
447
-                              residues[i+1].atoms["CA"].coords,
448
-                              residues[i+2].atoms["CA"].coords)
449
-        
450
-        if(angle>0 and angle<=180):
451
-            sign="+"
452
-            print("chirality", residues[i].resid, "+", angle)
453
-            
454
-        if(angle<=0 and angle > -180):
455
-            sign="-"
456
-            print("chirality", residues[i].resid, "-", angle)
457
-            
458
-        chirality[residues[i].resid] = sign
459
-        
460
-    return chirality
461
-
462
-
463
-def get_phi_psi(residues):
464
-    for i in range(len(residues)):
465
-        if(i==0):
466
-            phi = 360.0
467
-        else:
468
-            phi = calc_dihedral(residues[i-1].atoms["C"].coords,
469
-                                residues[i].atoms["N"].coords,
470
-                                residues[i].atoms["CA"].coords,
471
-                                residues[i].atoms["C"].coords)
472
-        if(i==len(residues)-1):
473
-            psi = 360.0
474
-        else:
475
-            psi = calc_dihedral(residues[i].atoms["N"].coords,
476
-                                residues[i].atoms["CA"].coords,
477
-                                residues[i].atoms["C"].coords,
478
-                                residues[i+1].atoms["N"].coords)
479
-
480
-        print("ANGLES", i, phi, psi)
481
-
482
-def get_TCO(res1, res2):
483
-    CO_res1 = vector_from_pos(res1.atoms["C"].coords,
484
-                              res1.atoms["O"].coords)
485
-    CO_res2 = vector_from_pos(res2.atoms["C"].coords,
486
-                              res2.atoms["O"].coords)
487
-    angle = vector_angles(CO_res1, CO_res2)
488
-    return(math.cos(angle))
489
-
490 413
 
491 414
 def build_turns_patterns(residues):
492 415
     turns_3 = {}

+ 12 - 3
src/dssp.py Dosyayı Görüntüle

@@ -79,7 +79,6 @@ for i,res in enumerate(residues):
79 79
     turn_3 = print_turn_pattern(residues, res, turns[0])
80 80
     turn_4 = print_turn_pattern(residues, res, turns[1])
81 81
     turn_5 = print_turn_pattern(residues, res, turns[2])
82
-
83 82
     helix_3 = print_helix_pattern(residues, res, helix[0])
84 83
     helix_4 = print_helix_pattern(residues, res, helix[1])
85 84
     helix_5 = print_helix_pattern(residues, res, helix[2])
@@ -91,5 +90,15 @@ for i,res in enumerate(residues):
91 90
            round(alpha, 1), round(phi, 1), round(psi,1), round(x_ca,1), round(y_ca,1), round(z_ca,1))
92 91
 
93 92
 
94
-for bridge in bridges:
95
-    print(bridges[bridge].i, bridges[bridge].j)
93
+for ladd1 in ladders:
94
+    ladd_1 = ladders[ladd1]
95
+    for ladd2 in ladders:
96
+        ladd_2 = ladders[ladd2]
97
+        for bridge in ladd_1['bridges']:
98
+            if bridge.j in res_list(ladd_2):  
99
+                print("ladder", ladd_1['i'],"-",ladd_1['j'], "|", bridge.i, "...", bridge.j, "| ladder", ladd_2['i'], ladd_2['j'])
100
+
101
+# for ind, sheet in sheets.items():
102
+#     print(ind, sheet)
103
+#     for ladder in sheet:
104
+#         print(ladder['start'], ladder['end'])

+ 1 - 7
src/structure.py Dosyayı Görüntüle

@@ -14,19 +14,13 @@ class Turn(Structure):
14 14
                         
15 15
 class Bridge(Structure):
16 16
 
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):
17
+    def __init__(self, bridge_type, res_num, res_partner, indices):
20 18
         self.bridge_type = bridge_type
21 19
         self.res_num = res_num
22 20
         self.res_partner = res_partner
23 21
         Structure.res = res_num
24 22
         self.i = indices[0]
25 23
         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
30 24
 
31 25
 class Helix(Structure):
32 26