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