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