1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """The value user function definitions."""
24
25
26 from os import sep
27 import dep_check
28 if dep_check.wx_module:
29 from wx import FD_OPEN, FD_SAVE
30 else:
31 FD_OPEN = -1
32 FD_SAVE = -1
33
34
35 from graphics import WIZARD_IMAGE_PATH
36 from pipe_control import diffusion_tensor, pipes, value
37 from prompt.doc_string import regexp_doc
38 from specific_analyses.consistency_tests import Consistency_tests
39 from specific_analyses.jw_mapping import Jw_mapping
40 from specific_analyses.model_free import Model_free
41 from specific_analyses.relax_fit import Relax_fit
42 from specific_analyses.n_state_model import N_state_model
43 from specific_analyses.noe import Noe
44 from user_functions.data import Uf_info; uf_info = Uf_info()
45 from user_functions.data import Uf_tables; uf_tables = Uf_tables()
46 from user_functions.objects import Desc_container
47
48
49
50 uf_class = uf_info.add_class('value')
51 uf_class.title = "Class for setting data values."
52 uf_class.menu_text = "&value"
53 uf_class.gui_icon = "relax.value"
54
55
56
57 uf = uf_info.add_uf('value.copy')
58 uf.title = "Copy spin specific data values from one data pipe to another."
59 uf.title_short = "Value copying."
60 uf.add_keyarg(
61 name = "pipe_from",
62 py_type = "str",
63 desc_short = "source data pipe",
64 desc = "The name of the pipe to copy from.",
65 wiz_element_type = 'combo',
66 wiz_combo_iter = pipes.pipe_names,
67 wiz_read_only = True
68 )
69 uf.add_keyarg(
70 name = "pipe_to",
71 py_type = "str",
72 desc_short = "destination data pipe",
73 desc = "The name of the pipe to copy to.",
74 wiz_element_type = 'combo',
75 wiz_combo_iter = pipes.pipe_names,
76 wiz_read_only = True
77 )
78 uf.add_keyarg(
79 name = "param",
80 py_type = "str",
81 desc_short = "parameter",
82 desc = "The parameter to copy. Only one parameter may be selected.",
83 wiz_element_type = 'combo',
84 wiz_combo_iter = value.get_parameters,
85 wiz_read_only = True
86 )
87
88 uf.desc.append(Desc_container())
89 uf.desc[-1].add_paragraph("If this is used to change values of previously minimised parameters, then the minimisation statistics (chi-squared value, iteration count, function count, gradient count, and Hessian count) will be reset.")
90
91 uf.desc.append(regexp_doc)
92 uf.desc.append(Model_free.set_doc)
93 uf.desc.append(Model_free.return_data_name_doc)
94 uf.desc.append(Jw_mapping.set_doc)
95 uf.desc.append(Jw_mapping.return_data_name_doc)
96 uf.desc.append(Consistency_tests.set_doc)
97 uf.desc.append(Consistency_tests.return_data_name_doc)
98 uf.desc.append(Relax_fit.set_doc)
99 uf.desc.append(Relax_fit.return_data_name_doc)
100 uf.desc.append(N_state_model.set_doc)
101 uf.desc.append(N_state_model.return_data_name_doc)
102 uf.desc.append(Desc_container("Prompt examples"))
103 uf.desc[-1].add_paragraph("To copy the CSA values from the data pipe 'm1' to 'm2', type:")
104 uf.desc[-1].add_prompt("relax> value.copy('m1', 'm2', 'csa')")
105 uf.backend = value.copy
106 uf.menu_text = "©"
107 uf.gui_icon = "oxygen.actions.list-add"
108 uf.wizard_height_desc = 500
109 uf.wizard_size = (1000, 750)
110 uf.wizard_image = WIZARD_IMAGE_PATH + 'value' + sep + 'value.png'
111
112
113
114 uf = uf_info.add_uf('value.display')
115 uf.title = "Display spin specific data values."
116 uf.title_short = "Display values."
117 uf.display = True
118 uf.add_keyarg(
119 name = "param",
120 py_type = "str",
121 desc_short = "parameter",
122 desc = "The parameter to display. Only one parameter may be selected.",
123 wiz_element_type = 'combo',
124 wiz_combo_iter = value.get_parameters,
125 wiz_read_only = True
126 )
127 uf.add_keyarg(
128 name = "scaling",
129 default = 1.0,
130 py_type = "float",
131 desc_short = "scaling",
132 desc = "The factor to scale parameters by."
133 )
134
135 uf.desc.append(Desc_container())
136 uf.desc[-1].add_paragraph("The values corresponding to the given parameter will be displayed. The scaling argument can be used to scale the parameter values. This can be useful for example in the case of the model-free Rex parameter to obtain the spectrometer dependent value from the omega_ex field strength independent internal value. Or to scale correlation times from seconds down to nanosecond or picosecond timescales.")
137 uf.desc.append(regexp_doc)
138 uf.desc.append(Model_free.return_data_name_doc)
139 uf.desc.append(Model_free.write_doc)
140 uf.desc.append(Jw_mapping.return_data_name_doc)
141 uf.desc.append(Consistency_tests.return_data_name_doc)
142 uf.desc.append(Noe.return_data_name_doc)
143 uf.desc.append(Relax_fit.return_data_name_doc)
144 uf.desc.append(N_state_model.return_data_name_doc)
145
146 uf.desc.append(Desc_container("Prompt examples"))
147 uf.desc[-1].add_paragraph("To show all CSA values, type:")
148 uf.desc[-1].add_prompt("relax> value.display('csa')")
149 uf.desc[-1].add_paragraph("To display the model-free Rex values scaled to 600 MHz, type one of:")
150 uf.desc[-1].add_prompt("relax> value.display('rex', scaling=(2.0*pi*600e6)**2)")
151 uf.desc[-1].add_prompt("relax> value.display(param='rex', scaling=(2.0*pi*600e6)**2)")
152 uf.backend = value.display
153 uf.menu_text = "&display"
154 uf.gui_icon = "oxygen.actions.document-preview"
155 uf.wizard_height_desc = 550
156 uf.wizard_size = (1000, 750)
157 uf.wizard_apply_button = False
158 uf.wizard_image = WIZARD_IMAGE_PATH + 'value' + sep + 'value.png'
159
160
161
162 uf = uf_info.add_uf('value.read')
163 uf.title = "Read spin specific data values from a file."
164 uf.title_short = "Reading values from file."
165 uf.add_keyarg(
166 name = "param",
167 py_type = "str",
168 desc_short = "parameter",
169 desc = "The parameter. Only one parameter may be selected.",
170 wiz_element_type = 'combo',
171 wiz_combo_iter = value.get_parameters,
172 wiz_read_only = True
173 )
174 uf.add_keyarg(
175 name = "scaling",
176 default = 1.0,
177 py_type = "float",
178 desc_short = "scaling",
179 desc = "The factor to scale parameters by."
180 )
181 uf.add_keyarg(
182 name = "file",
183 py_type = "str",
184 arg_type = "file sel",
185 desc_short = "file name",
186 desc = "The name of the file containing the values.",
187 wiz_filesel_style = FD_OPEN
188 )
189 uf.add_keyarg(
190 name = "dir",
191 py_type = "str",
192 arg_type = "dir",
193 desc_short = "directory name",
194 desc = "The directory where the file is located.",
195 can_be_none = True
196 )
197 uf.add_keyarg(
198 name = "spin_id_col",
199 py_type = "int",
200 arg_type = "free format",
201 desc_short = "spin ID string column",
202 desc = "The spin ID string column (an alternative to the mol, res, and spin name and number columns).",
203 can_be_none = True
204 )
205 uf.add_keyarg(
206 name = "mol_name_col",
207 py_type = "int",
208 arg_type = "free format",
209 desc_short = "molecule name column",
210 desc = "The molecule name column (alternative to the spin_id_col).",
211 can_be_none = True
212 )
213 uf.add_keyarg(
214 name = "res_num_col",
215 py_type = "int",
216 arg_type = "free format",
217 desc_short = "residue number column",
218 desc = "The residue number column (alternative to the spin_id_col).",
219 can_be_none = True
220 )
221 uf.add_keyarg(
222 name = "res_name_col",
223 py_type = "int",
224 arg_type = "free format",
225 desc_short = "residue name column",
226 desc = "The residue name column (alternative to the spin_id_col).",
227 can_be_none = True
228 )
229 uf.add_keyarg(
230 name = "spin_num_col",
231 py_type = "int",
232 arg_type = "free format",
233 desc_short = "spin number column",
234 desc = "The spin number column (alternative to the spin_id_col).",
235 can_be_none = True
236 )
237 uf.add_keyarg(
238 name = "spin_name_col",
239 py_type = "int",
240 arg_type = "free format",
241 desc_short = "spin name column",
242 desc = "The spin name column (alternative to the spin_id_col).",
243 can_be_none = True
244 )
245 uf.add_keyarg(
246 name = "data_col",
247 py_type = "int",
248 arg_type = "free format",
249 desc_short = "data column",
250 desc = "The RDC data column.",
251 can_be_none = True
252 )
253 uf.add_keyarg(
254 name = "error_col",
255 py_type = "int",
256 arg_type = "free format",
257 desc_short = "error column",
258 desc = "The experimental error column.",
259 can_be_none = True
260 )
261 uf.add_keyarg(
262 name = "sep",
263 py_type = "str",
264 arg_type = "free format",
265 desc_short = "column separator",
266 desc = "The column separator (the default is white space).",
267 can_be_none = True
268 )
269 uf.add_keyarg(
270 name = "spin_id",
271 py_type = "str",
272 desc_short = "spin ID string",
273 desc = "The spin ID string to restrict the loading of data to certain spin subsets."
274 )
275
276 uf.desc.append(Desc_container())
277 uf.desc[-1].add_paragraph("The spin system can be identified in the file using two different formats. The first is the spin ID string column which can include the molecule name, the residue name and number, and the spin name and number. Alternatively the molecule name, residue number, residue name, spin number and/or spin name columns can be supplied allowing this information to be in separate columns. Note that the numbering of columns starts at one. The spin ID string can be used to restrict the reading to certain spin types, for example only 15N spins when only residue information is in the file.")
278 uf.desc[-1].add_paragraph("If this is used to change values of previously minimised parameters, then the minimisation statistics (chi-squared value, iteration count, function count, gradient count, and Hessian count) will be reset.")
279 uf.desc.append(regexp_doc)
280 uf.desc.append(Model_free.set_doc)
281 uf.desc.append(Model_free.return_data_name_doc)
282 uf.desc.append(Jw_mapping.set_doc)
283 uf.desc.append(Jw_mapping.return_data_name_doc)
284 uf.desc.append(Consistency_tests.set_doc)
285 uf.desc.append(Consistency_tests.return_data_name_doc)
286 uf.desc.append(Relax_fit.set_doc)
287 uf.desc.append(Relax_fit.return_data_name_doc)
288 uf.desc.append(N_state_model.set_doc)
289 uf.desc.append(N_state_model.return_data_name_doc)
290
291 uf.desc.append(Desc_container("Prompt examples"))
292 uf.desc[-1].add_paragraph("To load 15N CSA values from the file 'csa_values' in the directory 'data', where spins are only identified by residue name and number, type one of the following:")
293 uf.desc[-1].add_prompt("relax> value.read('csa', 'data/csa_value', spin_id='@N')")
294 uf.desc[-1].add_prompt("relax> value.read('csa', 'csa_value', dir='data', spin_id='@N')")
295 uf.desc[-1].add_prompt("relax> value.read(param='csa', file='csa_value', dir='data', res_num_col=1, res_name_col=2, data_col=3, error_col=4, spin_id='@N')")
296 uf.backend = value.read
297 uf.menu_text = "&read"
298 uf.gui_icon = "oxygen.actions.document-open"
299 uf.wizard_height_desc = 450
300 uf.wizard_size = (1000, 750)
301 uf.wizard_image = WIZARD_IMAGE_PATH + 'value' + sep + 'value.png'
302
303
304
305 uf = uf_info.add_uf('value.set')
306 uf.title = "Set spin specific data values."
307 uf.title_short = "Value setting."
308 uf.add_keyarg(
309 name = "val",
310 py_type = "val_or_list",
311 desc_short = "value",
312 desc = "The value(s).",
313 can_be_none = True
314 )
315 uf.add_keyarg(
316 name = "param",
317 py_type = "str_or_str_list",
318 desc_short = "parameter",
319 desc = "The parameter(s).",
320 wiz_element_type = 'combo_list',
321 wiz_combo_iter = value.get_parameters,
322 wiz_read_only = False,
323 can_be_none = True
324 )
325 uf.add_keyarg(
326 name = "spin_id",
327 py_type = "str",
328 arg_type = "spin ID",
329 desc_short = "spin ID to restrict value setting to",
330 desc = "The spin ID string to restrict value setting to.",
331 can_be_none = True
332 )
333 uf.add_keyarg(
334 name = "error",
335 default = False,
336 py_type = "bool",
337 desc_short = "error flag",
338 desc = "A flag which if True will cause the error rather than parameter to be set."
339 )
340
341 uf.desc.append(Desc_container())
342 uf.desc[-1].add_paragraph("If this function is used to change values of previously minimised results, then the minimisation statistics (chi-squared value, iteration count, function count, gradient count, and Hessian count) will be reset to None.")
343 uf.desc[-1].add_paragraph("The value can be None, a single value, or an array of values while the parameter can be None, a string, or array of strings. The choice of which combination determines the behaviour of this function. The following table describes what occurs in each instance. In these columns, 'None' corresponds to None, '1' corresponds to either a single value or single string, and 'n' corresponds to either an array of values or an array of strings.")
344 table = uf_tables.add_table(label="table: value.set combinations", caption="The value and parameter combination options for the value.set user function.", caption_short="The value and parameter combinations for the value.set user function.")
345 table.add_headings(["Value", "Param", "Description"])
346 table.add_row(["None", "None", "This case is used to set the model parameters prior to minimisation or calculation. The model parameters are set to the default values."])
347 table.add_row(["1", "None", "Invalid combination."])
348 table.add_row(["n", "None", "This case is used to set the model parameters prior to minimisation or calculation. The length of the val array must be equal to the number of model parameters. The parameters will be set to the corresponding number."])
349 table.add_row(["None", "1", "The parameter matching the string will be set to the default value."])
350 table.add_row(["1", "1", "The parameter matching the string will be set to the supplied number."])
351 table.add_row(["n", "1", "Invalid combination."])
352 table.add_row(["None", "n", "Each parameter matching the strings will be set to the default values."])
353 table.add_row(["1", "n", "Each parameter matching the strings will be set to the supplied number."])
354 table.add_row(["n", "n", "Each parameter matching the strings will be set to the corresponding number. Both arrays must be of equal length."])
355 uf.desc[-1].add_table(table.label)
356
357 uf.desc.append(Desc_container("Spin identification"))
358 uf.desc[-1].add_paragraph("If the spin ID is left unset, then this will be applied to all spins. If the data is global non-spin specific data, such as diffusion tensor parameters, supplying the spin identifier will terminate the program with an error.")
359 uf.desc.append(regexp_doc)
360 uf.desc.append(Model_free.set_doc)
361 uf.desc.append(Model_free.return_data_name_doc)
362 uf.desc.append(Model_free.default_value_doc)
363 uf.desc.append(diffusion_tensor.__set_doc__)
364 uf.desc.append(diffusion_tensor.__return_data_name_doc__)
365 uf.desc.append(diffusion_tensor.__default_value_doc__)
366 uf.desc.append(Jw_mapping.set_doc)
367 uf.desc.append(Jw_mapping.return_data_name_doc)
368 uf.desc.append(Jw_mapping.default_value_doc)
369 uf.desc.append(Consistency_tests.set_doc)
370 uf.desc.append(Consistency_tests.return_data_name_doc)
371 uf.desc.append(Consistency_tests.default_value_doc)
372 uf.desc.append(Relax_fit.set_doc)
373 uf.desc.append(Relax_fit.return_data_name_doc)
374 uf.desc.append(Relax_fit.default_value_doc)
375 uf.desc.append(N_state_model.set_doc)
376 uf.desc.append(N_state_model.return_data_name_doc)
377 uf.desc.append(N_state_model.default_value_doc)
378
379 uf.desc.append(Desc_container("Prompt examples"))
380 uf.desc[-1].add_paragraph("To set the parameter values for the current data pipe to the default values, for all spins, type:")
381 uf.desc[-1].add_prompt("relax> value.set()")
382 uf.desc[-1].add_paragraph("To set the parameter values of residue 10, which is in the current model-free data pipe 'm4' and has the parameters {S2, te, Rex}, the following can be used. Rex term is the value for the first given field strength.")
383 uf.desc[-1].add_prompt("relax> value.set([0.97, 2.048*1e-9, 0.149], spin_id=':10')")
384 uf.desc[-1].add_prompt("relax> value.set(val=[0.97, 2.048*1e-9, 0.149], spin_id=':10')")
385 uf.desc[-1].add_paragraph("To set the CSA value of all spins to the default value, type:")
386 uf.desc[-1].add_prompt("relax> value.set(param='csa')")
387 uf.desc[-1].add_paragraph("To set the CSA value of all spins to -172 ppm, type:")
388 uf.desc[-1].add_prompt("relax> value.set(-172 * 1e-6, 'csa')")
389 uf.desc[-1].add_prompt("relax> value.set(val=-172 * 1e-6, param='csa')")
390 uf.desc[-1].add_paragraph("To set the NH bond length of all spins to 1.02 Angstroms, type:")
391 uf.desc[-1].add_prompt("relax> value.set(1.02 * 1e-10, 'r')")
392 uf.desc[-1].add_prompt("relax> value.set(val=1.02 * 1e-10, param='r')")
393 uf.desc[-1].add_paragraph("To set both the bond length and the CSA value to the default values, type:")
394 uf.desc[-1].add_prompt("relax> value.set(param=['r', 'csa'])")
395 uf.desc[-1].add_paragraph("To set both tf and ts to 100 ps, type:")
396 uf.desc[-1].add_prompt("relax> value.set(100e-12, ['tf', 'ts'])")
397 uf.desc[-1].add_prompt("relax> value.set(val=100e-12, param=['tf', 'ts'])")
398 uf.desc[-1].add_paragraph("To set the S2 and te parameter values of residue 126, Ca spins to 0.56 and 13 ps, type:")
399 uf.desc[-1].add_prompt("relax> value.set([0.56, 13e-12], ['s2', 'te'], ':126@Ca')")
400 uf.desc[-1].add_prompt("relax> value.set(val=[0.56, 13e-12], param=['s2', 'te'], spin_id=':126@Ca')")
401 uf.desc[-1].add_prompt("relax> value.set(val=[0.56, 13e-12], param=['s2', 'te'], spin_id=':126@Ca')")
402 uf.backend = value.set
403 uf.menu_text = "&set"
404 uf.wizard_height_desc = 480
405 uf.wizard_size = (1000, 750)
406 uf.wizard_image = WIZARD_IMAGE_PATH + 'value' + sep + 'value.png'
407
408
409
410 uf = uf_info.add_uf('value.write')
411 uf.title = "Write spin specific data values to a file."
412 uf.title_short = "Value writing."
413 uf.add_keyarg(
414 name = "param",
415 py_type = "str",
416 desc_short = "parameter",
417 desc = "The parameter.",
418 wiz_element_type = 'combo',
419 wiz_combo_iter = value.get_parameters,
420 wiz_read_only = True
421 )
422 uf.add_keyarg(
423 name = "file",
424 py_type = "str",
425 arg_type = "file sel",
426 desc_short = "file name",
427 desc = "The name of the file.",
428 wiz_filesel_style = FD_SAVE
429 )
430 uf.add_keyarg(
431 name = "dir",
432 py_type = "str",
433 arg_type = "dir",
434 desc_short = "directory name",
435 desc = "The directory name.",
436 can_be_none = True
437 )
438 uf.add_keyarg(
439 name = "scaling",
440 default = 1.0,
441 py_type = "float",
442 desc_short = "scaling",
443 desc = "The factor to scale parameters by."
444 )
445 uf.add_keyarg(
446 name = "comment",
447 py_type = "str",
448 desc_short = "comment",
449 desc = "Text which will be added to the start of the file as comments. All lines will be prefixed by '# '.",
450 can_be_none = True
451 )
452 uf.add_keyarg(
453 name = "bc",
454 default = False,
455 py_type = "bool",
456 desc_short = "back calculated value flag",
457 desc = "A flag which if True will cause the back calculated values to be written to file rather than the actual data."
458 )
459 uf.add_keyarg(
460 name = "force",
461 default = False,
462 py_type = "bool",
463 desc_short = "force flag",
464 desc = "A flag which, if set to True, will cause the file to be overwritten."
465 )
466
467 uf.desc.append(Desc_container())
468 uf.desc[-1].add_paragraph("The values corresponding to the given parameter will be written to file. The scaling argument can be used to scale the parameter values. This can be useful for example in the case of the model-free Rex parameter to obtain the spectrometer dependent value from the omega_ex field strength independent internal value. Or to scale correlation times from seconds down to nanosecond or picosecond timescales.")
469 uf.desc.append(regexp_doc)
470 uf.desc.append(Model_free.return_data_name_doc)
471 uf.desc.append(Model_free.write_doc)
472 uf.desc.append(Jw_mapping.return_data_name_doc)
473 uf.desc.append(Consistency_tests.return_data_name_doc)
474 uf.desc.append(Noe.return_data_name_doc)
475 uf.desc.append(Relax_fit.return_data_name_doc)
476 uf.desc.append(N_state_model.return_data_name_doc)
477
478 uf.desc.append(Desc_container("Prompt examples"))
479 uf.desc[-1].add_paragraph("To write the CSA values to the file 'csa.txt', type one of:")
480 uf.desc[-1].add_prompt("relax> value.write('csa', 'csa.txt')")
481 uf.desc[-1].add_prompt("relax> value.write(param='csa', file='csa.txt')")
482 uf.desc[-1].add_paragraph("To write the NOE values to the file 'noe', type one of:")
483 uf.desc[-1].add_prompt("relax> value.write('noe', 'noe.out')")
484 uf.desc[-1].add_prompt("relax> value.write(param='noe', file='noe.out')")
485 uf.desc[-1].add_prompt("relax> value.write(param='noe', file='noe.out')")
486 uf.desc[-1].add_prompt("relax> value.write(param='noe', file='noe.out', force=True)")
487 uf.desc[-1].add_paragraph("To write the model-free Rex values scaled to 600 MHz to the file 'rex_600', type one of:")
488 uf.desc[-1].add_prompt("relax> value.write('rex', 'rex_600', scaling=(2.0*pi*600e6)**2)")
489 uf.desc[-1].add_prompt("relax> value.write(param='rex', file='rex_600', scaling=(2.0*pi*600e6)**2)")
490 uf.backend = value.write
491 uf.menu_text = "&write"
492 uf.gui_icon = "oxygen.actions.document-save"
493 uf.wizard_height_desc = 400
494 uf.wizard_size = (1000, 750)
495 uf.wizard_image = WIZARD_IMAGE_PATH + 'value' + sep + 'value.png'
496