1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """The rdc user function definitions."""
24
25
26 import dep_check
27 if dep_check.wx_module:
28 from wx import FD_OPEN, FD_SAVE
29 else:
30 FD_OPEN = -1
31 FD_SAVE = -1
32
33
34 from graphics import WIZARD_IMAGE_PATH
35 from pipe_control import align_tensor, pipes, rdc
36 from pipe_control.mol_res_spin import get_spin_ids
37 from user_functions.data import Uf_info; uf_info = Uf_info()
38 from user_functions.objects import Desc_container
39 from user_functions.wildcards import WILDCARD_GRACE_ALL
40
41
42
43 uf_class = uf_info.add_class('rdc')
44 uf_class.title = "Class for handling residual dipolar couplings."
45 uf_class.menu_text = "&rdc"
46 uf_class.gui_icon = "relax.align_tensor"
47
48
49
50 uf = uf_info.add_uf('rdc.back_calc')
51 uf.title = "Back calculate the residual dipolar couplings."
52 uf.title_short = "RDC back calculation."
53 uf.display = True
54 uf.add_keyarg(
55 name = "align_id",
56 py_type = "str",
57 desc_short = "alignment ID string",
58 desc = "The alignment ID string.",
59 wiz_element_type = 'combo',
60 wiz_combo_iter = align_tensor.get_align_ids,
61 wiz_read_only = True,
62 can_be_none = True
63 )
64
65 uf.desc.append(Desc_container())
66 uf.desc[-1].add_paragraph("This will back calculate the residual dipolar couplings (RDCs) if an alignment tensor is present and inter-dipole vectors have been loaded into the relax data store.")
67 uf.backend = rdc.back_calc
68 uf.menu_text = "&back_calc"
69 uf.gui_icon = "oxygen.categories.applications-education"
70 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
71 uf.wizard_apply_button = False
72
73
74
75 uf = uf_info.add_uf('rdc.calc_q_factors')
76 uf.title = "Calculate the RDC Q factor for the selected spins."
77 uf.title_short = "RDC Q factor calculation."
78 uf.display = True
79 uf.add_keyarg(
80 name = "spin_id",
81 py_type = "str",
82 desc_short = "spin ID string",
83 desc = "The spin ID string for restricting to subset of all selected spins.",
84 can_be_none = True
85 )
86 uf.add_keyarg(
87 name = "verbosity",
88 default = 1,
89 py_type = "int",
90 desc_short = "verbosity level",
91 desc = "The amount of information to print out. Set to zero to silence the user function, or one to see all messages."
92 )
93
94 uf.desc.append(Desc_container())
95 uf.desc[-1].add_paragraph("For this to work, the back-calculated RDC data must first be generated by the analysis specific code. Otherwise a warning will be given.")
96
97 uf.desc.append(Desc_container("Prompt examples"))
98 uf.desc[-1].add_paragraph("To calculate the RDC Q factor for only the spins '@H26', '@H27', and '@H28', type one of:")
99 uf.desc[-1].add_prompt("relax> rdc.calc_q_factors('@H26 & @H27 & @H28')")
100 uf.desc[-1].add_prompt("relax> rdc.calc_q_factors(spin_id='@H26 & @H27 & @H28')")
101 uf.backend = rdc.q_factors
102 uf.menu_text = "&calc_q_factors"
103 uf.gui_icon = "oxygen.categories.applications-education"
104 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
105 uf.wizard_apply_button = False
106
107
108
109 uf = uf_info.add_uf('rdc.copy')
110 uf.title = "Copy RDC data from one data pipe to another."
111 uf.title_short = "RDC copying."
112 uf.add_keyarg(
113 name = "pipe_from",
114 py_type = "str",
115 desc_short = "source pipe",
116 desc = "The name of the pipe to copy the RDC data from.",
117 wiz_element_type = 'combo',
118 wiz_combo_iter = pipes.pipe_names,
119 can_be_none = True
120 )
121 uf.add_keyarg(
122 name = "pipe_to",
123 py_type = "str",
124 desc_short = "destination pipe",
125 desc = "The name of the pipe to copy the RDC data to.",
126 wiz_element_type = 'combo',
127 wiz_combo_iter = pipes.pipe_names,
128 can_be_none = True
129 )
130 uf.add_keyarg(
131 name = "align_id",
132 py_type = "str",
133 desc_short = "alignment ID string",
134 desc = "The alignment ID string.",
135 wiz_element_type = 'combo',
136 wiz_combo_iter = align_tensor.get_align_ids,
137 wiz_read_only = True,
138 can_be_none = True
139 )
140 uf.add_keyarg(
141 name = "back_calc",
142 default = True,
143 py_type = "bool",
144 desc_short = "back-calculated data flag",
145 desc = "A flag which if True will cause any back-calculated RDCs present to also be copied with the real values and errors."
146 )
147
148 uf.desc.append(Desc_container())
149 uf.desc[-1].add_paragraph("This function will copy RDC data from 'pipe_from' to 'pipe_to'. If align_id is not given then all RDC data will be copied, otherwise only a specific data set will be.")
150
151 uf.desc.append(Desc_container("Prompt examples"))
152 uf.desc[-1].add_paragraph("To copy all RDC data from pipe 'm1' to pipe 'm9', type one of:")
153 uf.desc[-1].add_prompt("relax> rdc.copy('m1', 'm9')")
154 uf.desc[-1].add_prompt("relax> rdc.copy(pipe_from='m1', pipe_to='m9')")
155 uf.desc[-1].add_prompt("relax> rdc.copy('m1', 'm9', None)")
156 uf.desc[-1].add_prompt("relax> rdc.copy(pipe_from='m1', pipe_to='m9', align_id=None)")
157 uf.desc[-1].add_paragraph("To copy only the 'Th' RDC data from 'm3' to 'm6', type one of:")
158 uf.desc[-1].add_prompt("relax> rdc.copy('m3', 'm6', 'Th')")
159 uf.desc[-1].add_prompt("relax> rdc.copy(pipe_from='m3', pipe_to='m6', align_id='Th')")
160 uf.backend = rdc.copy
161 uf.menu_text = "cop&y"
162 uf.gui_icon = "oxygen.actions.list-add"
163 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
164
165
166
167 uf = uf_info.add_uf('rdc.corr_plot')
168 uf.title = "Generate a correlation plot of the measured vs. the back-calculated RDCs."
169 uf.title_short = "Correlation plot generation."
170 uf.add_keyarg(
171 name = "format",
172 default = "grace",
173 py_type = "str",
174 desc_short = "format",
175 desc = "The format of the plot data.",
176 wiz_element_type = "combo",
177 wiz_combo_choices = ["grace"],
178 wiz_read_only = True,
179 can_be_none = True
180 )
181 uf.add_keyarg(
182 name = "title",
183 py_type = "str",
184 desc_short = "alternative plot title",
185 desc = "The title for the plot, overriding the default.",
186 can_be_none = True
187 )
188 uf.add_keyarg(
189 name = "subtitle",
190 py_type = "str",
191 desc_short = "alternative plot subtitle",
192 desc = "The subtitle for the plot, overriding the default.",
193 can_be_none = True
194 )
195 uf.add_keyarg(
196 name = "file",
197 default = "rdc_corr_plot.agr",
198 py_type = "str",
199 arg_type = "file sel",
200 desc_short = "Grace file name",
201 desc = "The name of the Grace file to create.",
202 wiz_filesel_wildcard = WILDCARD_GRACE_ALL,
203 wiz_filesel_style = FD_SAVE
204 )
205 uf.add_keyarg(
206 name = "dir",
207 py_type = "str",
208 arg_type = "dir",
209 desc_short = "directory name",
210 desc = "The directory name.",
211 can_be_none = True
212 )
213 uf.add_keyarg(
214 name = "force",
215 default = False,
216 py_type = "bool",
217 desc_short = "force flag",
218 desc = "A flag which if True will cause the file to be overwritten."
219 )
220
221 uf.desc.append(Desc_container())
222 uf.desc[-1].add_paragraph("Two formats are currently supported. If format is set to 'grace', then a Grace plot file will be created. If the format is not set then a plain text list of the measured and back-calculated data will be created.")
223
224 uf.desc.append(Desc_container("Prompt examples"))
225 uf.desc[-1].add_paragraph("To create a Grace plot of the data, type:")
226 uf.desc[-1].add_prompt("relax> rdc.corr_plot()")
227 uf.desc[-1].add_paragraph("To create a plain text list of the measured and back-calculated data, type one of:")
228 uf.desc[-1].add_prompt("relax> rdc.corr_plot(None)")
229 uf.desc[-1].add_prompt("relax> rdc.corr_plot(format=None)")
230 uf.backend = rdc.corr_plot
231 uf.menu_text = "corr_&plot"
232 uf.gui_icon = "relax.grace_icon"
233 uf.wizard_size = (900, 600)
234 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
235 uf.wizard_apply_button = False
236
237
238
239 uf = uf_info.add_uf('rdc.delete')
240 uf.title = "Delete the RDC data corresponding to the alignment ID."
241 uf.title_short = "RDC deletion."
242 uf.add_keyarg(
243 name = "align_id",
244 py_type = "str",
245 desc_short = "alignment ID string",
246 desc = "The alignment ID string of the data to delete.",
247 wiz_element_type = 'combo',
248 wiz_combo_iter = align_tensor.get_align_ids,
249 wiz_read_only = True,
250 can_be_none = True
251 )
252
253 uf.desc.append(Desc_container())
254 uf.desc[-1].add_paragraph("This will delete all RDC data associated with the alignment ID in the current data pipe.")
255
256 uf.desc.append(Desc_container("Prompt examples"))
257 uf.desc[-1].add_paragraph("To delete the RDC data corresponding to align_id='PH_gel', type:")
258 uf.desc[-1].add_prompt("relax> rdc.delete('PH_gel')")
259 uf.backend = rdc.delete
260 uf.menu_text = "&delete"
261 uf.gui_icon = "oxygen.actions.list-remove"
262 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
263
264
265
266 uf = uf_info.add_uf('rdc.display')
267 uf.title = "Display the RDC data corresponding to the alignment ID."
268 uf.title_short = "RDC data display."
269 uf.display = True
270 uf.add_keyarg(
271 name = "align_id",
272 py_type = "str",
273 desc_short = "alignment ID string",
274 desc = "The alignment ID string.",
275 wiz_element_type = 'combo',
276 wiz_combo_iter = align_tensor.get_align_ids,
277 wiz_read_only = True
278 )
279 uf.add_keyarg(
280 name = "bc",
281 default = False,
282 py_type = "bool",
283 desc_short = "back-calculation flag",
284 desc = "A flag which if set will display the back-calculated rather than measured RDCs."
285 )
286
287 uf.desc.append(Desc_container())
288 uf.desc[-1].add_paragraph("This will display all of the RDC data associated with the alignment ID in the current data pipe.")
289
290 uf.desc.append(Desc_container("Prompt examples"))
291 uf.desc[-1].add_paragraph("To display the 'phage' RDC data, type:")
292 uf.desc[-1].add_prompt("relax> rdc.display('phage')")
293 uf.backend = rdc.display
294 uf.menu_text = "di&splay"
295 uf.gui_icon = "oxygen.actions.document-preview"
296 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
297
298
299
300 uf = uf_info.add_uf('rdc.read')
301 uf.title = "Read the RDC data from file."
302 uf.title_short = "RDC data reading."
303 uf.add_keyarg(
304 name = "align_id",
305 py_type = "str",
306 desc_short = "alignment ID string",
307 desc = "The alignment ID string.",
308 wiz_element_type = 'combo',
309 wiz_combo_iter = align_tensor.get_align_ids
310 )
311 uf.add_keyarg(
312 name = "file",
313 py_type = "str",
314 arg_type = "file sel",
315 desc_short = "file name",
316 desc = "The name of the file containing the RDC data.",
317 wiz_filesel_style = FD_OPEN
318 )
319 uf.add_keyarg(
320 name = "dir",
321 py_type = "str",
322 arg_type = "dir",
323 desc_short = "directory name",
324 desc = "The directory where the file is located.",
325 can_be_none = True
326 )
327 uf.add_keyarg(
328 name = "data_type",
329 default = "D",
330 py_type = "str",
331 desc_short = "data type",
332 desc = "Specify if the RDC data is in the D or 2D format, or the T = J + D format.",
333 wiz_element_type = "combo",
334 wiz_combo_choices = ["D", "2D", "T"],
335 wiz_read_only = True
336 )
337 uf.add_keyarg(
338 name = "spin_id1_col",
339 default = 1,
340 py_type = "int",
341 min = 1,
342 desc_short = "first spin ID column",
343 desc = "The spin ID string column for the first spin."
344 )
345 uf.add_keyarg(
346 name = "spin_id2_col",
347 default = 2,
348 py_type = "int",
349 min = 1,
350 desc_short = "second spin ID column",
351 desc = "The spin ID string column for the second spin."
352 )
353 uf.add_keyarg(
354 name = "data_col",
355 py_type = "int",
356 desc_short = "data column",
357 desc = "The RDC data column.",
358 can_be_none = True
359 )
360 uf.add_keyarg(
361 name = "error_col",
362 py_type = "int",
363 desc_short = "error column",
364 desc = "The experimental error column.",
365 can_be_none = True
366 )
367 uf.add_keyarg(
368 name = "sep",
369 py_type = "str",
370 desc_short = "column separator",
371 desc = "The column separator (the default is white space).",
372 wiz_element_type = "combo",
373 wiz_combo_choices = ["white space", ",", ";", ":"],
374 wiz_combo_data = [None, ",", ";", ":"],
375 wiz_read_only = False,
376 can_be_none = True
377 )
378 uf.add_keyarg(
379 name = "neg_g_corr",
380 default = False,
381 py_type = "bool",
382 desc_short = "negative gyromagnetic ratio correction",
383 desc = "A flag which is used to correct for the negative gyromagnetic ratio of 15N. If set to True, all RDC values will be inverted prior to being stored in the relax data store."
384 )
385 uf.add_keyarg(
386 name = "absolute",
387 default = False,
388 py_type = "bool",
389 desc_short = "absolute RDCs",
390 desc = "A flag which indicates that the loaded RDCs are are signless."
391 )
392
393 uf.desc.append(Desc_container())
394 uf.desc[-1].add_paragraph("This will read RDC data from a file and associate it with an alignment ID, either a new ID or a preexisting one with no RDC data.")
395 uf.desc[-1].add_paragraph("The data type is used to specify how the RDC is defined. It can be set to a number of values:")
396 uf.desc[-1].add_list_element("'D' means that the splitting in the aligned sample was taken as J + D.")
397 uf.desc[-1].add_list_element("'2D' means that the splitting in the aligned sample was assumed to be J + 2D.")
398 uf.desc[-1].add_list_element("'T' means that the file contains T = J + D values.")
399 uf.desc[-1].add_paragraph("Internally, relax uses the D notation. Therefore if set to '2D', the values will be doubled when read in. If the 'T' data type is specified, then J couplings must be present for this data to be of any use.")
400 uf.desc[-1].add_paragraph("If the negative gyromagnetic ratio correction flag is set, a sign inversion will be applied to all RDC values to be loaded. This is sometimes needed for 15N if the data is not compensated for the negative gyromagnetic ratio.")
401 uf.desc[-1].add_paragraph("The absolute RDCs flag is used for RDCs in which the sign is unknown. All absolute RDCs loaded will be converted to positive values.")
402
403 uf.desc.append(Desc_container("Prompt examples"))
404 uf.desc[-1].add_paragraph("The following commands will read the RDC data out of the file 'Tb.txt' where the columns are separated by the symbol ',', and store the RDCs under the ID 'Tb':")
405 uf.desc[-1].add_prompt("relax> rdc.read('Tb', 'Tb.txt', sep=',')")
406 uf.desc[-1].add_paragraph("If the individual spin RDC errors are located in the file 'rdc_err.txt' in column number 5, then to read these values into relax, assuming J + D was measured, type one of:")
407 uf.desc[-1].add_prompt("relax> rdc.read('phage', 'rdc_err.txt', data_type='D', error_col=5)")
408 uf.desc[-1].add_prompt("relax> rdc.read(align_id='phage', file='rdc_err.txt', data_type='D', error_col=5)")
409 uf.backend = rdc.read
410 uf.menu_text = "&read"
411 uf.gui_icon = "oxygen.actions.document-open"
412 uf.wizard_height_desc = 300
413 uf.wizard_size = (1000, 750)
414 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
415
416
417
418 uf = uf_info.add_uf('rdc.set_errors')
419 uf.title = "Set the errors for the RDCs."
420 uf.title_short = "RDC error setting."
421 uf.add_keyarg(
422 name = "align_id",
423 py_type = "str",
424 desc_short = "alignment ID string",
425 desc = "The optional alignment ID string.",
426 wiz_element_type = 'combo',
427 wiz_combo_iter = align_tensor.get_align_ids,
428 wiz_read_only = True,
429 can_be_none = True
430 )
431 uf.add_keyarg(
432 name = "spin_id1",
433 py_type = "str",
434 arg_type = "spin ID",
435 desc_short = "first spin ID string",
436 desc = "The optional spin ID string of the first spin.",
437 wiz_combo_iter = get_spin_ids,
438 can_be_none = True
439 )
440 uf.add_keyarg(
441 name = "spin_id2",
442 py_type = "str",
443 arg_type = "spin ID",
444 desc_short = "second spin ID string",
445 desc = "The optional spin ID string of the second spin.",
446 wiz_combo_iter = get_spin_ids,
447 can_be_none = True
448 )
449 uf.add_keyarg(
450 name = "sd",
451 default = 1.0,
452 py_type = "num",
453 desc_short = "RDC error (Hz)",
454 desc = "The RDC standard deviation value in Hertz."
455 )
456
457 uf.desc.append(Desc_container())
458 uf.desc[-1].add_paragraph("If the RDC errors have not already been read from a RDC data file or if they need to be changed, then the errors can be set via this user function.")
459 uf.backend = rdc.set_errors
460 uf.menu_text = "&set_errors"
461 uf.gui_icon = "oxygen.actions.edit-rename"
462 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
463
464
465
466 uf = uf_info.add_uf('rdc.weight')
467 uf.title = "Set optimisation weights on the RDC data."
468 uf.title_short = "RDC weighting."
469 uf.add_keyarg(
470 name = "align_id",
471 py_type = "str",
472 desc_short = "alignment ID string",
473 desc = "The alignment ID string.",
474 wiz_element_type = 'combo',
475 wiz_combo_iter = align_tensor.get_align_ids,
476 wiz_read_only = True
477 )
478 uf.add_keyarg(
479 name = "spin_id",
480 py_type = "str",
481 desc_short = "spin ID string",
482 desc = "The spin ID string.",
483 can_be_none = True
484 )
485 uf.add_keyarg(
486 name = "weight",
487 default = 1.0,
488 py_type = "num",
489 desc_short = "weight",
490 desc = "The weighting value."
491 )
492
493 uf.desc.append(Desc_container())
494 uf.desc[-1].add_paragraph("This can be used to force the RDC to contribute more or less to the chi-squared optimisation statistic. The higher the value, the more importance the RDC will have.")
495 uf.backend = rdc.weight
496 uf.menu_text = "wei&ght"
497 uf.wizard_size = (700, 500)
498 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
499
500
501
502 uf = uf_info.add_uf('rdc.write')
503 uf.title = "Write the RDC data to file."
504 uf.title_short = "RDC data writing."
505 uf.add_keyarg(
506 name = "align_id",
507 py_type = "str",
508 desc_short = "alignment ID string",
509 desc = "The alignment ID string.",
510 wiz_element_type = 'combo',
511 wiz_combo_iter = align_tensor.get_align_ids,
512 wiz_read_only = True
513 )
514 uf.add_keyarg(
515 name = "file",
516 py_type = "str",
517 arg_type = "file sel",
518 desc_short = "file name",
519 desc = "The name of the file.",
520 wiz_filesel_style = FD_SAVE
521 )
522 uf.add_keyarg(
523 name = "dir",
524 py_type = "str",
525 arg_type = "dir",
526 desc_short = "directory name",
527 desc = "The directory name.",
528 can_be_none = True
529 )
530 uf.add_keyarg(
531 name = "bc",
532 default = False,
533 py_type = "bool",
534 desc_short = "back-calculation flag",
535 desc = "A flag which if set will write out the back-calculated rather than measured RDCs."
536 )
537 uf.add_keyarg(
538 name = "force",
539 default = False,
540 py_type = "bool",
541 desc_short = "force flag",
542 desc = "A flag which if True will cause the file to be overwritten."
543 )
544
545 uf.desc.append(Desc_container())
546 uf.desc[-1].add_paragraph("If no directory name is given, the file will be placed in the current working directory. The alignment ID is required for selecting which RDC data set will be written to file.")
547 uf.backend = rdc.write
548 uf.menu_text = "&write"
549 uf.gui_icon = "oxygen.actions.document-save"
550 uf.wizard_size = (800, 600)
551 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
552