| Home | Trees | Indices | Help |
|
|---|
|
|
1 ##
2 ##
3 ## Biskit, a toolkit for the manipulation of macromolecular structures
4 ## Copyright (C) 2004-2005 Raik Gruenberg & Johan Leckner
5 ##
6 ## This program is free software; you can redistribute it and/or
7 ## modify it under the terms of the GNU General Public License as
8 ## published by the Free Software Foundation; either version 2 of the
9 ## License, or any later version.
10 ##
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ## General Public License for more details.
15 ##
16 ## You find a copy of the GNU General Public License in the file
17 ## license.txt along with this program; if not, write to the Free
18 ## Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 ##
20 ##
21 ## Author: Wolfgang Rieping
22 ## Created: 04/02/02
23 ## Last modified: 04/06/02
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
42
43 self.executable = executable
44 self.setCleanup()
45 self.temp_dir = temp_dir
46 self.script_name = tempfile.mktemp()
47
48 ## set default values
49
50 self.setPairWindowSize()
51 self.setSurfaceRange()
52 self.setSurfaceFactor()
53
54 - def setCleanup(self, value = 1):
55
56 self.cleanup = int(value)
57
58 - def getCleanup(self):
59
60 return self.cleanup
61
62 - def setPairWindowSize(self, window = (1, 600)):
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
72 - def getPairWindowSize(self):
73
74 return self.pairWindowSize
75
76 - def setSurfaceRange(self, interval = (0., 15.)):
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
87 - def getSurfaceRange(self):
88
89 return self.surfaceRange
90
91 - def setSurfaceFactor(self, factor = 5.):
92 """
93 E_total = factor * E_surface + E_pair
94 see manual for further recommendations
95 """
96
97 self.surface_factor = factor
98
99 - def getSurfaceFactor(self):
100
101 return self.surface_factor
102
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
120 - def analyseEnergy(self, filename, object_name = None):
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 ## save current path
160
161 old_path = os.getcwd()
162 os.chdir(self.temp_dir)
163
164 self.run(command % values)
165
166 ## output is in .ana-file
167
168 prosa_output = values['obj_name'] + '.ana'
169
170 result = parse_ANA_output(prosa_output)
171
172 ## if cleanup-flag is set, remove ana-files
173
174 if self.getCleanup():
175 os.unlink(prosa_output)
176
177 ## restore old path
178
179 os.chdir(old_path)
180
181 return result[:,1:]
182
183
184 -def parse_ANA_output(prosa_output):
192
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0alpha3 on Fri Dec 22 20:12:05 2006 | http://epydoc.sourceforge.net |