1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import sys
24 from types import FunctionType
25
26 from doc_string import regexp_doc
27 import help
28 from generic_fns.diffusion_tensor import Diffusion_tensor
29 from specific_fns.model_free import Model_free
30
31
34
35 self.__relax_help__ = \
36 """Class for interfacing with OpenDX."""
37
38
39 self.__relax_help__ = self.__relax_help__ + "\n" + help.relax_class_help
40
41
42 self.__relax__ = relax
43
44
45 - def execute(self, file="map", dir="dx", dx_exe="dx", vp_exec=1):
46 """Function for running OpenDX.
47
48 Keyword Arguments
49 ~~~~~~~~~~~~~~~~~
50
51 file: The file name prefix. For example if file is set to 'temp', then the OpenDX program
52 temp.net will be loaded.
53
54 dir: The directory to change to for running OpenDX. If this is set to 'None', OpenDX will
55 be run in the current directory.
56
57 dx_exe: The OpenDX executable file.
58
59 vp_exec: A flag specifying whether to execute the visual program automatically at
60 start-up. The default is 1 which turns execution on. Setting the value to zero turns
61 execution off.
62 """
63
64
65 if self.__relax__.interpreter.intro:
66 text = sys.ps3 + "dx("
67 text = text + "file=" + `file`
68 text = text + ", dir=" + `dir`
69 text = text + ", dx_exe=" + `dx_exe`
70 text = text + ", vp_exec=" + `vp_exec` + ")"
71 print text
72
73
74 if type(file) != str:
75 raise RelaxStrError, ('file name', file)
76
77
78 if dir == None:
79 pass
80 elif type(dir) != str:
81 raise RelaxNoneStrError, ('file name', file)
82
83
84 if type(dx_exe) != str:
85 raise RelaxStrError, ('OpenDX executable file name', dx_exe)
86
87
88 if type(vp_exec) != int or (vp_exec != 0 and vp_exec != 1):
89 raise RelaxBinError, ('visual program execution flag', vp_exec)
90
91
92 self.__relax__.generic.opendx.run(file=file, dir=dir, dx_exe=dx_exe, vp_exec=vp_exec)
93
94
95 - def map(self, run=None, params=None, map_type="Iso3D", res_num=None, inc=20, lower=None, upper=None, axis_incs=10, file="map", dir="dx", point=None, point_file="point", remap=None):
96 """Function for creating a map of the given space in OpenDX format.
97
98 Keyword Arguments
99 ~~~~~~~~~~~~~~~~~
100
101 run: The name of the run.
102
103 params: The parameters to be mapped. This argument should be an array of strings, values
104 of which are described below.
105
106 map_type: The type of map to create. For example the default, a 3D isosurface, the type is
107 'Iso3D'. See below for more details.
108
109 res_num: The residue number.
110
111 inc: The number of increments to map in each dimension. This value controls the resolution
112 of the map.
113
114 lower: The lower bounds of the space. If you wish to change the lower bounds of the map
115 then supply an array of length equal to the number of parameters in the model. A lower
116 bound for each parameter must be supplied. If nothing is supplied then the defaults will
117 be used.
118
119 upper: The upper bounds of the space. If you wish to change the upper bounds of the map
120 then supply an array of length equal to the number of parameters in the model. A upper
121 bound for each parameter must be supplied. If nothing is supplied then the defaults will
122 be used.
123
124 axis_incs: The number of increments or ticks displaying parameter values along the axes of
125 the OpenDX plot.
126
127 file: The file name. All the output files are prefixed with this name. The main file
128 containing the data points will be called the value of 'file'. The OpenDX program will be
129 called 'file.net' and the OpenDX import file will be called 'file.general'.
130
131 dir: The directory to output files to. Set this to 'None' if you do not want the files to
132 be placed in subdirectory. If the directory does not exist, it will be created.
133
134 point: An array of parameter values where a point in the map, shown as a red sphere, will
135 be placed. The length must be equal to the number of parameters.
136
137 point_file: The name of that the point output files will be prefixed with.
138
139 remap: A user supplied remapping function. This function will receive the parameter array
140 and must return an array of equal length.
141
142
143 Map type
144 ~~~~~~~~
145
146 The map type can be changed by supplying the 'map_type' keyword argument. Here is a list of
147 currently supported map types:
148 _____________________________________________________________________________
149 | | |
150 | Surface type | Pattern |
151 |___________________________________________|_______________________________|
152 | | |
153 | 3D isosurface | '^[Ii]so3[Dd]' |
154 |___________________________________________|_______________________________|
155
156 Pattern syntax is simply regular expression syntax where square brackets '[]' means any
157 character within the brackets, '^' means the start of the string, etc.
158
159
160 Examples
161 ~~~~~~~~
162
163 The following commands will generate a map of the extended model-free space defined as run
164 'm5' which consists of the parameters {S2, S2f, ts}. Files will be output into the
165 directory 'dx' and will be prefixed by 'map'. The residue, in this case, is number 6.
166
167 relax> dx.map('m5', ['S2', 'S2f', 'ts'], 6)
168 relax> dx.map('m5', ['S2', 'S2f', 'ts'], 6, 20, 'map', 'dx')
169 relax> dx.map('m5', ['S2', 'S2f', 'ts'], res_num=6, file='map', dir='dx')
170 relax> dx.map(run='m5', params=['S2', 'S2f', 'ts'], res_num=6, inc=20, file='map', dir='dx')
171 relax> dx.map(run='m5', params=['S2', 'S2f', 'ts'], res_num=6, type='Iso3D', inc=20,
172 swap=[0, 1, 2], file='map', dir='dx')
173
174
175 To map the model-free space 'm4' defined by the parameters {S2, te, Rex}, name the results
176 'test', and not place the files in a subdirectory, use the following commands (assuming
177 residue 2).
178
179 relax> dx.map('m4', ['S2', 'te', 'Rex'], res_num=2, file='test', dir=None)
180 relax> dx.map(run='m4', params=['S2', 'te', 'Rex'], res_num=2, inc=100, file='test',
181 dir=None)
182 """
183
184
185 if self.__relax__.interpreter.intro:
186 text = sys.ps3 + "map("
187 text = text + "run=" + `run`
188 text = text + ", params=" + `params`
189 text = text + ", map_type=" + `map_type`
190 text = text + ", res_num=" + `res_num`
191 text = text + ", inc=" + `inc`
192 text = text + ", lower=" + `lower`
193 text = text + ", upper=" + `upper`
194 text = text + ", axis_incs=" + `axis_incs`
195 text = text + ", file=" + `file`
196 text = text + ", dir=" + `dir`
197 text = text + ", point=" + `point`
198 text = text + ", point_file=" + `point_file`
199 text = text + ", remap=" + `remap` + ")"
200 print text
201
202
203 if type(run) != str:
204 raise RelaxStrError, ('run', run)
205
206
207 if type(params) != list:
208 raise RelaxListError, ('parameters', params)
209 num_params = len(params)
210 for i in xrange(num_params):
211 if type(params[i]) != str:
212 raise RelaxListStrError, ('parameters', params)
213
214
215 if type(map_type) != str:
216 raise RelaxStrError, ('map type', map_type)
217
218
219 if type(res_num) != int and res_num != None:
220 raise RelaxNoneIntError, ('residue number', res_num)
221
222
223 if type(inc) != int:
224 raise RelaxIntError, ('increment', inc)
225 elif inc <= 1:
226 raise RelaxError, "The increment value needs to be greater than 1."
227
228
229 if lower != None:
230 if type(lower) != list:
231 raise RelaxListError, ('lower bounds', lower)
232 if len(lower) != num_params:
233 raise RelaxLenError, ('lower bounds', num_params)
234 for i in xrange(len(lower)):
235 if type(lower[i]) != int and type(lower[i]) != float:
236 raise RelaxListNumError, ('lower bounds', lower)
237
238
239 if upper != None:
240 if type(upper) != list:
241 raise RelaxListError, ('upper bounds', upper)
242 if len(upper) != num_params:
243 raise RelaxLenError, ('upper bounds', num_params)
244 for i in xrange(len(upper)):
245 if type(upper[i]) != int and type(upper[i]) != float:
246 raise RelaxListNumError, ('upper bounds', upper)
247
248
249 if type(axis_incs) != int:
250 raise RelaxIntError, ('axis increments', axis_incs)
251 elif axis_incs <= 1:
252 raise RelaxError, "The axis increment value needs to be greater than 1."
253
254
255 if type(file) != str:
256 raise RelaxStrError, ('file name', file)
257
258
259 if dir != None and type(dir) != str:
260 raise RelaxNoneStrError, ('directory name', dir)
261
262
263 if point != None:
264 if type(point) != list:
265 raise RelaxListError, ('point', point)
266 if len(point) != num_params:
267 raise RelaxLenError, ('point', point)
268 if type(point_file) != str:
269 raise RelaxStrError, ('point file name', point_file)
270 for i in xrange(len(point)):
271 if type(point[i]) != int and type(point[i]) != float:
272 raise RelaxListNumError, ('point', point)
273
274
275 if remap != None and type(remap) is not FunctionType:
276 raise RelaxFunctionError, ('remap function', remap)
277
278
279 self.__relax__.generic.opendx.map(run=run, params=params, map_type=map_type, res_num=res_num, inc=inc, lower=lower, upper=upper, axis_incs=axis_incs, file=file, dir=dir, point=point, point_file=point_file, remap=remap)
280
281
282
283
284
285
286 map.__doc__ = map.__doc__ + "\n\n" + regexp_doc() + "\n"
287 map.__doc__ = map.__doc__ + Diffusion_tensor.return_data_name.__doc__ + "\n\n"
288 map.__doc__ = map.__doc__ + Model_free.return_data_name.__doc__ + "\n\n"
289