소스 검색

Cleaning commented artefacts

Thomas Forest 5 년 전
부모
커밋
7f7d8aca98
2개의 변경된 파일12개의 추가작업 그리고 116개의 파일을 삭제
  1. 11 113
      src/chem.py
  2. 1 3
      src/pdb.py

+ 11 - 113
src/chem.py 파일 보기

@@ -1,5 +1,4 @@
1 1
 import math
2
-#from structure import *
3 2
 from geom import *
4 3
 
5 4
 class Atom:
@@ -107,7 +106,6 @@ class Residue:
107 106
                     if(self.h_bond(residues[i+j])<-0.5):
108 107
                         k = j
109 108
         if k != 0:    
110
-            #print(k,"TURN", residues[i].resid, residues[i+k].resid)
111 109
             return Turn(k,residues[i].resid)
112 110
 
113 111
         return False
@@ -115,78 +113,17 @@ class Residue:
115 113
     def get_bends(self, residues):
116 114
         i = residues.index(self)
117 115
         if i >=2 and i <len(residues)-2:
118
-            angle = math.degrees(vector_angles(vectors_substr(position_vector(residues[i].atoms["CA"].coords),
119
-                                                              position_vector(residues[i-2].atoms["CA"].coords)),
120
-                                               vectors_substr(position_vector(residues[i+2].atoms["CA"].coords),
121
-                                                              position_vector(residues[i].atoms["CA"].coords))))
116
+            angle = math.degrees(vector_angles(
117
+                vectors_substr(position_vector(residues[i].atoms["CA"].coords),
118
+                               position_vector(residues[i-2].atoms["CA"].coords)),
119
+                vectors_substr(position_vector(residues[i+2].atoms["CA"].coords),
120
+                               position_vector(residues[i].atoms["CA"].coords))))
122 121
             if(angle>70):
123 122
                 return [angle, 'S']
124 123
             return [angle, '']
125 124
         else:
126 125
             return [360.0, '']
127 126
 
128
-    def get_bridges(self, residues):
129
-        bridges = {}
130
-        bridge = {}
131
-        strongest_bridge = {}
132
-        i = residues.index(self)
133
-        if(i >= 1 and i < len(residues)-4):
134
-            E_min = 0
135
-            for j in range(i+2,len(residues)-1):
136
-                # select triplet with the minimal energy 
137
-
138
-                if(residues[i-1].h_bond(residues[j])<-0.5
139
-                   and residues[j].h_bond(residues[i+1])<-0.5):
140
-                    bridge = {'res1':residues[i-1].h_bond(residues[j]),
141
-                              'res2':residues[j].h_bond(residues[i+1]),
142
-                              'ipos':residues[i].resid,
143
-                              'jpos':residues[j].resid,
144
-                              'btype':"para"}
145
-
146
-                if(residues[j-1].h_bond(residues[i])<-0.5
147
-                   and residues[i].h_bond(residues[j+1])<-0.5):
148
-                    bridge = {'res1':residues[j-1].h_bond(residues[i]),
149
-                              'res2':residues[i].h_bond(residues[j+1]),
150
-                              'ipos':residues[i].resid,
151
-                              'jpos':residues[j].resid,
152
-                              'btype':"para"}
153
-
154
-                if(residues[i].h_bond(residues[j])<-0.5
155
-                   and residues[j].h_bond(residues[i])<-0.5):
156
-                    bridge = {'res1':residues[i].h_bond(residues[j]),
157
-                              'res2':residues[j].h_bond(residues[i]),
158
-                              'ipos':residues[i].resid,
159
-                              'jpos':residues[j].resid,
160
-                              'btype':"anti"}
161
-
162
-                if(residues[i-1].h_bond(residues[j+1])<-0.5
163
-                   and residues[j-1].h_bond(residues[i+1])<-0.5):
164
-                    bridge = {'res1':residues[i-1].h_bond(residues[j+1]),
165
-                              'res2':residues[j-1].h_bond(residues[i+1]),
166
-                              'ipos':residues[i].resid,
167
-                              'jpos':residues[j].resid,
168
-                              'btype':"anti"}
169
-
170
-                if(bridge):
171
-                    if(bridge['res1']+bridge['res2']<E_min):
172
-                        E_min = bridge['res1']+bridge['res2']
173
-                        strongest_bridge = bridge
174
-                        bridge = {}
175
-                        coord_bridge = [i,j]
176
-            # finally add the strongest bridge at i and j pos
177
-            if(strongest_bridge):
178
-                bridges[coord_bridge[0]] = (Bridge(strongest_bridge['btype'],
179
-                                                   strongest_bridge['ipos'],
180
-                                                   strongest_bridge['jpos']))
181
-                
182
-                bridges[coord_bridge[1]] = (Bridge(strongest_bridge['btype'],
183
-                                                   strongest_bridge['jpos'],
184
-                                                   strongest_bridge['ipos']))
185
-        if(len(bridges)>0):
186
-            return(bridges[coord_bridge[0]])
187
-        else:
188
-            return(False)
189
-
190 127
     def get_helix(self, residues):
