Browse Source

add get_ladders() function

Thomas Forest 5 years ago
parent
commit
1621940855
2 changed files with 21 additions and 8 deletions
  1. 2 0
      src/dssp.py
  2. 19 8
      src/structure.py

+ 2 - 0
src/dssp.py View File

19
     get_helix(pdb_file.residues, turns)
19
     get_helix(pdb_file.residues, turns)
20
     get_bends(pdb_file.residues)
20
     get_bends(pdb_file.residues)
21
     get_chirality(pdb_file.residues)
21
     get_chirality(pdb_file.residues)
22
+    bridges = get_bridges(pdb_file.residues)
23
+    get_ladders(bridges)

+ 19 - 8
src/structure.py View File

36
     return(turns)
36
     return(turns)
37
 
37
 
38
 def get_bridges(residues):
38
 def get_bridges(residues):
39
-    bridges = []
39
+    bridges = {}
40
     bridge = {}
40
     bridge = {}
41
     strongest_bridge = {}
41
     strongest_bridge = {}
42
     for i in range(1,len(residues)-4):
42
     for i in range(1,len(residues)-4):
102
                     bridge = {}
102
                     bridge = {}
103
         # finally add the strongest bridge at i and j pos
103
         # finally add the strongest bridge at i and j pos
104
         if(strongest_bridge):
104
         if(strongest_bridge):
105
-            bridges.append(Bridge(strongest_bridge['btype'],
105
+            bridges[strongest_bridge['ipos']] = (Bridge(strongest_bridge['btype'],
106
                                   strongest_bridge['ipos']))
106
                                   strongest_bridge['ipos']))
107
-            bridges.append(Bridge(strongest_bridge['btype'],
107
+            bridges[strongest_bridge['jpos']] = (Bridge(strongest_bridge['btype'],
108
                                   strongest_bridge['jpos']))
108
                                   strongest_bridge['jpos']))
109
     if(len(bridges)>0):
109
     if(len(bridges)>0):
110
         return(bridges)
110
         return(bridges)
129
             i+=1
129
             i+=1
130
     return(helix)
130
     return(helix)
131
 
131
 
132
-def get_ladder(bridges):
132
+def get_ladders(bridges):
133
     ladders = {}
133
     ladders = {}
134
-    for i in range(len(bridges)):
134
+    i = 1
135
+    while i < len(bridges):
135
         k = 1
136
         k = 1
136
-        while bridges[i] == bridges[i+k]:
137
+        while (((i in bridges.keys()) and (i+k in bridges.keys())) and
138
+        (bridges[i].bridge_type == bridges[i+k].bridge_type)):
137
             k+=1
139
             k+=1
138
         if k>1:
140
         if k>1:
139
             ladders[bridges[i].res_num] = k-1
141
             ladders[bridges[i].res_num] = k-1
142
+            print("ladder", bridges[i].res_num, bridges[i+k-1].res_num)
143
+            ladders[bridges[i].res_num] = {'start':bridges[i].res_num,
144
+                                           'end':bridges[i+k-1].res_num}
145
+            i+=k-1
146
+        else:
147
+            i+=1
148
+     return ladders
149
+ 
140
 
150
 
151
+                
141
 def get_bends(residues):
152
 def get_bends(residues):
142
     bends = {}
153
     bends = {}
143
     for i in range(2,len(residues)-2):
154
     for i in range(2,len(residues)-2):
229
         
240
         
230
         if(angle>0 and angle<=180):
241
         if(angle>0 and angle<=180):
231
             sign="+"
242
             sign="+"
232
-            print("angle", residues[i].resid, "+", angle)
243
+            print("chirality", residues[i].resid, "+", angle)
233
             
244
             
234
         if(angle<=0 and angle > -180):
245
         if(angle<=0 and angle > -180):
235
             sign="-"
246
             sign="-"
236
-            print("angle", residues[i].resid, "-", angle)
247
+            print("chirality", residues[i].resid, "-", angle)
237
             
248
             
238
         chirality[residues[i].resid] = sign
249
         chirality[residues[i].resid] = sign
239
         
250