Explorar el Código

add get_ladders() function

Thomas Forest hace 5 años
padre
commit
1621940855
Se han modificado 2 ficheros con 21 adiciones y 8 borrados
  1. 2 0
      src/dssp.py
  2. 19 8
      src/structure.py

+ 2 - 0
src/dssp.py Ver fichero

@@ -19,3 +19,5 @@ else:
19 19
     get_helix(pdb_file.residues, turns)
20 20
     get_bends(pdb_file.residues)
21 21
     get_chirality(pdb_file.residues)
22
+    bridges = get_bridges(pdb_file.residues)
23
+    get_ladders(bridges)

+ 19 - 8
src/structure.py Ver fichero

@@ -36,7 +36,7 @@ def get_turns(residues):
36 36
     return(turns)
37 37
 
38 38
 def get_bridges(residues):
39
-    bridges = []
39
+    bridges = {}
40 40
     bridge = {}
41 41
     strongest_bridge = {}
42 42
     for i in range(1,len(residues)-4):
@@ -102,9 +102,9 @@ def get_bridges(residues):
102 102
                     bridge = {}
103 103
         # finally add the strongest bridge at i and j pos
104 104
         if(strongest_bridge):
105
-            bridges.append(Bridge(strongest_bridge['btype'],
105
+            bridges[strongest_bridge['ipos']] = (Bridge(strongest_bridge['btype'],
106 106
                                   strongest_bridge['ipos']))
107
-            bridges.append(Bridge(strongest_bridge['btype'],
107
+            bridges[strongest_bridge['jpos']] = (Bridge(strongest_bridge['btype'],
108 108
                                   strongest_bridge['jpos']))
109 109
     if(len(bridges)>0):
110 110
         return(bridges)
@@ -129,15 +129,26 @@ def get_helix(residues, turns):
129 129
             i+=1
130 130
     return(helix)
131 131
 
132
-def get_ladder(bridges):
132
+def get_ladders(bridges):
133 133
     ladders = {}
134
-    for i in range(len(bridges)):
134
+    i = 1
135
+    while i < len(bridges):
135 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 139
             k+=1
138 140
         if k>1:
139 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 152
 def get_bends(residues):
142 153
     bends = {}
143 154
     for i in range(2,len(residues)-2):
@@ -229,11 +240,11 @@ def get_chirality(residues):
229 240
         
230 241
         if(angle>0 and angle<=180):
231 242
             sign="+"
232
-            print("angle", residues[i].resid, "+", angle)
243
+            print("chirality", residues[i].resid, "+", angle)
233 244
             
234 245
         if(angle<=0 and angle > -180):
235 246
             sign="-"
236
-            print("angle", residues[i].resid, "-", angle)
247
+            print("chirality", residues[i].resid, "-", angle)
237 248
             
238 249
         chirality[residues[i].resid] = sign
239 250