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