소스 검색

Add bends discovery from position vectors

Thomas Forest 5 년 전
부모
커밋
45f0eb8c93
3개의 변경된 파일109개의 추가작업 그리고 14개의 파일을 삭제
  1. 2 1
      src/atom.py
  2. 4 2
      src/dssp.py
  3. 103 11
      src/structure.py

+ 2 - 1
src/atom.py 파일 보기

@@ -16,7 +16,8 @@ class Atom:
16 16
         self.res_seq_nb = res_seq_nb
17 17
         self.coord_x = coordinates[0]
18 18
         self.coord_y = coordinates[1]
19
-        self.coord_z = coordinates[2]             
19
+        self.coord_z = coordinates[2]
20
+        self.coords = coordinates
20 21
 
21 22
 class Residue:
22 23
     def __init__(self, atoms_list):

+ 4 - 2
src/dssp.py 파일 보기

@@ -14,5 +14,7 @@ else:
14 14
     #print(pdb_file.residues[2].h_bond(pdb_file.residues[40]))
15 15
     #print(get_turns(pdb_file.residues))
16 16
     #print(pdb_file.residues[27].h_bond(pdb_file.residues[28]))
17
-    print(get_bridges(pdb_file.residues))
18
-
17
+    #print(get_bridges(pdb_file.residues))
18
+    turns = get_turns(pdb_file.residues)
19
+    get_helix(pdb_file.residues, turns)
20
+    get_bends(pdb_file.residues)

+ 103 - 11
src/structure.py 파일 보기

@@ -1,27 +1,37 @@
1
+import math
1 2
 
2
-class Turn:
3
+class Structure:
4
+    def __init__(self, res):
5
+        self.res = res
3 6
 
4
-    def __init__(self, turn_type, res_num):
7
+class Turn(Structure):
8
+
9
+    def __init__(self, turn_type, res):
5 10
         self.turn_type = turn_type
11
+        Structure.res = res
6 12
                         
7
-class Bridge:
13
+class Bridge(Structure):
8 14
 
9 15
     def __init__(self, bridge_type, res_num):
10 16
         self.bridge_type = bridge_type
11 17
         self.res_num = res_num
18
+        Structure.res = res_num
12 19
 
13
-class Helix:
20
+class Helix(Structure):
14 21
 
15
-    def __init__(self, residues):
22
+    def __init__(self, residues, res_num):
16 23
         self.residues = residues
24
+        self.res_num = res_num
25
+        Structure.res = res_num
17 26
         
18 27
 def get_turns(residues):
19
-    turns = []
28
+    turns = {}
20 29
     for i,res in enumerate(residues):
21 30
         for j in range(3,6):
22 31
             if(i+j<len(residues)):
23
-                if(res.h_bond(residues[i+j]<-0.5)):
24
-                    turns.append(Turn(j,i))
32
+                if(res.h_bond(residues[i+j])<-0.5):
33
+                    print("TURN", i+1, i+j+1)
34
+                    turns[i] = Turn(j,i)
25 35
     return(turns)
26 36
 
27 37
 def get_bridges(residues):
@@ -101,6 +111,88 @@ def get_bridges(residues):
101 111
         return(False)
102 112
 
103 113
 def get_helix(residues, turns):
104
-    for i in range(residues):
105
-        for j in range(i+1,i+5):
106
-            if
114
+    i = 1
115
+    helix = []
116
+    while i <= len(residues):
117
+        if(i in turns.keys() and i-1 in turns.keys()):
118
+            k = 0
119
+            temp_res = []
120
+            while(i+k in turns):
121
+                k+=1
122
+                temp_res.append(residues[i])
123
+            if(k>2):
124
+                print(k,"- HELIX at", i)
125
+                helix.append(Helix(temp_res,i))
126
+            i = i+k
127
+        else:
128
+            i+=1
129
+    return(helix)
130
+
131
+def get_bends(residues):
132
+    bends = {}
133
+    for i in range(2,len(residues)-2):
134
+        # print("angle",i,calculer_angles(residues[i-2].atoms["CA"].coords,
135
+        #                                 residues[i].atoms["CA"].coords,
136
+        #                                 residues[i+2].atoms["CA"].coords))
137
+        
138
+        angle = vector_angles(vectors_substr(position_vector(residues[i].atoms["CA"].coords),
139
+                                             position_vector(residues[i-2].atoms["CA"].coords)),
140
+                              vectors_substr(position_vector(residues[i+2].atoms["CA"].coords),
141
+                                             position_vector(residues[i].atoms["CA"].coords)))
142
+        if(angle>70):
143
+            print("angle", i+1, angle)
144
+    return(bends)
145
+
146
+def vecteur_deux_points (a, b):
147
+    xAB = b[0]-a[0]
148
+    yAB = b[1]-a[1]
149
+    zAB = b[2]-a[2]
150
+    coord_AB = [xAB,yAB,zAB]
151
+    return coord_AB
152
+
153
+def produit_scalaire (a, b, c):
154
+    coord_BA = vecteur_deux_points(b, a)
155
+    coord_BC = vecteur_deux_points(b, c)
156
+    dot_product = coord_BA[0]*coord_BC[0] + coord_BA[1]*coord_BC[1] + coord_BA[2]*coord_BC[2]
157
+    return dot_product
158
+
159
+
160
+def norme_vecteur (a,b):
161
+    vecteur = vecteur_deux_points(a,b)
162
+    norme = math.sqrt(vecteur[0]**2 + vecteur[1]**2 + vecteur[2]**2)
163
+    return norme
164
+
165
+def vector_norm(v):
166
+    norm = math.sqrt(v[0]**2 + v[1]**2 + v[2]**2)
167
+    return norm
168
+
169
+def dot_product(v1,v2):
170
+    dot_product = v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]
171
+    return(dot_product)
172
+
173
+def position_vector(c):
174
+    vector = vecteur_deux_points([0,0,0],c)
175
+    return vector
176
+
177
+def vectors_substr(v1, v2):
178
+    return ([v2[0]-v1[0],
179
+             v2[1]-v1[1],
180
+             v2[2]-v1[2]])
181
+
182
+def vector_angles(v1,v2):
183
+    dot_prod = dot_product(v1,v2)
184
+    norm_v1 = vector_norm(v1)
185
+    norm_v2 = vector_norm(v2)
186
+    term = dot_prod/(abs(norm_v1)*abs(norm_v2))
187
+    rad_angle = math.acos(term)
188
+    deg_angle = rad_angle*(180/math.pi)
189
+    return deg_angle
190
+
191
+def calculer_angles (a,b,c):
192
+    dot_product_ABC = produit_scalaire(a,b,c)
193
+    norme_BA = norme_vecteur (b,a)
194
+    norme_BC = norme_vecteur (b,c)
195
+    terme = dot_product_ABC/(abs(norme_BA)*abs(norme_BC))
196
+    angle_radian = math.acos(terme)
197
+    angle_degre = angle_radian*(180/math.pi)
198
+    return angle_degre