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
25 from doc_string import regexp_doc
26 import help
27 from generic_fns.diffusion_tensor import Diffusion_tensor
28 from specific_fns.model_free import Model_free
29 from specific_fns.jw_mapping import Jw_mapping
30 from specific_fns.noe import Noe
31
32
35
36 self.__relax_help__ = \
37 """Class for setting data values."""
38
39
40 self.__relax_help__ = self.__relax_help__ + "\n" + help.relax_class_help
41
42
43 self.__relax__ = relax
44
45
46 - def copy(self, run1=None, run2=None, param=None):
47 """Function for copying residue specific data values from run1 to run2.
48
49 Keyword Arguments
50 ~~~~~~~~~~~~~~~~~
51
52 run1: The name of the run to copy from.
53
54 run2: The name of the run to copy to.
55
56 param: The parameter to copy.
57
58
59 Description
60 ~~~~~~~~~~~
61
62 Only one parameter may be selected, therefore the 'param' argument should be a string.
63
64 If this function is used to change values of previously minimised runs, then the
65 minimisation statistics (chi-squared value, iteration count, function count, gradient count,
66 and Hessian count) will be reset to None.
67
68
69 Examples
70 ~~~~~~~~
71
72 To copy the CSA values from the run 'm1' to 'm2', type:
73
74 relax> value.copy('m1', 'm2', 'CSA')
75 """
76
77
78 if self.__relax__.interpreter.intro:
79 text = sys.ps3 + "value.copy("
80 text = text + "run1=" + `run1`
81 text = text + ", run2=" + `run2`
82 text = text + ", param=" + `param` + ")"
83 print text
84
85
86 if type(run1) != str:
87 raise RelaxStrError, ('run1', run1)
88
89
90 if type(run2) != str:
91 raise RelaxStrError, ('run2', run2)
92
93
94 if type(param) != str:
95 raise RelaxStrError, ('parameter', param)
96
97
98 self.__relax__.generic.value.copy(run1=run1, run2=run2, param=param)
99
100
101 - def display(self, run=None, param=None):
102 """Function for displaying residue specific data values.
103
104 Keyword Arguments
105 ~~~~~~~~~~~~~~~~~
106
107 run: The name of the run.
108
109 param: The parameter to display.
110
111
112 Description
113 ~~~~~~~~~~~
114
115 Only one parameter may be selected, therefore the 'param' argument should be a string.
116
117
118 Examples
119 ~~~~~~~~
120
121 To show all CSA values for the run 'm1', type:
122
123 relax> value.display('m1', 'CSA')
124 """
125
126
127 if self.__relax__.interpreter.intro:
128 text = sys.ps3 + "value.display("
129 text = text + "run=" + `run`
130 text = text + ", param=" + `param` + ")"
131 print text
132
133
134 if type(run) != str:
135 raise RelaxStrError, ('run', run)
136
137
138 if type(param) != str:
139 raise RelaxStrError, ('parameter', param)
140
141
142 self.__relax__.generic.value.display(run=run, param=param)
143
144
145 - def read(self, run=None, param=None, scaling=1.0, file=None, num_col=0, name_col=1, data_col=2, error_col=3, sep=None):
146 """Function for reading residue specific data values from a file.
147
148 Keyword Arguments
149 ~~~~~~~~~~~~~~~~~
150
151 run: The name of the run.
152
153 param: The parameter.
154
155 scaling: The factor to scale parameters by.
156
157 file: The name of the file containing the relaxation data.
158
159 num_col: The residue number column (the default is 0, ie the first column).
160
161 name_col: The residue name column (the default is 1).
162
163 data_col: The relaxation data column (the default is 2).
164
165 error_col: The experimental error column (the default is 3).
166
167 sep: The column separator (the default is white space).
168
169
170 Description
171 ~~~~~~~~~~~
172
173 Only one parameter may be selected, therefore the 'param' argument should be a string. If
174 the file only contains values and no errors, set the error column argument to None.
175
176 If this function is used to change values of previously minimised runs, then the
177 minimisation statistics (chi-squared value, iteration count, function count, gradient count,
178 and Hessian count) will be reset to None.
179
180
181 Examples
182 ~~~~~~~~
183
184 To load CSA values for the run 'm1' from the file 'csa_values' in the directory 'data', type
185 any of the following:
186
187 relax> value.read('m1', 'CSA', 'data/csa_value')
188 relax> value.read('m1', 'CSA', 'data/csa_value', 0, 1, 2, 3, None, 1)
189 relax> value.read(run='m1', param='CSA', file='data/csa_value', num_col=0, name_col=1,
190 data_col=2, error_col=3, sep=None)
191 """
192
193
194 if self.__relax__.interpreter.intro:
195 text = sys.ps3 + "value.read("
196 text = text + "run=" + `run`
197 text = text + ", param=" + `param`
198 text = text + ", scaling=" + `scaling`
199 text = text + ", file=" + `file`
200 text = text + ", num_col=" + `num_col`
201 text = text + ", name_col=" + `name_col`
202 text = text + ", data_col=" + `data_col`
203 text = text + ", error_col=" + `error_col`
204 text = text + ", sep=" + `sep` + ")"
205 print text
206
207
208 if type(run) != str:
209 raise RelaxStrError, ('run', run)
210
211
212 if type(param) != str:
213 raise RelaxStrError, ('parameter', param)
214
215
216 if type(scaling) != float:
217 raise RelaxFloatError, ('scaling', scaling)
218
219
220 if type(file) != str:
221 raise RelaxStrError, ('file', file)
222
223
224 if type(num_col) != int:
225 raise RelaxIntError, ('residue number column', num_col)
226
227
228 if name_col != None and type(name_col) != int:
229 raise RelaxNoneIntError, ('residue name column', name_col)
230
231
232 if type(data_col) != int:
233 raise RelaxIntError, ('data column', data_col)
234
235
236 if error_col != None and type(error_col) != int:
237 raise RelaxNoneIntError, ('error column', error_col)
238
239
240 if sep != None and type(sep) != str:
241 raise RelaxNoneStrError, ('column separator', sep)
242
243
244 self.__relax__.generic.value.read(run=run, param=param, scaling=scaling, file=file, num_col=num_col, name_col=name_col, data_col=data_col, error_col=error_col, sep=sep)
245
246
247 - def set(self, run=None, value=None, param=None, res_num=None, res_name=None):
248 """Function for setting residue specific data values.
249
250 Keyword arguments
251 ~~~~~~~~~~~~~~~~~
252
253 run: The run to assign the values to.
254
255 value: The value(s).
256
257 param: The parameter(s).
258
259 res_num: The residue number.
260
261 res_name: The residue name.
262
263
264 Description
265 ~~~~~~~~~~~
266
267 If this function is used to change values of previously minimised runs, then the
268 minimisation statistics (chi-squared value, iteration count, function count, gradient count,
269 and Hessian count) will be reset to None.
270
271
272 The value argument can be None, a single value, or an array of values while the parameter
273 argument can be None, a string, or array of strings. The choice of which combination
274 determines the behaviour of this function. The following table describes what occurs in
275 each instance. The Value column refers to the 'value' argument while the Param column refers
276 to the 'param' argument. In these columns, 'None' corresponds to None, '1' corresponds
277 to either a single value or single string, and 'n' corresponds to either an array of values
278 or an array of strings.
279
280 ____________________________________________________________________________________________
281 | | | |
282 | Value | Param | Description |
283 |_______|_______|__________________________________________________________________________|
284 | | | |
285 | None | None | This case is used to set the model parameters prior to minimisation or |
286 | | | calculation. The model parameters are set to the default values. |
287 | | | |
288 | 1 | None | Invalid combination. |
289 | | | |
290 | n | None | This case is used to set the model parameters prior to minimisation or |
291 | | | calculation. The length of the value array must be equal to the number |
292 | | | of model parameters for an individual residue. The parameters will be |
293 | | | set to the corresponding number. |
294 | | | |
295 | None | 1 | The parameter matching the string will be set to the default value. |
296 | | | |
297 | 1 | 1 | The parameter matching the string will be set to the supplied number. |
298 | | | |
299 | n | 1 | Invalid combination. |
300 | | | |
301 | None | n | Each parameter matching the strings will be set to the default values. |
302 | | | |
303 | 1 | n | Each parameter matching the strings will be set to the supplied number. |
304 | | | |
305 | n | n | Each parameter matching the strings will be set to the corresponding |
306 | | | number. Both arrays must be of equal length. |
307 |_______|_______|__________________________________________________________________________|
308
309
310 Residue number and name argument
311 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
312
313 If the 'res_num' and 'res_name' arguments are left as the defaults of None, then the
314 function will be applied to all residues. Otherwise the residue number can be set to either
315 an integer for selecting a single residue or a python regular expression string for
316 selecting multiple residues. The residue name argument must be a string and can use regular
317 expression as well. If the data is global non-residue specific data, such as diffusion
318 tensor parameters, supplying the residue number and name will terminate the program with an
319 error.
320
321
322 Examples
323 ~~~~~~~~
324
325 To set the parameter values for the run 'test' to the default values, for all residues,
326 type:
327
328 relax> value.set('test')
329
330
331 To set the parameter values of residue 10, which is the model-free run 'm4' and has the
332 parameters {S2, te, Rex}, the following can be used. Rex term is the value for the first
333 given field strength.
334
335 relax> value.set('m4', [0.97, 2.048*1e-9, 0.149], res_num=10)
336 relax> value.set('m4', value=[0.97, 2.048*1e-9, 0.149], res_num=10)
337
338
339 To set the CSA value for the model-free run 'tm3' to the default value, type:
340
341 relax> value.set('tm3', param='csa')
342
343
344 To set the CSA value of all residues in the reduced spectral density mapping run '600MHz' to
345 -170 ppm, type:
346
347 relax> value.set('600MHz', -170 * 1e-6, 'csa')
348 relax> value.set('600MHz', value=-170 * 1e-6, param='csa')
349
350
351 To set the NH bond length of all residues in the model-free run 'm5' to 1.02 Angstroms,
352 type:
353
354 relax> value.set('m5', 1.02 * 1e-10, 'bond_length')
355 relax> value.set('m5', value=1.02 * 1e-10, param='r')
356
357
358 To set both the bond length and the CSA value for the run 'new' to the default values, type:
359
360 relax> value.set('new', param=['bond length', 'csa'])
361
362
363 To set both tf and ts in the model-free run 'm6' to 100 ps, type:
364
365 relax> value.set('m6', 100e-12, ['tf', 'ts'])
366 relax> value.set('m6', value=100e-12, param=['tf', 'ts'])
367
368
369 To set the S2 and te parameter values for model-free run 'm4' which has the parameters
370 {S2, te, Rex} to 0.56 and 13 ps, type:
371
372 relax> value.set('m4', [0.56, 13e-12], ['S2', 'te'], 10)
373 relax> value.set('m4', value=[0.56, 13e-12], param=['S2', 'te'], res_num=10)
374 relax> value.set(run='m4', value=[0.56, 13e-12], param=['S2', 'te'], res_num=10)
375 """
376
377
378 if self.__relax__.interpreter.intro:
379 text = sys.ps3 + "value.set("
380 text = text + "run=" + `run`
381 text = text + ", value=" + `value`
382 text = text + ", param=" + `param`
383 text = text + ", res_num=" + `res_num`
384 text = text + ", res_name=" + `res_name` + ")"
385 print text
386
387
388 if type(run) != str:
389 raise RelaxStrError, ('run', run)
390
391
392 if value != None and type(value) != float and type(value) != int and type(value) != list:
393 raise RelaxNoneFloatListError, ('value', value)
394 if type(value) == list:
395 for i in xrange(len(value)):
396 if type(value[i]) != float and type(value[i]) != int:
397 raise RelaxListFloatError, ('value', value)
398
399
400 if param != None and type(param) != str and type(param) != list:
401 raise RelaxNoneStrListError, ('parameter', param)
402 if type(param) == list:
403 for i in xrange(len(param)):
404 if type(param[i]) != str:
405 raise RelaxListStrError, ('parameter', param)
406
407
408 if (type(value) == float or type(value) == int) and param == None:
409 raise RelaxError, "Invalid value and parameter argument combination, for details by type 'help(value.set)'"
410
411
412 if type(value) == list and type(param) == str:
413 raise RelaxError, "Invalid value and parameter argument combination, for details by type 'help(value.set)'"
414
415
416 if type(value) == list and type(param) == list and len(value) != len(param):
417 raise RelaxError, "Both the value array and parameter array must be of equal length."
418
419
420 if res_num != None and type(res_num) != int and type(res_num) != str:
421 raise RelaxNoneIntStrError, ('residue number', res_num)
422
423
424 if res_name != None and type(res_name) != str:
425 raise RelaxNoneStrError, ('residue name', res_name)
426
427
428 self.__relax__.generic.value.set(run=run, value=value, param=param, res_num=res_num, res_name=res_name)
429
430
431 - def write(self, run=None, param=None, file=None, dir=None, force=0):
432 """Function for writing residue specific data values to a file.
433
434 Keyword Arguments
435 ~~~~~~~~~~~~~~~~~
436
437 run: The name of the run.
438
439 param: The parameter.
440
441 file: The name of the file.
442
443 dir: The directory name.
444
445 force: A flag which, if set to 1, will cause the file to be overwritten.
446
447
448 Description
449 ~~~~~~~~~~~
450
451 If no directory name is given, the file will be placed in the current working directory.
452
453 The parameter argument should be a string.
454
455
456 Examples
457 ~~~~~~~~
458
459 To write the CSA values for the run 'm1' to the file 'csa.txt', type:
460
461 relax> value.write('m1', 'CSA', 'csa.txt')
462 relax> value.write(run='m1', param='CSA', file='csa.txt')
463
464
465 To write the NOE values from the run 'noe' to the file 'noe', type:
466
467 relax> value.write('noe', 'noe', 'noe.out')
468 relax> value.write('noe', param='noe', file='noe.out')
469 relax> value.write(run='noe', param='noe', file='noe.out')
470 relax> value.write(run='noe', param='noe', file='noe.out', force=1)
471 """
472
473
474 if self.__relax__.interpreter.intro:
475 text = sys.ps3 + "value.write("
476 text = text + "run=" + `run`
477 text = text + ", param=" + `param`
478 text = text + ", file=" + `file`
479 text = text + ", dir=" + `dir`
480 text = text + ", force=" + `force` + ")"
481 print text
482
483
484 if type(run) != str:
485 raise RelaxStrError, ('run', run)
486
487
488 if type(param) != str:
489 raise RelaxStrError, ('parameter', param)
490
491
492 if type(file) != str:
493 raise RelaxStrError, ('file name', file)
494
495
496 if dir != None and type(dir) != str:
497 raise RelaxNoneStrError, ('directory name', dir)
498
499
500 if type(force) != int or (force != 0 and force != 1):
501 raise RelaxBinError, ('force flag', force)
502
503
504 self.__relax__.generic.value.write(run=run, param=param, file=file, dir=dir, force=force)
505
506
507
508
509
510
511 copy.__doc__ = copy.__doc__ + "\n\n" + regexp_doc() + "\n"
512 copy.__doc__ = copy.__doc__ + Model_free.set.__doc__ + "\n\n"
513 copy.__doc__ = copy.__doc__ + Model_free.return_data_name.__doc__ + "\n"
514 copy.__doc__ = copy.__doc__ + Jw_mapping.set.__doc__ + "\n"
515 copy.__doc__ = copy.__doc__ + Jw_mapping.return_data_name.__doc__ + "\n"
516
517
518 display.__doc__ = display.__doc__ + "\n\n" + regexp_doc() + "\n"
519 display.__doc__ = display.__doc__ + Model_free.return_data_name.__doc__ + "\n\n"
520 display.__doc__ = display.__doc__ + Jw_mapping.return_data_name.__doc__ + "\n"
521
522
523 read.__doc__ = read.__doc__ + "\n\n" + regexp_doc() + "\n"
524 read.__doc__ = read.__doc__ + Model_free.set.__doc__ + "\n\n"
525 read.__doc__ = read.__doc__ + Model_free.return_data_name.__doc__ + "\n"
526 read.__doc__ = read.__doc__ + Jw_mapping.set.__doc__ + "\n"
527 read.__doc__ = read.__doc__ + Jw_mapping.return_data_name.__doc__ + "\n"
528
529
530 set.__doc__ = set.__doc__ + "\n\n" + regexp_doc() + "\n"
531 set.__doc__ = set.__doc__ + Model_free.set.__doc__ + "\n"
532 set.__doc__ = set.__doc__ + Model_free.return_data_name.__doc__ + "\n"
533 set.__doc__ = set.__doc__ + Model_free.default_value.__doc__ + "\n\n"
534 set.__doc__ = set.__doc__ + Jw_mapping.set.__doc__ + "\n"
535 set.__doc__ = set.__doc__ + Jw_mapping.return_data_name.__doc__ + "\n"
536 set.__doc__ = set.__doc__ + Jw_mapping.default_value.__doc__ + "\n"
537 set.__doc__ = set.__doc__ + Diffusion_tensor.set.__doc__ + "\n"
538 set.__doc__ = set.__doc__ + Diffusion_tensor.return_data_name.__doc__ + "\n"
539 set.__doc__ = set.__doc__ + Diffusion_tensor.default_value.__doc__ + "\n\n"
540
541
542 write.__doc__ = write.__doc__ + "\n\n" + regexp_doc() + "\n"
543 write.__doc__ = write.__doc__ + Model_free.return_data_name.__doc__ + "\n\n"
544 write.__doc__ = write.__doc__ + Jw_mapping.return_data_name.__doc__ + "\n\n"
545 write.__doc__ = write.__doc__ + Noe.return_data_name.__doc__ + "\n"
546