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