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 prompt.doc_string import regexp_doc
36 from generic_fns import diffusion_tensor, pipes, value
37 from graphics import WIZARD_IMAGE_PATH
38 from relax_errors import RelaxError
39 from specific_fns.consistency_tests import Consistency_tests
40 from specific_fns.jw_mapping import Jw_mapping
41 from specific_fns.model_free import Model_free
42 from specific_fns.relax_fit import Relax_fit
43 from specific_fns.n_state_model import N_state_model
44 from specific_fns.noe import Noe
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(Desc_container("Prompt examples"))
104 uf.desc[-1].add_paragraph("To copy the CSA values from the data pipe 'm1' to 'm2', type:")
105 uf.desc[-1].add_prompt("relax> value.copy('m1', 'm2', 'csa')")
106 uf.backend = value.copy
107 uf.menu_text = "©"
108 uf.gui_icon = "oxygen.actions.list-add"
109 uf.wizard_height_desc = 500
110 uf.wizard_size = (1000, 750)
111 uf.wizard_image = WIZARD_IMAGE_PATH + 'value' + sep + 'value.png'
112
113
114
115 uf = uf_info.add_uf('value.display')
116 uf.title = "Display spin specific data values."
117 uf.title_short = "Display values."
118 uf.display = True
119 uf.add_keyarg(
120 name = "param",
121 py_type = "str",
122 desc_short = "parameter",
123 desc = "The parameter to display. Only one parameter may be selected.",
124 wiz_element_type = 'combo',
125 wiz_combo_iter = value.get_parameters,
126 wiz_read_only = True
127 )
128 uf.add_keyarg(
129 name = "scaling",
130 default = 1.0,
131 py_type = "float",
132 desc_short = "scaling",
133 desc = "The factor to scale parameters by."
134 )
135
136 uf.desc.append(Desc_container())
137 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.")
138 uf.desc.append(regexp_doc)
139 uf.desc.append(Model_free.return_data_name_doc)
140 uf.desc.append(Model_free.write_doc)
141 uf.desc.append(Jw_mapping.return_data_name_doc)
142 uf.desc.append(Consistency_tests.return_data_name_doc)
143 uf.desc.append(Noe.return_data_name_doc)
144 uf.desc.append(Relax_fit.return_data_name_doc)
145 uf.desc.append(N_state_model.return_data_name_doc)
146
147 uf.desc.append(Desc_container("Prompt examples"))
148 uf.desc[-1].add_paragraph("To show all CSA values, type:")
149 uf.desc[-1].add_prompt("relax> value.display('csa')")
150 uf.desc[-1].add_paragraph("To display the model-free Rex values scaled to 600 MHz, type one of:")
151 uf.desc[-1].add_prompt("relax> value.display('rex', scaling=(2.0*pi*600e6)**2)")
152 uf.desc[-1].add_prompt("relax> value.display(param='rex', scaling=(2.0*pi*600e6)**2)")
153 uf.backend = value.display
154 uf.menu_text = "&display"
155 uf.gui_icon = "oxygen.actions.document-preview"
156 uf.wizard_height_desc = 550
157 uf.wizard_size = (1000, 750)
158 uf.wizard_apply_button = False
159 uf.wizard_image = WIZARD_IMAGE_PATH + 'value' + sep + 'value.png'
160
161
162
163 uf = uf_info.add_uf('value.read')
164 uf.title = "Read spin specific data values from a file."
165 uf.title_short = "Reading values from file."
166 uf.add_keyarg(
167 name = "param",
168 py_type = "str",
169 desc_short = "parameter",
170 desc = "The parameter. Only one parameter may be selected.",
171 wiz_element_type = 'combo',
172 wiz_combo_iter = value.get_parameters,
173 wiz_read_only = True
174 )
175 uf.add_keyarg(
176 name = "scaling",
177 default = 1.0,
178 py_type = "float",
179 desc_short = "scaling",
180 desc = "The factor to scale parameters by."
181 )
182 uf.add_keyarg(
183 name = "file",
184 py_type = "str",
185 arg_type = "file sel",
186 desc_short = "file name",
187 desc = "The name of the file containing the values.",
188 wiz_filesel_style = FD_OPEN
189 )
190 uf.add_keyarg(
191 name = "dir",
192 py_type = "str",
193 arg_type = "dir",
194 desc_short = "directory name",
195 desc = "The directory where the file is located.",
196 can_be_none = True
197 )
198 uf.add_keyarg(
199 name = "spin_id_col",
200 py_type = "int",
201 arg_type = "free format",
202 desc_short = "spin ID string column",
203 desc = "The spin ID string column (an alternative to the mol, res, and spin name and number columns).",
204 can_be_none = True
205 )
206 uf.add_keyarg(
207 name = "mol_name_col",
208 py_type = "int",
209 arg_type = "free format",
210 desc_short = "molecule name column",
211 desc = "The molecule name column (alternative to the spin_id_col).",
212 can_be_none = True
213 )
214 uf.add_keyarg(
215 name = "res_num_col",
216 py_type = "int",
217 arg_type = "free format",
218 desc_short = "residue number column",
219 desc = "The residue number column (alternative to the spin_id_col).",
220 can_be_none = True
221 )
222 uf.add_keyarg(
223 name = "res_name_col",
224 py_type = "int",
225 arg_type = "free format",
226 desc_short = "residue name column",
227 desc = "The residue name column (alternative to the spin_id_col).",
228 can_be_none = True
229 )
230 uf.add_keyarg(
231 name = "spin_num_col",
232 py_type = "int",
233 arg_type = "free format",
234 desc_short = "spin number column",
235 desc = "The spin number column (alternative to the spin_id_col).",
236 can_be_none = True
237 )
238 uf.add_keyarg(
239 name = "spin_name_col",
240 py_type = "int",
241 arg_type = "free format",
242 desc_short = "spin name column",
243 desc = "The spin name column (alternative to the spin_id_col).",
244 can_be_none = True
245 )
246 uf.add_keyarg(
247 name = "data_col",
248 py_type = "int",
249 arg_type = "free format",
250 desc_short = "data column",
251 desc = "The RDC data column.",
252 can_be_none = True
253 )
254 uf.add_keyarg(
255 name = "error_col",
256 py_type = "int",
257 arg_type = "free format",
258 desc_short = "error column",
259 desc = "The experimental error column.",
260 can_be_none = True
261 )
262 uf.add_keyarg(
263 name = "sep",
264 py_type = "str",
265 arg_type = "free format",
266 desc_short = "column separator",
267 desc = "The column separator (the default is white space).",
268 can_be_none = True
269 )
270 uf.add_keyarg(
271 name = "spin_id",
272 py_type = "str",
273 desc_short = "spin ID string",
274 desc = "The spin ID string to restrict the loading of data to certain spin subsets."
275 )
276
277 uf.desc.append(Desc_container())
278 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.")
279 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.")
280 uf.desc.append(regexp_doc)
281 uf.desc.append(Model_free.set_doc)
282 uf.desc.append(Model_free.return_data_name_doc)
283 uf.desc.append(Jw_mapping.set_doc)
284 uf.desc.append(Jw_mapping.return_data_name_doc)
285 uf.desc.append(Consistency_tests.set_doc)
286 uf.desc.append(Consistency_tests.return_data_name_doc)
287 uf.desc.append(Relax_fit.set_doc)
288 uf.desc.append(Relax_fit.return_data_name_doc)
289 uf.desc.append(N_state_model.set_doc)
290 uf.desc.append(N_state_model.return_data_name_doc)
291
292 uf.desc.append(Desc_container("Prompt examples"))
293 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:")
294 uf.desc[-1].add_prompt("relax> value.read('csa', 'data/csa_value', spin_id='@N')")
295 uf.desc[-1].add_prompt("relax> value.read('csa', 'csa_value', dir='data', spin_id='@N')")
296 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')")
297 uf.backend = value.read
298 uf.menu_text = "&read"
299 uf.gui_icon = "oxygen.actions.document-open"
300 uf.wizard_height_desc = 200
301 uf.wizard_size = (1000, 750)
302 uf.wizard_image = WIZARD_IMAGE_PATH + 'value' + sep + 'value.png'
303
304
305
306 uf = uf_info.add_uf('value.set')
307 uf.title = "Set spin specific data values."
308 uf.title_short = "Value setting."
309 uf.add_keyarg(
310 name = "val",
311 py_type = "val_or_list",
312 desc_short = "value",
313 desc = "The value(s).",
314 can_be_none = True
315 )
316 uf.add_keyarg(
317 name = "param",
318 py_type = "str_or_str_list",
319 desc_short = "parameter",
320 desc = "The parameter(s).",
321 wiz_element_type = 'combo_list',
322 wiz_combo_iter = value.get_parameters,
323 wiz_read_only = False,
324 can_be_none = True
325 )
326 uf.add_keyarg(
327 name = "spin_id",
328 py_type = "str",
329 arg_type = "spin ID",
330 desc_short = "spin ID to restrict value setting to",
331 desc = "The spin ID string to restrict value setting to.",
332 can_be_none = True
333 )
334
335 uf.desc.append(Desc_container())
336 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.")
337 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.")
338 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.")
339 table.add_headings(["Value", "Param", "Description"])
340 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."])
341 table.add_row(["1", "None", "Invalid combination."])
342 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."])
343 table.add_row(["None", "1", "The parameter matching the string will be set to the default value."])
344 table.add_row(["1", "1", "The parameter matching the string will be set to the supplied number."])
345 table.add_row(["n", "1", "Invalid combination."])
346 table.add_row(["None", "n", "Each parameter matching the strings will be set to the default values."])
347 table.add_row(["1", "n", "Each parameter matching the strings will be set to the supplied number."])
348 table.add_row(["n", "n", "Each parameter matching the strings will be set to the corresponding number. Both arrays must be of equal length."])
349 uf.desc[-1].add_table(table.label)
350
351 uf.desc.append(Desc_container("Spin identification"))
352 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.")
353 uf.desc.append(regexp_doc)
354 uf.desc.append(Model_free.set_doc)
355 uf.desc.append(Model_free.return_data_name_doc)
356 uf.desc.append(Model_free.default_value_doc)
357 uf.desc.append(diffusion_tensor.__set_doc__)
358 uf.desc.append(diffusion_tensor.__return_data_name_doc__)
359 uf.desc.append(diffusion_tensor.__default_value_doc__)
360 uf.desc.append(Jw_mapping.set_doc)
361 uf.desc.append(Jw_mapping.return_data_name_doc)
362 uf.desc.append(Jw_mapping.default_value_doc)
363 uf.desc.append(Consistency_tests.set_doc)
364 uf.desc.append(Consistency_tests.return_data_name_doc)
365 uf.desc.append(Consistency_tests.default_value_doc)
366 uf.desc.append(Relax_fit.set_doc)
367 uf.desc.append(Relax_fit.return_data_name_doc)
368 uf.desc.append(Relax_fit.default_value_doc)
369 uf.desc.append(N_state_model.set_doc)
370 uf.desc.append(N_state_model.return_data_name_doc)
371 uf.desc.append(N_state_model.default_value_doc)
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 = 480
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 data values to a file."
406 uf.title_short = "Value writing."
407 uf.add_keyarg(
408 name = "param",
409 py_type = "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 py_type = "str",
419 arg_type = "file sel",
420 desc_short = "file name",
421 desc = "The name of the file.",
422 wiz_filesel_style = FD_SAVE
423 )
424 uf.add_keyarg(
425 name = "dir",
426 py_type = "str",
427 arg_type = "dir",
428 desc_short = "directory name",
429 desc = "The directory name.",
430 can_be_none = True
431 )
432 uf.add_keyarg(
433 name = "scaling",
434 default = 1.0,
435 py_type = "float",
436 desc_short = "scaling",
437 desc = "The factor to scale parameters by."
438 )
439 uf.add_keyarg(
440 name = "comment",
441 py_type = "str",
442 desc_short = "comment",
443 desc = "Text which will be added to the start of the file as comments. All lines will be prefixed by '# '.",
444 can_be_none = True
445 )
446 uf.add_keyarg(
447 name = "bc",
448 default = False,
449 py_type = "bool",
450 desc_short = "back calculated value flag",
451 desc = "A flag which if True will cause the back calculated values to be written to file rather than the actual data."
452 )
453 uf.add_keyarg(
454 name = "force",
455 default = False,
456 py_type = "bool",
457 desc_short = "force flag",
458 desc = "A flag which, if set to True, will cause the file to be overwritten."
459 )
460
461 uf.desc.append(Desc_container())
462 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.")
463 uf.desc.append(regexp_doc)
464 uf.desc.append(Model_free.return_data_name_doc)
465 uf.desc.append(Model_free.write_doc)
466 uf.desc.append(Jw_mapping.return_data_name_doc)
467 uf.desc.append(Consistency_tests.return_data_name_doc)
468 uf.desc.append(Noe.return_data_name_doc)
469 uf.desc.append(Relax_fit.return_data_name_doc)
470 uf.desc.append(N_state_model.return_data_name_doc)
471
472 uf.desc.append(Desc_container("Prompt examples"))
473 uf.desc[-1].add_paragraph("To write the CSA values to the file 'csa.txt', type one of:")
474 uf.desc[-1].add_prompt("relax> value.write('csa', 'csa.txt')")
475 uf.desc[-1].add_prompt("relax> value.write(param='csa', file='csa.txt')")
476 uf.desc[-1].add_paragraph("To write the NOE values to the file 'noe', type one of:")
477 uf.desc[-1].add_prompt("relax> value.write('noe', 'noe.out')")
478 uf.desc[-1].add_prompt("relax> value.write(param='noe', file='noe.out')")
479 uf.desc[-1].add_prompt("relax> value.write(param='noe', file='noe.out')")
480 uf.desc[-1].add_prompt("relax> value.write(param='noe', file='noe.out', force=True)")
481 uf.desc[-1].add_paragraph("To write the model-free Rex values scaled to 600 MHz to the file 'rex_600', type one of:")
482 uf.desc[-1].add_prompt("relax> value.write('rex', 'rex_600', scaling=(2.0*pi*600e6)**2)")
483 uf.desc[-1].add_prompt("relax> value.write(param='rex', file='rex_600', scaling=(2.0*pi*600e6)**2)")
484 uf.backend = value.write
485 uf.menu_text = "&write"
486 uf.gui_icon = "oxygen.actions.document-save"
487 uf.wizard_height_desc = 400
488 uf.wizard_size = (1000, 750)
489 uf.wizard_image = WIZARD_IMAGE_PATH + 'value' + sep + 'value.png'
490