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 generic_fns import align_tensor, pipes, rdc
35 from graphics import WIZARD_IMAGE_PATH
36 from user_functions.data import Uf_info; uf_info = Uf_info()
37 from user_functions.objects import Desc_container
38
39
40
41 uf_class = uf_info.add_class('rdc')
42 uf_class.title = "Class for handling residual dipolar couplings."
43 uf_class.menu_text = "&rdc"
44 uf_class.gui_icon = "relax.align_tensor"
45
46
47
48 uf = uf_info.add_uf('rdc.back_calc')
49 uf.title = "Back calculate the residual dipolar couplings."
50 uf.title_short = "RDC back calculation."
51 uf.display = True
52 uf.add_keyarg(
53 name = "align_id",
54 py_type = "str",
55 desc_short = "alignment ID string",
56 desc = "The alignment ID string.",
57 wiz_element_type = 'combo',
58 wiz_combo_iter = align_tensor.get_ids,
59 wiz_read_only = True,
60 can_be_none = True
61 )
62
63 uf.desc.append(Desc_container())
64 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.")
65 uf.backend = rdc.back_calc
66 uf.menu_text = "&back_calc"
67 uf.gui_icon = "oxygen.categories.applications-education"
68 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
69 uf.wizard_apply_button = False
70
71
72
73 uf = uf_info.add_uf('rdc.calc_q_factors')
74 uf.title = "Calculate the RDC Q factor for the selected spins."
75 uf.title_short = "RDC Q factor calculation."
76 uf.display = True
77 uf.add_keyarg(
78 name = "spin_id",
79 py_type = "str",
80 desc_short = "spin ID string",
81 desc = "The spin ID string for restricting to subset of all selected spins.",
82 can_be_none = True
83 )
84
85 uf.desc.append(Desc_container())
86 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.")
87
88 uf.desc.append(Desc_container("Prompt examples"))
89 uf.desc[-1].add_paragraph("To calculate the RDC Q factor for only the spins '@H26', '@H27', and '@H28', type one of:")
90 uf.desc[-1].add_prompt("relax> rdc.calc_q_factors('@H26 & @H27 & @H28')")
91 uf.desc[-1].add_prompt("relax> rdc.calc_q_factors(spin_id='@H26 & @H27 & @H28')")
92 uf.backend = rdc.q_factors
93 uf.menu_text = "&calc_q_factors"
94 uf.gui_icon = "oxygen.categories.applications-education"
95 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
96 uf.wizard_apply_button = False
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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_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_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_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.",
303 wiz_element_type = "combo",
304 wiz_combo_choices = ["D", "2D"],
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 two 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_paragraph("Internally, relax uses the D notation. Therefore if set to '2D', the values will be doubled when read in.")
369 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.")
370 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.")
371 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 and name, and spin number and 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 can be used to restrict the reading to certain spin types, for example only 15N spins when only residue information is in the file.")
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.desc[-1].add_paragraph("If the RDCs correspond to the 'N' spin and other spin types such as 1H, 13C, etc. are loaded into relax, then type:")
380 uf.desc[-1].add_prompt("relax> rdc.read('Tb', 'Tb.txt', spin_id='@N')")
381 uf.backend = rdc.read
382 uf.menu_text = "&read"
383 uf.gui_icon = "oxygen.actions.document-open"
384 uf.wizard_height_desc = 300
385 uf.wizard_size = (1000, 750)
386 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
387
388
389
390 uf = uf_info.add_uf('rdc.weight')
391 uf.title = "Set optimisation weights on the RDC data."
392 uf.title_short = "RDC weighting."
393 uf.add_keyarg(
394 name = "align_id",
395 py_type = "str",
396 desc_short = "alignment ID string",
397 desc = "The alignment ID string.",
398 wiz_element_type = 'combo',
399 wiz_combo_iter = align_tensor.get_ids,
400 wiz_read_only = True
401 )
402 uf.add_keyarg(
403 name = "spin_id",
404 py_type = "str",
405 desc_short = "spin ID string",
406 desc = "The spin ID string."
407 )
408 uf.add_keyarg(
409 name = "weight",
410 default = 1.0,
411 py_type = "num",
412 desc_short = "weight",
413 desc = "The weighting value."
414 )
415
416 uf.desc.append(Desc_container())
417 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.")
418 uf.backend = rdc.weight
419 uf.menu_text = "wei&ght"
420 uf.wizard_size = (700, 500)
421 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
422
423
424
425 uf = uf_info.add_uf('rdc.write')
426 uf.title = "Write the RDC data to file."
427 uf.title_short = "RDC data writing."
428 uf.add_keyarg(
429 name = "align_id",
430 py_type = "str",
431 desc_short = "alignment ID string",
432 desc = "The alignment ID string.",
433 wiz_element_type = 'combo',
434 wiz_combo_iter = align_tensor.get_ids,
435 wiz_read_only = True
436 )
437 uf.add_keyarg(
438 name = "file",
439 py_type = "str",
440 arg_type = "file sel",
441 desc_short = "file name",
442 desc = "The name of the file.",
443 wiz_filesel_style = FD_SAVE
444 )
445 uf.add_keyarg(
446 name = "dir",
447 py_type = "str",
448 arg_type = "dir",
449 desc_short = "directory name",
450 desc = "The directory name.",
451 can_be_none = True
452 )
453 uf.add_keyarg(
454 name = "bc",
455 default = False,
456 py_type = "bool",
457 desc_short = "back-calculation flag",
458 desc = "A flag which if set will write out the back-calculated rather than measured RDCs."
459 )
460 uf.add_keyarg(
461 name = "force",
462 default = False,
463 py_type = "bool",
464 desc_short = "force flag",
465 desc = "A flag which if True will cause the file to be overwritten."
466 )
467
468 uf.desc.append(Desc_container())
469 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.")
470 uf.backend = rdc.write
471 uf.menu_text = "&write"
472 uf.gui_icon = "oxygen.actions.document-save"
473 uf.wizard_size = (800, 600)
474 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
475