Browse Source

attempt of NH-->O bonds discovery + correction of get_helix

Thomas Forest 5 years ago
parent
commit
583d7e33d8
2 changed files with 69 additions and 28 deletions
  1. 27 4
      src/dssp.py
  2. 42 24
      src/structure.py

+ 27 - 4
src/dssp.py View File

3
 import sys
3
 import sys
4
 from structure import *
4
 from structure import *
5
 
5
 
6
+def print_dssp():
7
+
8
+    empt_line=" " * 145
9
+
6
 if(len(sys.argv)<2):
10
 if(len(sys.argv)<2):
7
     print("Not enough arguments! Run with --help to learn more about proper"
11
     print("Not enough arguments! Run with --help to learn more about proper"
8
           "call structure and parameters.")
12
           "call structure and parameters.")
15
     #print(get_turns(pdb_file.residues))
19
     #print(get_turns(pdb_file.residues))
16
     #print(pdb_file.residues[27].h_bond(pdb_file.residues[28]))
20
     #print(pdb_file.residues[27].h_bond(pdb_file.residues[28]))
17
     #print(get_bridges(pdb_file.residues))
21
     #print(get_bridges(pdb_file.residues))
22
+
23
+
18
     turns = get_turns(pdb_file.residues)
24
     turns = get_turns(pdb_file.residues)
19
     get_helix(pdb_file.residues, turns)
25
     get_helix(pdb_file.residues, turns)
20
-    get_bends(pdb_file.residues)
21
-    get_chirality(pdb_file.residues)
26
+    # get_bends(pdb_file.residues)
27
+    # get_chirality(pdb_file.residues)
28
+    # bridges = get_bridges(pdb_file.residues)
29
+    # ladders = get_ladders(bridges)
30
+    # get_sheets(ladders)
31
+
32
+    # print("NBRIDGES",len(bridges))
33
+
22
     bridges = get_bridges(pdb_file.residues)
34
     bridges = get_bridges(pdb_file.residues)
23
-    ladders = get_ladders(bridges)
24
-    get_sheets(ladders)
35
+
36
+    get_bonds(pdb_file.residues)
37
+
38
+    print(pdb_file.residues[1].h_bond(pdb_file.residues[2]))
39
+
40
+    residues = pdb_file.residues
41
+    e_min = 0
42
+    for res in residues:
43
+        ene = residues[1].h_bond(res)
44
+        if ene <= e_min:
45
+            e_min = ene
46
+            best_res = res
47
+    print(residues[1].resid, best_res.resid,e_min)

+ 42 - 24
src/structure.py View File

34
             if(i+j<len(residues)):
34
             if(i+j<len(residues)):
35
                 if(res.h_bond(residues[i+j])<-0.5):
35
                 if(res.h_bond(residues[i+j])<-0.5):
36
                     print(j,"TURN", residues[i].resid, residues[i+j].resid)
36
                     print(j,"TURN", residues[i].resid, residues[i+j].resid)
37
-                    turns[residues[i].resid] = Turn(j,residues[i].resid)
37
+                    turns[i] = Turn(j,residues[i].resid)
38
     return(turns)
38
     return(turns)
39
 
39
 
40
 def get_bridges(residues):
40
 def get_bridges(residues):
53
                           'ipos':residues[i].resid,
53
                           'ipos':residues[i].resid,
54
                           'jpos':residues[j].resid,
54
                           'jpos':residues[j].resid,
55
                           'btype':"para"}
55
                           'btype':"para"}
56
-                # if(residues[i-1].h_bond(residues[j])+
57
-                #    residues[j].h_bond(residues[i+1]))<E_min:
58
-                #    E_min = residues[i-1].h_bond(residues[j])
59
-                #    +residues[j].h_bond(residues[i+1])
60
-                #    bridge_type = "para"
61
                    
56
                    
62
             if(residues[j-1].h_bond(residues[i])<-0.5
57
             if(residues[j-1].h_bond(residues[i])<-0.5
63
                and residues[i].h_bond(residues[j+1])<-0.5):
58
                and residues[i].h_bond(residues[j+1])<-0.5):
66
                           'ipos':residues[i].resid,
61
                           'ipos':residues[i].resid,
67
                           'jpos':residues[j].resid,
62
                           'jpos':residues[j].resid,
68
                           'btype':"para"}
63
                           'btype':"para"}
69
-                # if(residues[j-1].h_bond(residues[i])+
70
-                #    residues[i].h_bond(residues[j+1]))<E_min:
71
-                #    E_min = residues[j-1].h_bond(residues[i])
72
-                #    +residues[i].h_bond(residues[j+1])
73
-                #    bridge_type = "para"
74
 
64
 
