1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 """
26 Run a ProsaII job.
27
28 @attention: This class should be replaced by L{Prosa2003}. It will only stay
29 for a while unitl all transitions are made to the new version of Prosa.
30 """
31
32 import tempfile
33 import os
34 import Numeric as N
35
36 import tools as T
37 import Table
38
40
53
57
61
63 """
64 pair-interactions are calculated for residue pairs
65 whose sequence separation lies in 'window'.
66 window must be a tuple.
67 default values come from prosaII manual
68 """
69
70 self.pairWindowSize = tuple(window)
71
73
74 return self.pairWindowSize
75
77 """
78 surface energy for a residue pair is calculated only,
79 if their distance lies within the 'interval'. otherwise
80 energy is 0.
81 interval must be tuple.
82 default values come from prosaII manual
83 """
84
85 self.surfaceRange = tuple(interval)
86
88
89 return self.surfaceRange
90
92 """
93 E_total = factor * E_surface + E_pair
94 see manual for further recommendations
95 """
96
97 self.surface_factor = factor
98
100
101 return self.surface_factor
102
103 - def run(self, command):
104
105 script = self.script_name
106
107 f = open(script, 'w')
108 f.write(command)
109 f.close()
110
111 os.system('%s -d -f %s > /dev/null' % (self.executable, script))
112
113 if self.getCleanup():
114
115 try:
116 os.unlink(script)
117 except:
118 pass
119
121 """
122 supports user-expansion
123 """
124
125 if not os.path.exists(filename):
126 raise IOError, 'file %s does not exist. Check the ProsaII license' % filename
127
128 filename = os.path.expanduser(filename)
129 path, filename = os.path.split(filename)
130 name, ext = os.path.splitext(filename)
131
132 if path == '':
133 path = '.'
134
135 lower_k, upper_k = self.getPairWindowSize()
136 surface_lower, surface_upper = self.getSurfaceRange()
137
138 if object_name is None:
139 object_name = name
140
141 values = {'pdb_path': path,
142 'pdb_file': filename,
143 'obj_name': object_name,
144 'lower_k': lower_k,
145 'upper_k': upper_k,
146 'surface_lower': surface_lower,
147 'surface_upper': surface_upper,
148 'factor_surface': self.getSurfaceFactor()}
149
150 command = 'pdb_dir = %(pdb_path)s\n' + \
151 'read pdb %(pdb_file)s %(obj_name)s\n' + \
152 'lower_k = %(lower_k)d\n' + \
153 'upper_k = %(upper_k)d\n' + \
154 'pot_lb = %(surface_lower)f\n' + \
155 'pot_ub = %(surface_upper)f\n' + \
156 'analyse energy %(obj_name)s\n' + \
157 'print energy %(obj_name)s\n'
158
159
160
161 old_path = os.getcwd()
162 os.chdir(self.temp_dir)
163
164 self.run(command % values)
165
166
167
168 prosa_output = values['obj_name'] + '.ana'
169
170 result = parse_ANA_output(prosa_output)
171
172
173
174 if self.getCleanup():
175 os.unlink(prosa_output)
176
177
178
179 os.chdir(old_path)
180
181 return result[:,1:]
182
183
185
186 if not os.path.exists(prosa_output):
187 raise 'prosa output %s is missing.' % prosa_output
188
189 t = Table.fromFile(prosa_output)
190
191 return N.array(t[2:]).astype(N.Float)
192