Browse Source

Turns pattern display

Thomas Forest 5 years ago
parent
commit
3b73eb5866
2 changed files with 44 additions and 5 deletions
  1. 36 3
      src/atom.py
  2. 8 2
      src/dssp.py

+ 36 - 3
src/atom.py View File

@@ -88,10 +88,11 @@ class Residue:
88 88
                                                               position_vector(residues[i-2].atoms["CA"].coords)),
89 89
                                                vectors_substr(position_vector(residues[i+2].atoms["CA"].coords),
90 90
                                                               position_vector(residues[i].atoms["CA"].coords))))
91
-           
92
-            return angle
91
+            if(angle>70):
92
+                return [angle, 'S']
93
+            return [angle, '']
93 94
         else:
94
-            return 360.0
95
+            return [360.0, '']
95 96
 
96 97
     def get_bridges(self, residues):
97 98
         bridges = {}
@@ -457,3 +458,35 @@ def get_TCO(res1, res2):
457 458
                               res2.atoms["O"].coords)
458 459
     angle = vector_angles(CO_res1, CO_res2)
459 460
     return(math.cos(angle))
461
+
462
+
463
+def build_turns_patterns(residues):
464
+    turns_3 = {}
465
+    turns_4 = {}
466
+    turns_5 = {}
467
+    for i,res in enumerate(residues):
468
+        turn = residues[i].get_turns(residues)
469
+        if(turn):
470
+            for k in range(turn.turn_type):
471
+                if turn.turn_type == 3:
472
+                    turns_3[i+1+k] = turn.turn_type
473
+                    #print(i+1+k, turn.turn_type)
474
+                if turn.turn_type == 4:
475
+                    turns_4[i+1+k] = turn.turn_type
476
+                    #print(i+1+k, turn.turn_type)
477
+                if turn.turn_type == 5:
478
+                    turns_5[i+1+k] = turn.turn_type
479
+    return[turns_3, turns_4, turns_5]
480
+
481
+
482
+def print_turn_pattern(residues, res, turns):
483
+    i = residues.index(res)+1
484
+    if i in turns.keys() and not i-1 in turns.keys():
485
+        return(">")
486
+    elif i in turns.keys() and i-1 in turns.keys():
487
+        return(turns[i])
488
+    elif i not in turns.keys() and i-1 in turns.keys():
489
+        return("<")
490
+    else:
491
+        return(' ')
492
+    

+ 8 - 2
src/dssp.py View File

@@ -64,13 +64,19 @@ sheets = get_sheets(ladders)
64 64
 for i,res in enumerate(residues):
65 65
     #res.get_turns(residues, turns)
66 66
     #res.get_helix(residues)
67
-    kappa = res.get_bends(residues)
67
+    kappa = res.get_bends(residues)[0]
68
+    bend_symbol = res.get_bends(residues)[1]
68 69
     t_co = res.get_tco(residues)
69 70
     alpha = res.get_chirality(residues)[0]
71
+    chirality = res.get_chirality(residues)[1]
70 72
     phi = res.get_phi_psi(residues)[0]
71 73
     psi = res.get_phi_psi(residues)[1]
72 74
     x_ca = res.atoms["CA"].coord_x
73 75
     y_ca = res.atoms["CA"].coord_y
74 76
     z_ca = res.atoms["CA"].coord_z
75
-    print(i+1, res.resid, res.chain_id, res.res_letter, round(t_co, 3), round(kappa,1),
77
+    turns = build_turns_patterns(residues)
78
+    turn_3 = print_turn_pattern(residues, res, turns[0])
79
+    turn_4 = print_turn_pattern(residues, res, turns[1])
80
+    turn_5 = print_turn_pattern(residues, res, turns[2])
81
+    print(i+1, res.resid, res.chain_id, res.res_letter, turn_3, turn_4, turn_5, bend_symbol, chirality, round(t_co, 3), round(kappa,1),
76 82
           round(alpha, 1), round(phi, 1), round(psi,1), round(x_ca,1), round(y_ca,1), round(z_ca,1))