75
             if(residues[i].h_bond(residues[j])<-0.5
65
             if(residues[i].h_bond(residues[j])<-0.5
76
                and residues[j].h_bond(residues[i])<-0.5):
66
                and residues[j].h_bond(residues[i])<-0.5):
79
                           'ipos':residues[i].resid,
69
                           'ipos':residues[i].resid,
80
                           'jpos':residues[j].resid,
70
                           'jpos':residues[j].resid,
81
                           'btype':"anti"}
71
                           'btype':"anti"}
82
-                # if(residues[i].h_bond(residues[j])+
83
-                #    residues[j].h_bond(residues[i]))<E_min:
84
-                #    E_min = residues[i].h_bond(residues[j])
85
-                #    +residues[j].h_bond(residues[i])
86
-                #    bridge_type = "anti"
87
                    
72
                    
88
             if(residues[i-1].h_bond(residues[j+1])<-0.5
73
             if(residues[i-1].h_bond(residues[j+1])<-0.5
89
                and residues[j-1].h_bond(residues[i+1])<-0.5):
74
                and residues[j-1].h_bond(residues[i+1])<-0.5):
92
                           'ipos':residues[i].resid,
77
                           'ipos':residues[i].resid,
93
                           'jpos':residues[j].resid,
78
                           'jpos':residues[j].resid,
94
                           'btype':"anti"}
79
                           'btype':"anti"}
95
-                 # if(residues[i-1].h_bond(residues[j+1])+
96
-                 #   residues[j-1].h_bond(residues[i+1]))<E_min:
97
-                 #   E_min = residues[i-1].h_bond(residues[j+1])
98
-                 #   +residues[j-1].h_bond(residues[i+1])
99
-                 #   bridge_type = "anti"
80
+
100
             if(bridge):
81
             if(bridge):
101
                 if(bridge['res1']+bridge['res2']<E_min):
82
                 if(bridge['res1']+bridge['res2']<E_min):
102
                     E_min = bridge['res1']+bridge['res2']
83
                     E_min = bridge['res1']+bridge['res2']
107
             bridges[strongest_bridge['ipos']] = (Bridge(strongest_bridge['btype'],
88
             bridges[strongest_bridge['ipos']] = (Bridge(strongest_bridge['btype'],
108
                                                         strongest_bridge['ipos'],
89
                                                         strongest_bridge['ipos'],
109
                                                         strongest_bridge['jpos']))
90
                                                         strongest_bridge['jpos']))
110
-            bridges[strongest_bridge['jpos']] = (Bridge(strongest_bridge['btype'],
111
-                                                        strongest_bridge['jpos'],
112
-                                                        strongest_bridge['ipos']))
91
+            # bridges[strongest_bridge['jpos']] = (Bridge(strongest_bridge['btype'],
92
+            #                                             strongest_bridge['jpos'],
93
+            #                                             strongest_bridge['ipos']))
113
     if(len(bridges)>0):
94
     if(len(bridges)>0):
114
         return(bridges)
95
         return(bridges)
115
     else:
96
     else:
116
         return(False)
97
         return(False)
117
 
98
 
99
+# def get_bonds(residues):
100
+#     for i,res1 in enumerate(residues):
101
+#         E_min = 0
102
+#         strongest_bridge = []
103
+#         for j in range(-5,6):
104
+#             if(i+j < len(residues)):
105
+#                 res2 = residues[i+j]
106
+#                 if(res1.h_bond(res2)<-0.5) and (res1.h_bond(res2)<E_min):
107
+#                     E_min = res1.h_bond(res2)
108
+#                     strongest_bridge = [res1, res2]
109
+#         if(len(strongest_bridge)>0):
110
+#             diff = strongest_bridge[0].resid - strongest_bridge[1].resid
111
+#             if( abs (diff) > 1 and abs(diff)<=5):
112
+#                 print(diff)
113
+
114
+def get_bonds(residues):
115
+    bonds = {}
116
+    k = 0
117
+    for i,res in enumerate(residues):
118
+        E_min = 0
119
+        for j in range(-5,-2):
120
+            if(i+j<len(residues)):
121
+                if(residues[i+j].h_bond(res)<-0.5):
122
+                    k+=1
123
+                    #if(res.h_bond(residues[i+j])<E_min):
124
+                    E_min = res.h_bond(residues[i+j])
125
+                    res_a = res
126
+                    res_b = residues[i+j]
127
+                    if j not in bonds:
128
+                        bonds[j] = []
129
+                    bonds[j].append([res_a.resid, res_b.resid])
130
+                    #turns[residues[i].resid] = Turn(j,residues[i].resid)
131
+    for key in bonds.keys():
132
+        print(key, len(bonds[key]))
133
+
134
+    print("LH",k)
135
+    
118
 def get_helix(residues, turns):
136
 def get_helix(residues, turns):
119
     i = 1
137
     i = 1
120
     helix = []
138
     helix = []