191 128
         """
192 129
         Return if there is an helix at a given residue,
@@ -198,12 +135,10 @@ class Residue:
198 135
             return False
199 136
         
200 137
         if(self.get_turns(residues) and residues[i-1].get_turns(residues)):
201
-            #print(self.get_turns(residues).turn_type,"- HELIX at", residues[i].indice)
202 138
             return(self.get_turns(residues).turn_type, residues[i].indice)
203 139
         return(False)
204 140
 
205 141
     def get_ladder(self, residues):
206
-        #ladders = {}
207 142
         i = residues.index(self)
208 143
         if i != 0:
209 144
             if self.get_bridges(residues):
@@ -211,7 +146,6 @@ class Residue:
211 146
                     local_bridge = self.get_bridges(residues)
212 147
                     consec_bridge = residues[i-1].get_bridges(residues)
213 148
                     if local_bridge.bridge_type == consec_bridge.bridge_type:
214
-                        #print("ladder", consec_bridge.res_num, local_bridge.res_num)
215 149
                         ladder = {'start':consec_bridge.res_num,
216 150
                                   'end':local_bridge.res_num,
217 151
                                   'bridges':[consec_bridge, local_bridge]}
@@ -278,7 +212,6 @@ def get_bridges(residues):
278 212
         E_min = 0
279 213
         for j in range(i+2,len(residues)-1):
280 214
             # select triplet with the minimal energy 
281
-            
282 215
             if(residues[i-1].h_bond(residues[j])<-0.5
283 216
                and residues[j].h_bond(residues[i+1])<-0.5):
284 217
                 bridge = {'res1':residues[i-1].h_bond(residues[j]),
@@ -328,13 +261,11 @@ def get_bridges(residues):
328 261
 
329 262
         # finally add the strongest bridge at i and j pos
330 263
         if(strongest_bridge):
331
-
332 264
             bridges[strongest_bridge['i']] = (Bridge(strongest_bridge['btype'],
333 265
                                                      strongest_bridge['ipos'],
334 266
                                                      strongest_bridge['jpos'],
335 267
                                                      [strongest_bridge['i'],
336
-                                                      strongest_bridge['j']]))
337
-                                              
268
+                                                      strongest_bridge['j']]))                                        
338 269
             bridges[strongest_bridge['j']] = (Bridge(strongest_bridge['btype'],
339 270
                                                      strongest_bridge['ipos'],
340 271
                                                      strongest_bridge['jpos'],
@@ -357,7 +288,6 @@ def get_ladders(bridges, residues):
357 288
                 temp_bridges.append(bridges[i+k])
358 289
                 k+=1
359 290
         if k>1:
360
-            #print("ladder", bridges[i].res_num, bridges[i+k-1].res_num)
361 291
             ladders[i] = {'start':bridges[i].res_num,
362 292
                           'end':bridges[i+k-1].res_num,
363 293
                           'bridges':temp_bridges,
@@ -373,20 +303,8 @@ def connected_ladders(ladd_1, ladd_2):
373 303
     for bridge in ladd_1['bridges']:
374 304
         if bridge.res_partner in res_list(ladd_2):
375 305
             return ladd_2
376
-
377
-    return False
378
-
379
-def connected_ladders2(ladd_1, ladd_2):
380
-    links = []
381
-    for bridge in ladd_1['bridges']:
382
-        if bridge.res_partner in res_list(ladd_2):
383
-            return([ladd_1['i'], ladd_1['j'], bridge.i, bridge.j,
384
-                    ladd_2['i'], ladd_2['j']])
385
-            #return ladd_2
386
-
387 306
     return False
388 307
 
389
-
390 308
 def get_sheets(ladders):
391 309
     """
