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