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
40
41
42 uf_class = uf_info.add_class('rdc')
43 uf_class.title = "Class for handling residual dipolar couplings."
44 uf_class.menu_text = "&rdc"
45 uf_class.gui_icon = "relax.align_tensor"
46
47
48
49 uf = uf_info.add_uf('rdc.back_calc')
50 uf.title = "Back calculate the residual dipolar couplings."
51 uf.title_short = "RDC back calculation."
52 uf.display = True
53 uf.add_keyarg(
54 name = "align_id",
55 py_type = "str",
56 desc_short = "alignment ID string",
57 desc = "The alignment ID string.",
58 wiz_element_type = 'combo',
59 wiz_combo_iter = align_tensor.get_align_ids,
60 wiz_read_only = True,
61 can_be_none = True
62 )
63
64 uf.desc.append(Desc_container())
65 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.")
66 uf.backend = rdc.back_calc
67 uf.menu_text = "&back_calc"
68 uf.gui_icon = "oxygen.categories.applications-education"
69 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
70 uf.wizard_apply_button = False
71
72
73
74 uf = uf_info.add_uf('rdc.calc_q_factors')
75 uf.title = "Calculate the RDC Q factor for the selected spins."
76 uf.title_short = "RDC Q factor calculation."
77 uf.display = True
78 uf.add_keyarg(
79 name = "spin_id",
80 py_type = "str",
81 desc_short = "spin ID string",
82 desc = "The spin ID string for restricting to subset of all selected spins.",
83 can_be_none = True
84 )
85
86 uf.desc.append(Desc_container())
87 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.")
88
89 uf.desc.append(Desc_container("Prompt examples"))
90 uf.desc[-1].add_paragraph("To calculate the RDC Q factor for only the spins '@H26', '@H27', and '@H28', type one of:")
91 uf.desc[-1].add_prompt("relax> rdc.calc_q_factors('@H26 & @H27 & @H28')")
92 uf.desc[-1].add_prompt("relax> rdc.calc_q_factors(spin_id='@H26 & @H27 & @H28')")
93 uf.backend = rdc.q_factors
94 uf.menu_text = "&calc_q_factors"
95 uf.gui_icon = "oxygen.categories.applications-education"
96 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
97 uf.wizard_apply_button = False
98
99
100
101 uf = uf_info.add_uf('rdc.copy')
102 uf.title = "Copy RDC data from one data pipe to another."
103 uf.title_short = "RDC copying."
104 uf.add_keyarg(
105 name = "pipe_from",
106 py_type = "str",
107 desc_short = "source pipe",
108 desc = "The name of the pipe to copy the RDC data from.",
109 wiz_element_type = 'combo',
110 wiz_combo_iter = pipes.pipe_names,
111 can_be_none = True
112 )
113 uf.add_keyarg(
114 name = "pipe_to",
115 py_type = "str",
116 desc_short = "destination pipe",
117 desc = "The name of the pipe to copy the RDC data to.",
118 wiz_element_type = 'combo',
119 wiz_combo_iter = pipes.pipe_names,
120 can_be_none = True
121 )
122 uf.add_keyarg(
123 name = "align_id",
124 py_type = "str",
125 desc_short = "alignment ID string",
126 desc = "The alignment ID string.",
127 wiz_element_type = 'combo',
128 wiz_combo_iter = align_tensor.get_align_ids,
129 wiz_read_only = True,
130 can_be_none = True
131 )
132
133 uf.desc.append(Desc_container())
134 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.")
135
136 uf.desc.append(Desc_container("Prompt examples"))
137 uf.desc[-1].add_paragraph("To copy all RDC data from pipe 'm1' to pipe 'm9', type one of:")
138 uf.desc[-1].add_prompt("relax> rdc.copy('m1', 'm9')")
139 uf.desc[-1].add_prompt("relax> rdc.copy(pipe_from='m1', pipe_to='m9')")
140 uf.desc[-1].add_prompt("relax> rdc.copy('m1', 'm9', None)")
141 uf.desc[-1].add_prompt("relax> rdc.copy(pipe_from='m1', pipe_to='m9', align_id=None)")
142 uf.desc[-1].add_paragraph("To copy only the 'Th' RDC data from 'm3' to 'm6', type one of:")
143 uf.desc[-1].add_prompt("relax> rdc.copy('m3', 'm6', 'Th')")
144 uf.desc[-1].add_prompt("relax> rdc.copy(pipe_from='m3', pipe_to='m6', align_id='Th')")
145 uf.backend = rdc.copy
146 uf.menu_text = "cop&y"
147 uf.gui_icon = "oxygen.actions.list-add"
148 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
149
150
151
152 uf = uf_info.add_uf('rdc.corr_plot')
153 uf.title = "Generate a correlation plot of the measured vs. the back-calculated RDCs."
154 uf.title_short = "Correlation plot generation."
155 uf.add_keyarg(
156 name = "format",
157 default = "grace",
158 py_type = "str",
159 desc_short = "format",
160 desc = "The format of the plot data.",
161 wiz_element_type = "combo",
162 wiz_combo_choices = ["grace"],
163 wiz_read_only = True,
164 can_be_none = True
165 )
166 uf.add_keyarg(
167 name = "file",
168 default = "rdc_corr_plot.agr",
169 py_type = "str",
170 arg_type = "file sel",
171 desc_short = "Grace file name",
172 desc = "The name of the Grace file to create.",
173 wiz_filesel_wildcard = "Grace files (*.agr)|*.agr;*.AGR",
174 wiz_filesel_style = FD_SAVE
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 name.",
182 can_be_none = True
183 )
184 uf.add_keyarg(
185 name = "force",
186 default = False,
187 py_type = "bool",
188 desc_short = "force flag",
189 desc = "A flag which if True will cause the file to be overwritten."
190 )
191
192 uf.desc.append(Desc_container())
193 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.")
194
195 uf.desc.append(Desc_container("Prompt examples"))
196 uf.desc[-1].add_paragraph("To create a Grace plot of the data, type:")
197 uf.desc[-1].add_prompt("relax> rdc.corr_plot()")
198 uf.desc[-1].add_paragraph("To create a plain text list of the measured and back-calculated data, type one of:")
199 uf.desc[-1].add_prompt("relax> rdc.corr_plot(None)")
200 uf.desc[-1].add_prompt("relax> rdc.corr_plot(format=None)")
201 uf.backend = rdc.corr_plot
202 uf.menu_text = "corr_&plot"
203 uf.wizard_size = (800, 500)
204 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
205 uf.wizard_apply_button = False
206
207
208
209 uf = uf_info.add_uf('rdc.delete')
210 uf.title = "Delete the RDC data corresponding to the alignment ID."
211 uf.title_short = "RDC deletion."
212 uf.add_keyarg(
213 name = "align_id",
214 py_type = "str",
215 desc_short = "alignment ID string",
216 desc = "The alignment ID string of the data to delete.",
217 wiz_element_type = 'combo',
218 wiz_combo_iter = align_tensor.get_align_ids,
219 wiz_read_only = True,
220 can_be_none = True
221 )
222
223 uf.desc.append(Desc_container())
224 uf.desc[-1].add_paragraph("This will delete all RDC data associated with the alignment ID in the current data pipe.")
225
226 uf.desc.append(Desc_container("Prompt examples"))
227 uf.desc[-1].add_paragraph("To delete the RDC data corresponding to align_id='PH_gel', type:")
228 uf.desc[-1].add_prompt("relax> rdc.delete('PH_gel')")
229 uf.backend = rdc.delete
230 uf.menu_text = "&delete"
231 uf.gui_icon = "oxygen.actions.list-remove"
232 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
233
234
235
236 uf = uf_info.add_uf('rdc.display')
237 uf.title = "Display the RDC data corresponding to the alignment ID."
238 uf.title_short = "RDC data display."
239 uf.display = True
240 uf.add_keyarg(
241 name = "align_id",
242 py_type = "str",
243 desc_short = "alignment ID string",
244 desc = "The alignment ID string.",
245 wiz_element_type = 'combo',
246 wiz_combo_iter = align_tensor.get_align_ids,
247 wiz_read_only = True
248 )
249 uf.add_keyarg(
250 name = "bc",
251 default = False,
252 py_type = "bool",
253 desc_short = "back-calculation flag",
254 desc = "A flag which if set will display the back-calculated rather than measured RDCs."
255 )
256
257 uf.desc.append(Desc_container())
258 uf.desc[-1].add_paragraph("This will display all of the RDC data associated with the alignment ID in the current data pipe.")
259
260 uf.desc.append(Desc_container("Prompt examples"))
261 uf.desc[-1].add_paragraph("To display the 'phage' RDC data, type:")
262 uf.desc[-1].add_prompt("relax> rdc.display('phage')")
263 uf.backend = rdc.display
264 uf.menu_text = "di&splay"
265 uf.gui_icon = "oxygen.actions.document-preview"
266 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
267
268
269
270 uf = uf_info.add_uf('rdc.read')
271 uf.title = "Read the RDC data from file."
272 uf.title_short = "RDC data reading."
273 uf.add_keyarg(
274 name = "align_id",
275 py_type = "str",
276 desc_short = "alignment ID string",
277 desc = "The alignment ID string.",
278 wiz_element_type = 'combo',
279 wiz_combo_iter = align_tensor.get_align_ids
280 )
281 uf.add_keyarg(
282 name = "file",
283 py_type = "str",
284 arg_type = "file sel",
285 desc_short = "file name",
286 desc = "The name of the file containing the RDC data.",
287 wiz_filesel_style = FD_OPEN
288 )
289 uf.add_keyarg(
290 name = "dir",
291 py_type = "str",
292 arg_type = "dir",
293 desc_short = "directory name",
294 desc = "The directory where the file is located.",
295 can_be_none = True
296 )
297 uf.add_keyarg(
298 name = "data_type",
299 default = "D",
300 py_type = "str",
301 desc_short = "data type",
302 desc = "Specify if the RDC data is in the D or 2D format, or the T = J + D format.",
303 wiz_element_type = "combo",
304 wiz_combo_choices = ["D", "2D", "T"],
305 wiz_read_only = True
306 )
307 uf.add_keyarg(
308 name = "spin_id1_col",
309 default = 1,
310 py_type = "int",
311 min = 1,
312 desc_short = "first spin ID column",
313 desc = "The spin ID string column for the first spin."
314 )
315 uf.add_keyarg(
316 name = "spin_id2_col",
317 default = 2,
318 py_type = "int",
319 min = 1,
320 desc_short = "second spin ID column",
321 desc = "The spin ID string column for the second spin."
322 )
323 uf.add_keyarg(
324 name = "data_col",
325 py_type = "int",
326 desc_short = "data column",
327 desc = "The RDC data column.",
328 can_be_none = True
329 )
330 uf.add_keyarg(
331 name = "error_col",
332 py_type = "int",
333 desc_short = "error column",
334 desc = "The experimental error column.",
335 can_be_none = True
336 )
337 uf.add_keyarg(
338 name = "sep",
339 py_type = "str",
340 desc_short = "column separator",
341 desc = "The column separator (the default is white space).",
342 wiz_element_type = "combo",
343 wiz_combo_choices = ["white space", ",", ";", ":"],
344 wiz_combo_data = [None, ",", ";", ":"],
345 wiz_read_only = False,
346 can_be_none = True
347 )
348 uf.add_keyarg(
349 name = "neg_g_corr",
350 default = False,
351 py_type = "bool",
352 desc_short = "negative gyromagnetic ratio correction",
353 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."
354 )
355 uf.add_keyarg(
356 name = "absolute",
357 default = False,
358 py_type = "bool",
359 desc_short = "absolute RDCs",
360 desc = "A flag which indicates that the loaded RDCs are are signless."
361 )
362
363 uf.desc.append(Desc_container())
364 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.")
365 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:")
366 uf.desc[-1].add_list_element("'D' means that the splitting in the aligned sample was taken as J + D.")
367 uf.desc[-1].add_list_element("'2D' means that the splitting in the aligned sample was assumed to be J + 2D.")
368 uf.desc[-1].add_list_element("'T' means that the file contains T = J + D values.")
369 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.")
370 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.")
371 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.")
372
373 uf.desc.append(Desc_container("Prompt examples"))
374 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':")
375 uf.desc[-1].add_prompt("relax> rdc.read('Tb', 'Tb.txt', sep=',')")
376 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:")
377 uf.desc[-1].add_prompt("relax> rdc.read('phage', 'rdc_err.txt', data_type='D', error_col=5)")
378 uf.desc[-1].add_prompt("relax> rdc.read(align_id='phage', file='rdc_err.txt', data_type='D', error_col=5)")
379 uf.backend = rdc.read
380 uf.menu_text = "&read"
381 uf.gui_icon = "oxygen.actions.document-open"
382 uf.wizard_height_desc = 300
383 uf.wizard_size = (1000, 750)
384 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
385
386
387
388 uf = uf_info.add_uf('rdc.set_errors')
389 uf.title = "Set the errors for the RDCs."
390 uf.title_short = "RDC error setting."
391 uf.add_keyarg(
392 name = "align_id",
393 py_type = "str",
394 desc_short = "alignment ID string",
395 desc = "The optional alignment ID string.",
396 wiz_element_type = 'combo',
397 wiz_combo_iter = align_tensor.get_align_ids,
398 wiz_read_only = True,
399 can_be_none = True
400 )
401 uf.add_keyarg(
402 name = "spin_id1",
403 py_type = "str",
404 arg_type = "spin ID",
405 desc_short = "first spin ID string",
406 desc = "The optional spin ID string of the first spin.",
407 wiz_combo_iter = get_spin_ids,
408 can_be_none = True
409 )
410 uf.add_keyarg(
411 name = "spin_id2",
412 py_type = "str",
413 arg_type = "spin ID",
414 desc_short = "second spin ID string",
415 desc = "The optional spin ID string of the second spin.",
416 wiz_combo_iter = get_spin_ids,
417 can_be_none = True
418 )
419 uf.add_keyarg(
420 name = "sd",
421 default = 1.0,
422 py_type = "num",
423 desc_short = "RDC error (Hz)",
424 desc = "The RDC standard deviation value in Hertz."
425 )
426
427 uf.desc.append(Desc_container())
428 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.")
429 uf.backend = rdc.set_errors
430 uf.menu_text = "&set_errors"
431 uf.gui_icon = "oxygen.actions.edit-rename"
432 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
433
434
435
436 uf = uf_info.add_uf('rdc.weight')
437 uf.title = "Set optimisation weights on the RDC data."
438 uf.title_short = "RDC weighting."
439 uf.add_keyarg(
440 name = "align_id",
441 py_type = "str",
442 desc_short = "alignment ID string",
443 desc = "The alignment ID string.",
444 wiz_element_type = 'combo',
445 wiz_combo_iter = align_tensor.get_align_ids,
446 wiz_read_only = True
447 )
448 uf.add_keyarg(
449 name = "spin_id",
450 py_type = "str",
451 desc_short = "spin ID string",
452 desc = "The spin ID string."
453 )
454 uf.add_keyarg(
455 name = "weight",
456 default = 1.0,
457 py_type = "num",
458 desc_short = "weight",
459 desc = "The weighting value."
460 )
461
462 uf.desc.append(Desc_container())
463 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.")
464 uf.backend = rdc.weight
465 uf.menu_text = "wei&ght"
466 uf.wizard_size = (700, 500)
467 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
468
469
470
471 uf = uf_info.add_uf('rdc.write')
472 uf.title = "Write the RDC data to file."
473 uf.title_short = "RDC data writing."
474 uf.add_keyarg(
475 name = "align_id",
476 py_type = "str",
477 desc_short = "alignment ID string",
478 desc = "The alignment ID string.",
479 wiz_element_type = 'combo',
480 wiz_combo_iter = align_tensor.get_align_ids,
481 wiz_read_only = True
482 )
483 uf.add_keyarg(
484 name = "file",
485 py_type = "str",
486 arg_type = "file sel",
487 desc_short = "file name",
488 desc = "The name of the file.",
489 wiz_filesel_style = FD_SAVE
490 )
491 uf.add_keyarg(
492 name = "dir",
493 py_type = "str",
494 arg_type = "dir",
495 desc_short = "directory name",
496 desc = "The directory name.",
497 can_be_none = True
498 )
499 uf.add_keyarg(
500 name = "bc",
501 default = False,
502 py_type = "bool",
503 desc_short = "back-calculation flag",
504 desc = "A flag which if set will write out the back-calculated rather than measured RDCs."
505 )
506 uf.add_keyarg(
507 name = "force",
508 default = False,
509 py_type = "bool",
510 desc_short = "force flag",
511 desc = "A flag which if True will cause the file to be overwritten."
512 )
513
514 uf.desc.append(Desc_container())
515 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.")
516 uf.backend = rdc.write
517 uf.menu_text = "&write"
518 uf.gui_icon = "oxygen.actions.document-save"
519 uf.wizard_size = (800, 600)
520 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
521