Browse Source

display helix

Thomas Forest 5 years ago
parent
commit
d58e01d3f2
3 changed files with 38 additions and 10 deletions
  1. 28 4
      src/atom.py
  2. 8 4
      src/dssp.py
  3. 2 2
      src/structure.py

+ 28 - 4
src/atom.py View File

167
             return False
167
             return False
168
         
168
         
169
         if(self.get_turns(residues) and residues[i-1].get_turns(residues)):
169
         if(self.get_turns(residues) and residues[i-1].get_turns(residues)):
170
-            print(self.get_turns(residues).turn_type,"- HELIX at", residues[i].resid)
171
-            return(self.get_turns(residues).turn_type, residues[i].resid)
170
+            #print(self.get_turns(residues).turn_type,"- HELIX at", residues[i].indice)
171
+            return(self.get_turns(residues).turn_type, residues[i].indice)
172
         return(False)
172
         return(False)
173
 
173
 
174
     def get_ladder(self, residues):
174
     def get_ladder(self, residues):
470
             for k in range(turn.turn_type):
470
             for k in range(turn.turn_type):
471
                 if turn.turn_type == 3:
471
                 if turn.turn_type == 3:
472
                     turns_3[i+1+k] = turn.turn_type
472
                     turns_3[i+1+k] = turn.turn_type
473
-                    #print(i+1+k, turn.turn_type)
474
                 if turn.turn_type == 4:
473
                 if turn.turn_type == 4:
475
                     turns_4[i+1+k] = turn.turn_type
474
                     turns_4[i+1+k] = turn.turn_type
476
-                    #print(i+1+k, turn.turn_type)
477
                 if turn.turn_type == 5:
475
                 if turn.turn_type == 5:
478
                     turns_5[i+1+k] = turn.turn_type
476
                     turns_5[i+1+k] = turn.turn_type
479
     return[turns_3, turns_4, turns_5]
477
     return[turns_3, turns_4, turns_5]
480
 
478
 
479
+def build_helix_patterns(residues):
480
+    helix_3 = {}
481
+    helix_4 = {}
482
+    helix_5 = {}
483
+    for i,res in enumerate(residues):
484
+        helix = residues[i].get_helix(residues)
485
+        if(helix):
486
+            helix_type = residues[i].get_helix(residues)[0]
487
+            helix_pos = residues[i].get_helix(residues)[1]
488
+            #print("TYPE", helix_type)
489
+            for k in range(helix_type):
490
+                if helix_type == 3:
491
+                    helix_3[i+1+k] = "G"
492
+                if helix_type == 4:
493
+                    helix_4[i+1+k] = "H"
494
+                if helix_type == 5:
495
+                    helix_5[i+1+k] = "I"
496
+        #print(helix_3)
497
+    return[helix_3, helix_4, helix_5]
498
+
499
+def print_helix_pattern(residues, res, helix):
500
+    i = residues.index(res)+1
501
+    if i in helix.keys():
502
+        return (helix[i])
503
+    else:
504
+        return(' ')
481
 
505
 
482
 def print_turn_pattern(residues, res, turns):
506
 def print_turn_pattern(residues, res, turns):
483
     i = residues.index(res)+1
507
     i = residues.index(res)+1

+ 8 - 4
src/dssp.py View File

59
 bridges = get_bridges(residues)
59
 bridges = get_bridges(residues)
60
 ladders = get_ladders(bridges, residues)
60
 ladders = get_ladders(bridges, residues)
61
 sheets = get_sheets(ladders)  
61
 sheets = get_sheets(ladders)  
62
-
62
+helix = build_helix_patterns(residues)
63
 # iterating over residues
63
 # iterating over residues
64
 for i,res in enumerate(residues):
64
 for i,res in enumerate(residues):
65
     #res.get_turns(residues, turns)
65
     #res.get_turns(residues, turns)
66
-    #res.get_helix(residues)
67
     kappa = res.get_bends(residues)[0]
66
     kappa = res.get_bends(residues)[0]
68
     bend_symbol = res.get_bends(residues)[1]
67
     bend_symbol = res.get_bends(residues)[1]
69
     t_co = res.get_tco(residues)
68
     t_co = res.get_tco(residues)
78
     turn_3 = print_turn_pattern(residues, res, turns[0])
77
     turn_3 = print_turn_pattern(residues, res, turns[0])
79
     turn_4 = print_turn_pattern(residues, res, turns[1])
78
     turn_4 = print_turn_pattern(residues, res, turns[1])
80
     turn_5 = print_turn_pattern(residues, res, turns[2])
79
     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),
82
-          round(alpha, 1), round(phi, 1), round(psi,1), round(x_ca,1), round(y_ca,1), round(z_ca,1))
80
+
81
+    helix_3 = print_helix_pattern(residues, res, helix[0])
82
+    helix_4 = print_helix_pattern(residues, res, helix[1])
83
+    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
+           round(alpha, 1), round(phi, 1), round(psi,1), round(x_ca,1), round(y_ca,1), round(z_ca,1))

+ 2 - 2
src/structure.py View File

24
 
24
 
25
 class Helix(Structure):
25
 class Helix(Structure):
26
 
26
 
27
-    def __init__(self, residues, res_num):
27
+    def __init__(self, residues, res_num, helix_type):
28
         self.residues = residues
28
         self.residues = residues
29
         self.res_num = res_num
29
         self.res_num = res_num
30
         Structure.res = res_num
30
         Structure.res = res_num
31
- 
31
+        self.helix_type = helix_type