392 310
     Bridges between ladders.
@@ -396,7 +314,6 @@ def get_sheets(ladders):
396 314
     """
397 315
     ladds = [ elem for elem in ladders.values() ]
398 316
     sheets = {}
399
-
400 317
     corresp = {}
401 318
     for ladd1 in ladds:
402 319
         for ladd2 in ladds:
@@ -414,29 +331,10 @@ def get_sheets(ladders):
414 331
                     corresp[ladd2['i']] = corresp[ladd1['i']]
415 332
                 elif ladd1 not in corresp_list and ladd2 in corresp_list:
416 333
                     sheets[corresp[ladd2['i']]].append(ladd1)
417
-                    corresp[ladd1['i']] = corresp[ladd2['i']]
418
-                    
334
+                    corresp[ladd1['i']] = corresp[ladd2['i']]                   
419 335
     return sheets
420
-
421
-def get_sheets2(ladders):
422
-    """
423
-    Bridges between ladders.
424
-    Check if 1 bridge between one ladder and one or more other ladders.
425
-    Iterate over all residues of one ladder and check if bridge with other residues
426
-    of the other ladders.
427
-    """
428
-    sheets = {}    
429
-    for ladder in ladders:
430
-        for ladd2 in ladders:
431
-            if connected_ladders(ladders[ladder], ladders[ladd2]):
432
-                bridge_i = connected_ladders2(ladders[ladder], ladders[ladd2])[2]
433
-                bridge_j = connected_ladders2(ladders[ladder], ladders[ladd2])[3]
434
-                print("ladder",ladders[ladder]['i'], ladders[ladder]['j'],"bridge",bridge_i, bridge_j,
435
-                      "ladder 2",ladders[ladd2]['i'], ladders[ladd2]['j'])
436
-
437
-               
336
+   
438 337
 def res_list(ladder):
439
-    # TODO : method in ladder class
440 338
     l=[]
441 339
     for i in range(ladder['i'], ladder['j']):
442 340
         l.append(i)
@@ -467,7 +365,6 @@ def build_helix_patterns(residues):
467 365
         if(helix):
468 366
             helix_type = residues[i].get_helix(residues)[0]
469 367
             helix_pos = residues[i].get_helix(residues)[1]
470
-            #print("TYPE", helix_type)
471 368
             for k in range(helix_type):
472 369
                 if helix_type == 3:
473 370
                     helix_3[i+1+k] = "G"
@@ -475,7 +372,6 @@ def build_helix_patterns(residues):
475 372
                     helix_4[i+1+k] = "H"
476 373
                 if helix_type == 5:
477 374
                     helix_5[i+1+k] = "I"
478
-        #print(helix_3)
479 375
     return[helix_3, helix_4, helix_5]
480 376
 
481 377
 def print_helix_pattern(residues, res, helix):
@@ -503,5 +399,7 @@ def raw_ladders_print(ladders, ):
503 399
             ladd_2 = ladders[ladd2]
504 400
             for bridge in ladd_1['bridges']:
505 401
                 if bridge.j in res_list(ladd_2):  
506
-                    print("ladder", ladd_1['i'],"-",ladd_1['j'], "|", bridge.i, "...", bridge.j, "| ladder", ladd_2['i'], ladd_2['j'])
402
+                    print("ladder", ladd_1['i'],"-", ladd_1['j'], "|",
403
+                          bridge.i, "...", bridge.j, "| ladder",
404
+                          ladd_2['i'], ladd_2['j'])
507 405
 

+ 1 - 3
src/pdb.py 파일 보기

@@ -110,6 +110,4 @@ class PDBFile:
110 110
         self.rawLines = self.get_content(filename)
111 111
         self.metadata = self.get_header()
112 112
         self.get_atoms(filename)
113
-        # for elem in self.metadata : 
114
-        #     print(self.metadata[elem], end="")
115
-        
113
+