ソースを参照

Working phi_psi

Thomas Forest 5 年 前
コミット
8532e4ecd7
共有2 個のファイルを変更した48 個の追加18 個の削除を含む
  1. 11 9
      src/dssp.py
  2. 37 9
      src/structure.py

+ 11 - 9
src/dssp.py ファイルの表示

@@ -23,19 +23,17 @@ else:
23 23
 
24 24
     turns = get_turns(pdb_file.residues)
25 25
     get_helix(pdb_file.residues, turns)
26
-    # get_bends(pdb_file.residues)
26
+    get_bends(pdb_file.residues)
27 27
     # get_chirality(pdb_file.residues)
28
-    bridges = get_bridges(pdb_file.residues)
29
-    ladders = get_ladders(bridges, pdb_file.residues)
30
-    get_sheets(ladders)
28
+    # bridges = get_bridges(pdb_file.residues)
29
+    # ladders = get_ladders(bridges, pdb_file.residues)
30
+    # get_sheets(ladders)  
31 31
 
32 32
     # print("NBRIDGES",len(bridges))
33 33
 
34
-    bridges = get_bridges(pdb_file.residues)
34
+    # bridges = get_bridges(pdb_file.residues)
35 35
 
36
-    get_bonds(pdb_file.residues)
37
-
38
-    print(pdb_file.residues[1].h_bond(pdb_file.residues[2]))
36
+    # get_bonds(pdb_file.residues)
39 37
 
40 38
     residues = pdb_file.residues
41 39
     e_min = 0
@@ -44,4 +42,8 @@ else:
44 42
         if ene <= e_min:
45 43
             e_min = ene
46 44
             best_res = res
47
-    print(residues[1].resid, best_res.resid,e_min)
45
+    #print(residues[1].resid, best_res.resid,e_min)
46
+
47
+    #get_phi_psi(residues)
48
+    #print(residues[2].atoms, residues[0].resid, residues[1].resid)
49
+    print(get_TCO(residues[2],residues[3]))

+ 37 - 9
src/structure.py ファイルの表示

@@ -144,8 +144,10 @@ def get_helix(residues, turns):
144 144
             while(i+k in turns):
145 145
                 k+=1
146 146
                 temp_res.append(residues[i])
147
+                last_res_pos = residues[i].resid+k
147 148
             if(k>=1):
148
-                print(k,"- HELIX at", residues[i].resid)
149
+                helix_size=last_res_pos - residues[i].resid
150
+                print(turns[i].turn_type,"- HELIX at", residues[i].resid)
149 151
                 helix.append(Helix(temp_res,residues[i].resid))
150 152
             i = i+k
151 153
         else:
@@ -167,8 +169,8 @@ def get_ladders(bridges, residues):
167 169
             ladders[i] = k-1
168 170
             print("ladder", bridges[i].res_num, bridges[i+k-1].res_num)
169 171
             ladders[i] = {'start':bridges[i].res_num,
170
-                                           'end':bridges[i+k-1].res_num,
171
-                                           'bridges':temp_bridges}
172
+                          'end':bridges[i+k-1].res_num,
173
+                          'bridges':temp_bridges}
172 174
             i+=k-1
173 175
         else:
174 176
             i+=1
@@ -201,10 +203,10 @@ def res_list(ladder):
201 203
 def get_bends(residues):
202 204
     bends = {}
203 205
     for i in range(2,len(residues)-2):
204
-        angle = vector_angles(vectors_substr(position_vector(residues[i].atoms["CA"].coords),
205
-                                             position_vector(residues[i-2].atoms["CA"].coords)),
206
-                              vectors_substr(position_vector(residues[i+2].atoms["CA"].coords),
207
-                                             position_vector(residues[i].atoms["CA"].coords)))
206
+        angle = math.degrees(vector_angles(vectors_substr(position_vector(residues[i].atoms["CA"].coords),
207
+                                                          position_vector(residues[i-2].atoms["CA"].coords)),
208
+                                           vectors_substr(position_vector(residues[i+2].atoms["CA"].coords),
209
+                                                          position_vector(residues[i].atoms["CA"].coords))))
208 210
         if(angle>70):
209 211
             print("angle", residues[i].resid, angle)
210 212
             bends[residues[i].resid] = angle
@@ -240,8 +242,7 @@ def vector_angles(v1,v2):
240 242
     norm_v2 = vector_norm(v2)
241 243
     term = dot_prod/(abs(norm_v1)*abs(norm_v2))
242 244
     rad_angle = math.acos(term)
243
-    deg_angle = rad_angle*(180/math.pi)
244
-    return deg_angle
245
+    return rad_angle
245 246
 
246 247
 def calc_dihedral(u1, u2, u3, u4):
247 248
     """ Calculate dihedral angle method. From bioPython.PDB
@@ -299,3 +300,30 @@ def get_chirality(residues):
299 300
         
300 301
     return chirality
301 302
 
303
+
304
+def get_phi_psi(residues):
305
+    for i in range(len(residues)):
306
+        if(i==0):
307
+            phi = 360.0
308
+        else:
309
+            phi = calc_dihedral(residues[i-1].atoms["C"].coords,
310
+                                residues[i].atoms["N"].coords,
311
+                                residues[i].atoms["CA"].coords,
312
+                                residues[i].atoms["C"].coords)
313
+        if(i==len(residues)-1):
314
+            psi = 360.0
315
+        else:
316
+            psi = calc_dihedral(residues[i].atoms["N"].coords,
317
+                                residues[i].atoms["CA"].coords,
318
+                                residues[i].atoms["C"].coords,
319
+                                residues[i+1].atoms["N"].coords)
320
+
321
+        print("ANGLES", i, phi, psi)
322
+
323
+def get_TCO(res1, res2):
324
+    CO_res1 = vector_from_pos(res1.atoms["C"].coords,
325
+                              res1.atoms["O"].coords)
326
+    CO_res2 = vector_from_pos(res2.atoms["C"].coords,
327
+                              res2.atoms["O"].coords)
328
+    angle = vector_angles(CO_res1, CO_res2)
329
+    return(math.cos(angle))