ソースを参照

Corrected get_bridges func

Thomas Forest 5 年 前
コミット
4cd628fa50
共有1 個のファイルを変更した72 個の追加25 個の削除を含む
  1. 72 25
      src/structure.py

+ 72 - 25
src/structure.py ファイルの表示

@@ -1,13 +1,14 @@
1 1
 
2 2
 class Turn:
3 3
 
4
-    def __init__(self, turn_type):
4
+    def __init__(self, turn_type, res_num):
5 5
         self.turn_type = turn_type
6 6
                         
7 7
 class Bridge:
8 8
 
9
-    def __init__(self, bridge_type):
9
+    def __init__(self, bridge_type, res_num):
10 10
         self.bridge_type = bridge_type
11
+        self.res_num = res_num
11 12
 
12 13
 class Helix:
13 14
 
@@ -20,11 +21,13 @@ def get_turns(residues):
20 21
         for j in range(3,6):
21 22
             if(i+j<len(residues)):
22 23
                 if(res.h_bond(residues[i+j]<-0.5)):
23
-                    turns.append(Turn(j))
24
+                    turns.append(Turn(j,i))
24 25
     return(turns)
25 26
 
26 27
 def get_bridges(residues):
27 28
     bridges = []
29
+    bridge = {}
30
+    strongest_bridge = {}
28 31
     for i in range(1,len(residues)-4):
29 32
         E_min = 0
30 33
         for j in range(i+2,len(residues)-1):
@@ -32,28 +35,72 @@ def get_bridges(residues):
32 35
 
33 36
             if(residues[i-1].h_bond(residues[j])<-0.5
34 37
                and residues[j].h_bond(residues[i+1])<-0.5):
35
-                if(residues[i-1].h_bond(residues[j])+
36
-                   residues[j].h_bond(residues[i+1]))<E_min:
37
-                   E_min = residues[i-1].h_bond(residues[j])
38
-                   +residues[j].h_bond(residues[i+1])
38
+                bridge = {'res1':residues[i-1].h_bond(residues[j]),
39
+                          'res2':residues[j].h_bond(residues[i+1]),
40
+                          'ipos':i,
41
+                          'jpos':j,
42
+                          'btype':"para"}
43
+                # if(residues[i-1].h_bond(residues[j])+
44
+                #    residues[j].h_bond(residues[i+1]))<E_min:
45
+                #    E_min = residues[i-1].h_bond(residues[j])
46
+                #    +residues[j].h_bond(residues[i+1])
47
+                #    bridge_type = "para"
39 48
                    
40 49
             if(residues[j-1].h_bond(residues[i])<-0.5
41 50
                and residues[i].h_bond(residues[j+1])<-0.5):
42
-                if(residues[j-1].h_bond(residues[i])+
43
-                   residues[i].h_bond(residues[j+1]))<E_min:
44
-                   E_min = residues[j-1].h_bond(residues[i])
45
-                   +residues[i].h_bond(residues[j+1])
46
-                #bridges.append(Bridge("para"))
47
-                    
48
-                
49
-            if((residues[i].h_bond(residues[j])<-0.5
50
-                and residues[j].h_bond(residues[i])<-0.5)
51
-               or(residues[i-1].h_bond(residues[j+1])<-0.5
52
-                  and residues[j-1].h_bond(residues[i+1])<-0.5)):
53
-
54
-                #bridges.append(Bridge("anti"))
55
-        #bridges.append(strongest_bridge)
56
-    return(bridges)
57
-
58
-def get_helix(turns):
59
-    pass
51
+                bridge = {'res1':residues[j-1].h_bond(residues[i]),
52
+                          'res2':residues[i].h_bond(residues[j+1]),
53
+                          'ipos':i,
54
+                          'jpos':j,
55
+                          'btype':"para"}
56
+                # if(residues[j-1].h_bond(residues[i])+
57
+                #    residues[i].h_bond(residues[j+1]))<E_min:
58
+                #    E_min = residues[j-1].h_bond(residues[i])
59
+                #    +residues[i].h_bond(residues[j+1])
60
+                #    bridge_type = "para"
61
+
62
+            if(residues[i].h_bond(residues[j])<-0.5
63
+               and residues[j].h_bond(residues[i])<-0.5):
64
+                bridge = {'res1':residues[i].h_bond(residues[j]),
65
+                          'res2':residues[j].h_bond(residues[i]),
66
+                          'ipos':i,
67
+                          'jpos':j,
68
+                          'btype':"anti"}
69
+                # if(residues[i].h_bond(residues[j])+
70
+                #    residues[j].h_bond(residues[i]))<E_min:
71
+                #    E_min = residues[i].h_bond(residues[j])
72
+                #    +residues[j].h_bond(residues[i])
73
+                #    bridge_type = "anti"
74
+                   
75
+            if(residues[i-1].h_bond(residues[j+1])<-0.5
76
+               and residues[j-1].h_bond(residues[i+1])<-0.5):
77
+                bridge = {'res1':residues[i-1].h_bond(residues[j+1]),
78
+                          'res2':residues[j-1].h_bond(residues[i+1]),
79
+                          'ipos':i,
80
+                          'jpos':j,
81
+                          'btype':"anti"}
82
+                 # if(residues[i-1].h_bond(residues[j+1])+
83
+                 #   residues[j-1].h_bond(residues[i+1]))<E_min:
84
+                 #   E_min = residues[i-1].h_bond(residues[j+1])
85
+                 #   +residues[j-1].h_bond(residues[i+1])
86
+                 #   bridge_type = "anti"
87
+            if(bridge):
88
+                if(bridge['res1']+bridge['res2']<E_min):
89
+                    E_min = bridge['res1']+bridge['res2']
90
+                    strongest_bridge = bridge
91
+                    bridge = {}
92
+        # finally add the strongest bridge at i and j pos
93
+        if(strongest_bridge):
94
+            bridges.append(Bridge(strongest_bridge['btype'],
95
+                                  strongest_bridge['ipos']))
96
+            bridges.append(Bridge(strongest_bridge['btype'],
97
+                                  strongest_bridge['jpos']))
98
+    if(len(bridges)>0):
99
+        return(bridges)
100
+    else:
101
+        return(False)
102
+
103
+def get_helix(residues, turns):
104
+    for i in range(residues):
105
+        for j in range(i+1,i+5):
106
+            if