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.desc.append(regexp_doc)
129 uf.desc.append(Model_free.return_data_name_doc)
130 uf.desc.append(Jw_mapping.return_data_name_doc)
131 uf.desc.append(Consistency_tests.return_data_name_doc)
132 uf.desc.append(Noe.return_data_name_doc)
133 uf.desc.append(Relax_fit.return_data_name_doc)
134 uf.desc.append(N_state_model.return_data_name_doc)
135
136 uf.desc.append(Desc_container("Prompt examples"))
137 uf.desc[-1].add_paragraph("To show all CSA values, type:")
138 uf.desc[-1].add_prompt("relax> value.display('csa')")
139 uf.backend = value.display
140 uf.menu_text = "&display"
141 uf.gui_icon = "oxygen.actions.document-preview"
142 uf.wizard_height_desc = 550
143 uf.wizard_size = (1000, 750)
144 uf.wizard_apply_button = False
145 uf.wizard_image = WIZARD_IMAGE_PATH + 'value' + sep + 'value.png'
146
147
148
149 uf = uf_info.add_uf('value.read')
150 uf.title = "Read spin specific data values from a file."
151 uf.title_short = "Reading values from file."
152 uf.add_keyarg(
153 name = "param",
154 py_type = "str",
155 desc_short = "parameter",
156 desc = "The parameter. Only one parameter may be selected.",
157 wiz_element_type = 'combo',
158 wiz_combo_iter = value.get_parameters,
159 wiz_read_only = True
160 )
161 uf.add_keyarg(
162 name = "scaling",
163 default = 1.0,
164 py_type = "float",
165 desc_short = "scaling",
166 desc = "The factor to scale parameters by."
167 )
168 uf.add_keyarg(
169 name = "file",
170 py_type = "str",
171 arg_type = "file sel",
172 desc_short = "file name",
173 desc = "The name of the file containing the values.",
174 wiz_filesel_style = FD_OPEN
175 )
176 uf.add_keyarg(
177 name = "dir",
178 py_type = "str",
179 arg_type = "dir",
180 desc_short = "directory name",
181 desc = "The directory where the file is located.",
182 can_be_none = True
183 )
184 uf.add_keyarg(
185 name = "spin_id_col",
186 py_type = "int",
187 arg_type = "free format",
188 desc_short = "spin ID string column",
189 desc = "The spin ID string column (an alternative to the mol, res, and spin name and number columns).",
190 can_be_none = True
191 )
192 uf.add_keyarg(
193 name = "mol_name_col",
194 py_type = "int",
195 arg_type = "free format",
196 desc_short = "molecule name column",
197 desc = "The molecule name column (alternative to the spin_id_col).",
198 can_be_none = True
199 )
200 uf.add_keyarg(
201 name = "res_num_col",
202 py_type = "int",
203 arg_type = "free format",
204 desc_short = "residue number column",
205 desc = "The residue number column (alternative to the spin_id_col).",
206 can_be_none = True
207 )
208 uf.add_keyarg(
209 name = "res_name_col",
210 py_type = "int",
211 arg_type = "free format",
212 desc_short = "residue name column",
213 desc = "The residue name column (alternative to the spin_id_col).",
214 can_be_none = True
215 )
216 uf.add_keyarg(
217 name = "spin_num_col",
218 py_type = "int",
219 arg_type = "free format",
220 desc_short = "spin number column",
221 desc = "The spin number column (alternative to the spin_id_col).",
222 can_be_none = True
223 )
224 uf.add_keyarg(
225 name = "spin_name_col",
226 py_type = "int",
227 arg_type = "free format",
228 desc_short = "spin name column",
229 desc = "The spin name column (alternative to the spin_id_col).",
230 can_be_none = True
231 )
232 uf.add_keyarg(
233 name = "data_col",
234 py_type = "int",
235 arg_type = "free format",
236 desc_short = "data column",
237 desc = "The RDC data column.",
238 can_be_none = True
239 )
240 uf.add_keyarg(
241 name = "error_col",
242 py_type = "int",
243 arg_type = "free format",
244 desc_short = "error column",
245 desc = "The experimental error column.",
246 can_be_none = True
247 )
248 uf.add_keyarg(
249 name = "sep",
250 py_type = "str",
251 arg_type = "free format",
252 desc_short = "column separator",
253 desc = "The column separator (the default is white space).",
254 can_be_none = True
255 )
256 uf.add_keyarg(
257 name = "spin_id",
258 py_type = "str",
259 desc_short = "spin ID string",
260 desc = "The spin ID string to restrict the loading of data to certain spin subsets."
261 )
262
263 uf.desc.append(Desc_container())
264 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.")
265 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.")
266 uf.desc.append(regexp_doc)
267 uf.desc.append(Model_free.set_doc)
268 uf.desc.append(Model_free.return_data_name_doc)
269 uf.desc.append(Jw_mapping.set_doc)
270 uf.desc.append(Jw_mapping.return_data_name_doc)
271 uf.desc.append(Consistency_tests.set_doc)
272 uf.desc.append(Consistency_tests.return_data_name_doc)
273 uf.desc.append(Relax_fit.set_doc)
274 uf.desc.append(Relax_fit.return_data_name_doc)
275 uf.desc.append(N_state_model.set_doc)
276 uf.desc.append(N_state_model.return_data_name_doc)
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 = 200
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 spin specific data values."
294 uf.title_short = "Value setting."
295 uf.add_keyarg(
296 name = "val",
297 py_type = "val_or_list",
298 desc_short = "value",
299 desc = "The value(s).",
300 can_be_none = True
301 )
302 uf.add_keyarg(
303 name = "param",
304 py_type = "str_or_str_list",
305 desc_short = "parameter",
306 desc = "The parameter(s).",
307 wiz_element_type = 'combo_list',
308 wiz_combo_iter = value.get_parameters,
309 wiz_read_only = False,
310 can_be_none = True
311 )
312 uf.add_keyarg(
313 name = "spin_id",
314 py_type = "str",
315 arg_type = "spin ID",
316 desc_short = "spin ID to restrict value setting to",
317 desc = "The spin ID string to restrict value setting to.",
318 can_be_none = True
319 )
320
321 uf.desc.append(Desc_container())
322 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.")
323 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.")
324 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.")
325 table.add_headings(["Value", "Param", "Description"])
326 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."])
327 table.add_row(["1", "None", "Invalid combination."])
328 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."])
329 table.add_row(["None", "1", "The parameter matching the string will be set to the default value."])
330 table.add_row(["1", "1", "The parameter matching the string will be set to the supplied number."])
331 table.add_row(["n", "1", "Invalid combination."])
332 table.add_row(["None", "n", "Each parameter matching the strings will be set to the default values."])
333 table.add_row(["1", "n", "Each parameter matching the strings will be set to the supplied number."])
334 table.add_row(["n", "n", "Each parameter matching the strings will be set to the corresponding number. Both arrays must be of equal length."])
335 uf.desc[-1].add_table(table.label)
336
337 uf.desc.append(Desc_container("Spin identification"))
338 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.")
339 uf.desc.append(regexp_doc)
340 uf.desc.append(Model_free.set_doc)
341 uf.desc.append(Model_free.return_data_name_doc)
342 uf.desc.append(Model_free.default_value_doc)
343 uf.desc.append(diffusion_tensor.__set_doc__)
344 uf.desc.append(diffusion_tensor.__return_data_name_doc__)
345 uf.desc.append(diffusion_tensor.__default_value_doc__)
346 uf.desc.append(Jw_mapping.set_doc)
347 uf.desc.append(Jw_mapping.return_data_name_doc)
348 uf.desc.append(Jw_mapping.default_value_doc)
349 uf.desc.append(Consistency_tests.set_doc)
350 uf.desc.append(Consistency_tests.return_data_name_doc)
351 uf.desc.append(Consistency_tests.default_value_doc)
352 uf.desc.append(Relax_fit.set_doc)
353 uf.desc.append(Relax_fit.return_data_name_doc)
354 uf.desc.append(Relax_fit.default_value_doc)
355 uf.desc.append(N_state_model.set_doc)
356 uf.desc.append(N_state_model.return_data_name_doc)
357 uf.desc.append(N_state_model.default_value_doc)
358
359 uf.desc.append(Desc_container("Prompt examples"))
360 uf.desc[-1].add_paragraph("To set the parameter values for the current data pipe to the default values, for all spins, type:")
361 uf.desc[-1].add_prompt("relax> value.set()")
362 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.")
363 uf.desc[-1].add_prompt("relax> value.set([0.97, 2.048*1e-9, 0.149], spin_id=':10')")
364 uf.desc[-1].add_prompt("relax> value.set(val=[0.97, 2.048*1e-9, 0.149], spin_id=':10')")
365 uf.desc[-1].add_paragraph("To set the CSA value of all spins to the default value, type:")
366 uf.desc[-1].add_prompt("relax> value.set(param='csa')")
367 uf.desc[-1].add_paragraph("To set the CSA value of all spins to -172 ppm, type:")
368 uf.desc[-1].add_prompt("relax> value.set(-172 * 1e-6, 'csa')")
369 uf.desc[-1].add_prompt("relax> value.set(val=-172 * 1e-6, param='csa')")
370 uf.desc[-1].add_paragraph("To set the NH bond length of all spins to 1.02 Angstroms, type:")
371 uf.desc[-1].add_prompt("relax> value.set(1.02 * 1e-10, 'r')")
372 uf.desc[-1].add_prompt("relax> value.set(val=1.02 * 1e-10, param='r')")
373 uf.desc[-1].add_paragraph("To set both the bond length and the CSA value to the default values, type:")
374 uf.desc[-1].add_prompt("relax> value.set(param=['r', 'csa'])")
375 uf.desc[-1].add_paragraph("To set both tf and ts to 100 ps, type:")
376 uf.desc[-1].add_prompt("relax> value.set(100e-12, ['tf', 'ts'])")
377 uf.desc[-1].add_prompt("relax> value.set(val=100e-12, param=['tf', 'ts'])")
378 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:")
379 uf.desc[-1].add_prompt("relax> value.set([0.56, 13e-12], ['s2', 'te'], ':126@Ca')")
380 uf.desc[-1].add_prompt("relax> value.set(val=[0.56, 13e-12], param=['s2', 'te'], spin_id=':126@Ca')")
381 uf.desc[-1].add_prompt("relax> value.set(val=[0.56, 13e-12], param=['s2', 'te'], spin_id=':126@Ca')")
382 uf.backend = value.set
383 uf.menu_text = "&set"
384 uf.wizard_height_desc = 480
385 uf.wizard_size = (1000, 750)
386 uf.wizard_image = WIZARD_IMAGE_PATH + 'value' + sep + 'value.png'
387
388
389
390 uf = uf_info.add_uf('value.write')
391 uf.title = "Write spin specific data values to a file."
392 uf.title_short = "Value writing."
393 uf.add_keyarg(
394 name = "param",
395 py_type = "str",
396 desc_short = "parameter",
397 desc = "The parameter.",
398 wiz_element_type = 'combo',
399 wiz_combo_iter = value.get_parameters,
400 wiz_read_only = True
401 )
402 uf.add_keyarg(
403 name = "file",
404 py_type = "str",
405 arg_type = "file sel",
406 desc_short = "file name",
407 desc = "The name of the file.",
408 wiz_filesel_style = FD_SAVE
409 )
410 uf.add_keyarg(
411 name = "dir",
412 py_type = "str",
413 arg_type = "dir",
414 desc_short = "directory name",
415 desc = "The directory name.",
416 can_be_none = True
417 )
418 uf.add_keyarg(
419 name = "bc",
420 default = False,
421 py_type = "bool",
422 desc_short = "back calculated value flag",
423 desc = "A flag which if True will cause the back calculated values to be written to file rather than the actual data."
424 )
425 uf.add_keyarg(
426 name = "force",
427 default = False,
428 py_type = "bool",
429 desc_short = "force flag",
430 desc = "A flag which, if set to True, will cause the file to be overwritten."
431 )
432
433 uf.desc.append(Desc_container())
434 uf.desc[-1].add_paragraph("The values corresponding to the given parameter will be written to file.")
435 uf.desc.append(regexp_doc)
436 uf.desc.append(Model_free.return_data_name_doc)
437 uf.desc.append(Jw_mapping.return_data_name_doc)
438 uf.desc.append(Consistency_tests.return_data_name_doc)
439 uf.desc.append(Noe.return_data_name_doc)
440 uf.desc.append(Relax_fit.return_data_name_doc)
441 uf.desc.append(N_state_model.return_data_name_doc)
442
443 uf.desc.append(Desc_container("Prompt examples"))
444 uf.desc[-1].add_paragraph("To write the CSA values to the file 'csa.txt', type one of:")
445 uf.desc[-1].add_prompt("relax> value.write('csa', 'csa.txt')")
446 uf.desc[-1].add_prompt("relax> value.write(param='csa', file='csa.txt')")
447 uf.desc[-1].add_paragraph("To write the NOE values to the file 'noe', type one of:")
448 uf.desc[-1].add_prompt("relax> value.write('noe', 'noe.out')")
449 uf.desc[-1].add_prompt("relax> value.write(param='noe', file='noe.out')")
450 uf.desc[-1].add_prompt("relax> value.write(param='noe', file='noe.out')")
451 uf.desc[-1].add_prompt("relax> value.write(param='noe', file='noe.out', force=True)")
452 uf.backend = value.write
453 uf.menu_text = "&write"
454 uf.gui_icon = "oxygen.actions.document-save"
455 uf.wizard_height_desc = 400
456 uf.wizard_size = (1000, 750)
457 uf.wizard_image = WIZARD_IMAGE_PATH + 'value' + sep + 'value.png'
458