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,6 +3,10 @@ import atom
3 3
 import sys
4 4
 from structure import *
5 5
 
6
+def print_dssp():
7
+
8
+    empt_line=" " * 145
9
+
6 10
 if(len(sys.argv)<2):
7 11
     print("Not enough arguments! Run with --help to learn more about proper"
8 12
           "call structure and parameters.")
@@ -15,10 +19,29 @@ else:
15 19
     #print(get_turns(pdb_file.residues))
16 20
     #print(pdb_file.residues[27].h_bond(pdb_file.residues[28]))
17 21
     #print(get_bridges(pdb_file.residues))
22
+
23
+
18 24
     turns = get_turns(pdb_file.residues)
19 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 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,7 +34,7 @@ def get_turns(residues):
34 34
             if(i+j<len(residues)):
35 35
                 if(res.h_bond(residues[i+j])<-0.5):
36 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 38
     return(turns)
39 39
 
40 40
 def get_bridges(residues):
@@ -53,11 +53,6 @@ def get_bridges(residues):
53 53
                           'ipos':residues[i].resid,
54 54
                           'jpos':residues[j].resid,
55 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 57
             if(residues[j-1].h_bond(residues[i])<-0.5
63 58
                and residues[i].h_bond(residues[j+1])<-0.5):
@@ -66,11 +61,6 @@ def get_bridges(residues):
66 61
                           'ipos':residues[i].resid,
67 62
                           'jpos':residues[j].resid,
68 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 65
             if(residues[i].h_bond(residues[j])<-0.5
76 66
                and residues[j].h_bond(residues[i])<-0.5):
@@ -79,11 +69,6 @@ def get_bridges(residues):
79 69
                           'ipos':residues[i].resid,
80 70
                           'jpos':residues[j].resid,
81 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 73
             if(residues[i-1].h_bond(residues[j+1])<-0.5
89 74
                and residues[j-1].h_bond(residues[i+1])<-0.5):
@@ -92,11 +77,7 @@ def get_bridges(residues):
92 77
                           'ipos':residues[i].resid,
93 78
                           'jpos':residues[j].resid,
94 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 81
             if(bridge):
101 82
                 if(bridge['res1']+bridge['res2']<E_min):
102 83
                     E_min = bridge['res1']+bridge['res2']
@@ -107,14 +88,51 @@ def get_bridges(residues):
107 88
             bridges[strongest_bridge['ipos']] = (Bridge(strongest_bridge['btype'],
108 89
                                                         strongest_bridge['ipos'],
109 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 94
     if(len(bridges)>0):
114 95
         return(bridges)
115 96
     else:
116 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 136
 def get_helix(residues, turns):
119 137
     i = 1
120 138
     helix = []