1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """Module containing the 'rdc' user function class."""
25 __docformat__ = 'plaintext'
26
27
28 from base_class import User_fn_class
29 import arg_check
30 from generic_fns import rdc
31 from relax_errors import RelaxError
32
33
34 -class RDC(User_fn_class):
35 """Class for handling residual dipolar coulpings."""
36
38 """Back calculate RDCs.
39
40 Keyword Arguments
41 ~~~~~~~~~~~~~~~~~
42
43 align_id: The alignment ID string.
44 """
45
46
47 if self._exec_info.intro:
48 text = self._exec_info.ps3 + "rdc.back_calc("
49 text = text + "align_id=" + repr(align_id) + ")"
50 print(text)
51
52
53 arg_check.is_str(align_id, 'alignment ID string', can_be_none=True)
54
55
56 rdc.back_calc(align_id=align_id)
57
58
60 """Calculate the RDC Q-factor for the selected spins.
61
62 Keyword Arguments
63 ~~~~~~~~~~~~~~~~~
64
65 spin_id: The spin ID string for restricting to subset of all selected spins.
66
67
68 Description
69 ~~~~~~~~~~~
70
71 For this function to work, the back-calculated RDC data must first be generated by the
72 analysis specific code. Otherwise a warning will be given.
73
74
75 Examples
76 ~~~~~~~~
77
78 To calculate the RDC Q-factor for only the spins '@H26', '@H27', and '@H28', type one of:
79
80 relax> rdc.calc_q_factors('@H26 & @H27 & @H28')
81 relax> rdc.calc_q_factors(spin_id='@H26 & @H27 & @H28')
82 """
83
84
85 if self._exec_info.intro:
86 text = self._exec_info.ps3 + "rdc.calc_q_factors("
87 text = text + "spin_id=" + repr(spin_id) + ")"
88 print(text)
89
90
91 arg_check.is_str(spin_id, 'spin ID string', can_be_none=True)
92
93
94 rdc.q_factors(spin_id=spin_id)
95
96
97 - def copy(self, pipe_from=None, pipe_to=None, align_id=None):
98 """Copy RDC data from pipe_from to pipe_to.
99
100 Keyword Arguments
101 ~~~~~~~~~~~~~~~~~
102
103 pipe_from: The name of the pipe to copy the RDC data from.
104
105 pipe_to: The name of the pipe to copy the RDC data to.
106
107 align_id: The alignment ID string.
108
109
110 Description
111 ~~~~~~~~~~~
112
113 This function will copy RDC data from 'pipe_from' to 'pipe_to'. If align_id is not given
114 then all RDC data will be copied, otherwise only a specific data set will be.
115
116
117 Examples
118 ~~~~~~~~
119
120 To copy all RDC data from pipe 'm1' to pipe 'm9', type one of:
121
122 relax> rdc.copy('m1', 'm9')
123 relax> rdc.copy(pipe_from='m1', pipe_to='m9')
124 relax> rdc.copy('m1', 'm9', None)
125 relax> rdc.copy(pipe_from='m1', pipe_to='m9', align_id=None)
126
127 To copy only the 'Th' RDC data from 'm3' to 'm6', type one of:
128
129 relax> rdc.copy('m3', 'm6', 'Th')
130 relax> rdc.copy(pipe_from='m3', pipe_to='m6', align_id='Th')
131 """
132
133
134 if self._exec_info.intro:
135 text = self._exec_info.ps3 + "rdc.copy("
136 text = text + "pipe_from=" + repr(pipe_from)
137 text = text + ", pipe_to=" + repr(pipe_to)
138 text = text + ", align_id=" + repr(align_id) + ")"
139 print(text)
140
141
142 arg_check.is_str(pipe_from, 'pipe from', can_be_none=True)
143 arg_check.is_str(pipe_to, 'pipe to', can_be_none=True)
144 arg_check.is_str(align_id, 'alignment ID string', can_be_none=True)
145
146
147 if pipe_from == None and pipe_to == None:
148 raise RelaxError("The pipe_from and pipe_to arguments cannot both be set to None.")
149
150
151 rdc.copy(pipe_from=pipe_from, pipe_to=pipe_to, align_id=align_id)
152
153
154 - def corr_plot(self, format='grace', file='rdc_corr_plot.agr', dir=None, force=False):
155 """Generate a correlation plot of the measured vs. the back-calculated RDCs.
156
157 Keyword Arguments
158 ~~~~~~~~~~~~~~~~~
159
160 format: The format of the plot data.
161
162 file: The name of the file.
163
164 dir: The directory name.
165
166 force: A flag which if True will cause the file to be overwritten.
167
168
169 Description
170 ~~~~~~~~~~~
171
172 Two formats are currently supported. If format is set to 'grace', then a Grace plot file
173 will be created. If the format arg is set to None, then a plain text list of the measured
174 and back-calculated data will be created.
175
176
177 Examples
178 ~~~~~~~~
179
180 To create a Grace plot of the data, type:
181
182 relax> rdc.corr_plot()
183
184
185 To create a plain text list of the measured and back-calculated data, type one of:
186
187 relax> rdc.corr_plot(None)
188 relax> rdc.corr_plot(format=None)
189 """
190
191
192 if self._exec_info.intro:
193 text = self._exec_info.ps3 + "rdc.corr_plot("
194 text = text + "format=" + repr(format)
195 text = text + ", file=" + repr(file)
196 text = text + ", dir=" + repr(dir)
197 text = text + ", force=" + repr(force) + ")"
198 print(text)
199
200
201 arg_check.is_str(format, 'format', can_be_none=True)
202 arg_check.is_str(file, 'file name')
203 arg_check.is_str(dir, 'directory name', can_be_none=True)
204 arg_check.is_bool(force, 'force flag')
205
206
207 rdc.corr_plot(format=format, file=file, dir=dir, force=force)
208
209
210 - def delete(self, align_id=None):
211 """Delete the RDC data corresponding to the alignment ID.
212
213 Keyword Arguments
214 ~~~~~~~~~~~~~~~~~
215
216 align_id: The alignment ID string.
217
218
219 Examples
220 ~~~~~~~~
221
222 To delete the RDC data corresponding to align_id='PH_gel', type:
223
224 relax> rdc.delete('PH_gel')
225 """
226
227
228 if self._exec_info.intro:
229 text = self._exec_info.ps3 + "rdc.delete("
230 text = text + "align_id=" + repr(align_id) + ")"
231 print(text)
232
233
234 arg_check.is_str(align_id, 'alignment ID string', can_be_none=True)
235
236
237 rdc.delete(align_id=align_id)
238
239
240 - def display(self, align_id=None, bc=False):
241 """Display the RDC data corresponding to the alignment ID.
242
243 Keyword Arguments
244 ~~~~~~~~~~~~~~~~~
245
246 align_id: The alignment ID string.
247
248 bc: A flag which if set will display the back-calculated rather than measured RDCs.
249
250
251 Examples
252 ~~~~~~~~
253
254 To display the 'phage' RDC data, type:
255
256 relax> rdc.display('phage')
257 """
258
259
260 if self._exec_info.intro:
261 text = self._exec_info.ps3 + "rdc.display("
262 text = text + "align_id=" + repr(align_id)
263 text = text + ", bc=" + repr(bc) + ")"
264 print(text)
265
266
267 arg_check.is_str(align_id, 'alignment ID string')
268 arg_check.is_bool(bc, 'back-calculation flag')
269
270
271 rdc.display(align_id=align_id, bc=bc)
272
273
274 - def read(self, align_id=None, file=None, dir=None, data_type='D', spin_id_col=None, mol_name_col=None, res_num_col=None, res_name_col=None, spin_num_col=None, spin_name_col=None, data_col=None, error_col=None, sep=None, spin_id=None, neg_g_corr=False):
275 """Read the RDC data from file.
276
277 Keyword Arguments
278 ~~~~~~~~~~~~~~~~~
279
280 align_id: The alignment ID string.
281
282 file: The name of the file containing the RDC data.
283
284 dir: The directory where the file is located.
285
286 data_type: Whether the RDC data is in the D or 2D format.
287
288 spin_id_col: The spin ID string column (an alternative to the mol, res, and spin name and
289 number columns).
290
291 mol_name_col: The molecule name column (alternative to the spin_id_col).
292
293 res_num_col: The residue number column (alternative to the spin_id_col).
294
295 res_name_col: The residue name column (alternative to the spin_id_col).
296
297 spin_num_col: The spin number column (alternative to the spin_id_col).
298
299 spin_name_col: The spin name column (alternative to the spin_id_col).
300
301 data_col: The RDC data column.
302
303 error_col: The experimental error column.
304
305 sep: The column separator (the default is white space).
306
307 spin_id: The spin ID string to restrict the loading of data to certain spin subsets.
308
309 neg_g_corr: A flag which is used to correct for the negative gyromagnetic ratio of 15N.
310
311
312 Description
313 ~~~~~~~~~~~
314
315 The data_type argument is used to specify how the RDC is defined. It is a string which can
316 be set to two values:
317
318 - 'D' means that the splitting in the aligned sample was taken as J + D.
319 - '2D' means that the splitting in the aligned sample was assumed to be J + 2D.
320
321 Internally, relax uses the D notation. Therefore if set to '2D', the values will be doubled
322 when read in.
323
324 If neg_g_corr is set to True, a sign inversion will be applied to all RDC values to be
325 loaded. This is sometimes needed for 15N if the data is not compensated for the negative
326 gyromagnetic ratio.
327
328 The spin system can be identified in the file using two different formats. The first is the
329 spin ID string column which can include the molecule name, the residue name and number, and
330 the spin name and number. Alternatively the mol_name_col, res_num_col, res_name_col,
331 spin_num_col, and/or spin_name_col arguments can be supplied allowing this information to be
332 in separate columns. Note that the numbering of columns starts at one. The spin_id
333 argument can be used to restrict the reading to certain spin types, for example only 15N
334 spins when only residue information is in the file.
335
336
337 Examples
338 ~~~~~~~~
339
340 The following commands will read the RDC data out of the file 'Tb.txt' where the columns are
341 separated by the symbol ',', and store the RDCs under the ID 'Tb':
342
343 relax> rdc.read('Tb', 'Tb.txt', sep=',')
344
345
346 If the individual spin RDC errors are located in the file 'rdc_err.txt' in column number 5,
347 then to read these values into relax, assuming J + D was measured, type one of:
348
349 relax> rdc.read('phage', 'rdc_err.txt', data_type='D', error_col=5)
350 relax> rdc.read(align_id='phage', file='rdc_err.txt', data_type='D', error_col=5)
351
352
353 If the RDCs correspond to the 'N' spin and other spin types such as 1H, 13C, etc. are loaded
354 into relax, then type:
355
356 relax> rdc.read('Tb', 'Tb.txt', spin_id='@N')
357 """
358
359
360 if self._exec_info.intro:
361 text = self._exec_info.ps3 + "rdc.read("
362 text = text + "align_id=" + repr(align_id)
363 text = text + ", file=" + repr(file)
364 text = text + ", dir=" + repr(dir)
365 text = text + ", data_type=" + repr(data_type)
366 text = text + ", spin_id_col=" + repr(spin_id_col)
367 text = text + ", mol_name_col=" + repr(mol_name_col)
368 text = text + ", res_num_col=" + repr(res_num_col)
369 text = text + ", res_name_col=" + repr(res_name_col)
370 text = text + ", spin_num_col=" + repr(spin_num_col)
371 text = text + ", spin_name_col=" + repr(spin_name_col)
372 text = text + ", data_col=" + repr(data_col)
373 text = text + ", error_col=" + repr(error_col)
374 text = text + ", sep=" + repr(sep)
375 text = text + ", spin_id=" + repr(spin_id)
376 text = text + ", neg_g_corr=" + repr(neg_g_corr) + ")"
377 print(text)
378
379
380 arg_check.is_str(align_id, 'alignment ID string')
381 arg_check.is_str(file, 'file name')
382 arg_check.is_str(dir, 'directory name', can_be_none=True)
383 arg_check.is_str(data_type, 'data type')
384 arg_check.is_int(spin_id_col, 'spin ID string column', can_be_none=True)
385 arg_check.is_int(mol_name_col, 'molecule name column', can_be_none=True)
386 arg_check.is_int(res_num_col, 'residue number column', can_be_none=True)
387 arg_check.is_int(res_name_col, 'residue name column', can_be_none=True)
388 arg_check.is_int(spin_num_col, 'spin number column', can_be_none=True)
389 arg_check.is_int(spin_name_col, 'spin name column', can_be_none=True)
390 arg_check.is_int(data_col, 'data column', can_be_none=True)
391 arg_check.is_int(error_col, 'error column', can_be_none=True)
392 arg_check.is_str(sep, 'column separator', can_be_none=True)
393 arg_check.is_str(spin_id, 'spin ID string', can_be_none=True)
394 arg_check.is_bool(neg_g_corr, 'negative gyromagnetic ratio correction')
395
396
397 rdc.read(align_id=align_id, file=file, dir=dir, data_type=data_type, spin_id_col=spin_id_col, mol_name_col=mol_name_col, res_num_col=res_num_col, res_name_col=res_name_col, spin_num_col=spin_num_col, spin_name_col=spin_name_col, data_col=data_col, error_col=error_col, sep=sep, spin_id=spin_id, neg_g_corr=neg_g_corr)
398
399
400 - def weight(self, align_id=None, spin_id=None, weight=1.0):
401 """Set optimisation weights on the RDC data.
402
403 Keyword Arguments
404 ~~~~~~~~~~~~~~~~~
405
406 align_id: The alignment ID string.
407
408 spin_id: The spin ID string.
409
410 weight: The weighting value.
411
412
413 Description
414 ~~~~~~~~~~~
415
416 This function can be used to force the RDC to contribute more or less to the chi-squared
417 optimisation statistic. The higher the value, the more importance the RDC will have.
418 """
419
420
421 if self._exec_info.intro:
422 text = self._exec_info.ps3 + "rdc.weight("
423 text = text + "align_id=" + repr(align_id)
424 text = text + ", spin_id=" + repr(spin_id)
425 text = text + ", weight=" + repr(weight) + ")"
426 print(text)
427
428
429 arg_check.is_str(align_id, 'alignment ID string')
430 arg_check.is_str(spin_id, 'spin ID string', can_be_none=True)
431 arg_check.is_num(weight, 'weight')
432
433
434 rdc.weight(align_id=align_id, spin_id=spin_id, weight=weight)
435
436
437 - def write(self, align_id=None, file=None, dir=None, bc=False, force=False):
438 """Write the RDC data to file.
439
440 Keyword Arguments
441 ~~~~~~~~~~~~~~~~~
442
443 align_id: The alignment ID string.
444
445 file: The name of the file.
446
447 dir: The directory name.
448
449 bc: A flag which if set will write out the back-calculated rather than measured RDCs.
450
451 force: A flag which if True will cause the file to be overwritten.
452
453
454 Description
455 ~~~~~~~~~~~
456
457 If no directory name is given, the file will be placed in the current working directory.
458 The 'align_id' argument are required for selecting which RDC data set will be written to file.
459 """
460
461
462 if self._exec_info.intro:
463 text = self._exec_info.ps3 + "rdc.write("
464 text = text + "align_id=" + repr(align_id)
465 text = text + ", file=" + repr(file)
466 text = text + ", dir=" + repr(dir)
467 text = text + ", bc=" + repr(bc)
468 text = text + ", force=" + repr(force) + ")"
469 print(text)
470
471
472 arg_check.is_str(align_id, 'alignment ID string')
473 arg_check.is_str(file, 'file name')
474 arg_check.is_str(dir, 'directory name', can_be_none=True)
475 arg_check.is_bool(bc, 'back-calculation flag')
476 arg_check.is_bool(force, 'force flag')
477
478
479 rdc.write(align_id=align_id, file=file, dir=dir, bc=bc, force=force)
480