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 'pcs' pseudocontact shift 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 pcs
31 from relax_errors import RelaxError
32
33
34 -class PCS(User_fn_class):
35 """Class for handling pseudo-contact shifts."""
36
38 """Back calculate the pseudo-contact shifts.
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 + "pcs.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')
54
55
56 pcs.back_calc(align_id=align_id)
57
58
60 """Calculate the PCS 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 PCS 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 PCS Q-factor for only the spins '@H26', '@H27', and '@H28', type one of:
79
80 relax> pcs.calc_q_factors('@H26 & @H27 & @H28')
81 relax> pcs.calc_q_factors(spin_id='@H26 & @H27 & @H28')
82 """
83
84
85 if self._exec_info.intro:
86 text = self._exec_info.ps3 + "pcs.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 pcs.q_factors(spin_id=spin_id)
95
96
97 - def copy(self, pipe_from=None, pipe_to=None, align_id=None):
98 """Copy PCS data from pipe_from to pipe_to.
99
100 Keyword Arguments
101 ~~~~~~~~~~~~~~~~~
102
103 pipe_from: The name of the pipe to copy the PCS data from.
104
105 pipe_to: The name of the pipe to copy the PCS data to.
106
107 align_id: The alignment ID string.
108
109
110 Description
111 ~~~~~~~~~~~
112
113 This function will copy PCS data from 'pipe_from' to 'pipe_to'. If align_id is not given
114 then all PCS data will be copied, otherwise only a specific data set will be.
115
116
117 Examples
118 ~~~~~~~~
119
120 To copy all PCS data from pipe 'm1' to pipe 'm9', type one of:
121
122 relax> pcs.copy('m1', 'm9')
123 relax> pcs.copy(pipe_from='m1', pipe_to='m9')
124 relax> pcs.copy('m1', 'm9', None)
125 relax> pcs.copy(pipe_from='m1', pipe_to='m9', align_id=None)
126
127 To copy only the 'Th' PCS data from 'm3' to 'm6', type one of:
128
129 relax> pcs.copy('m3', 'm6', 'Th')
130 relax> pcs.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 + "pcs.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 pcs.copy(pipe_from=pipe_from, pipe_to=pipe_to, align_id=align_id)
152
153
154 - def corr_plot(self, format='grace', file='pcs_corr_plot.agr', dir=None, force=False):
155 """Generate a correlation plot of the measured vs. the back-calculated PCSs.
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> pcs.corr_plot()
183
184
185 To create a plain text list of the measured and back-calculated data, type one of:
186
187 relax> pcs.corr_plot(None)
188 relax> pcs.corr_plot(format=None)
189 """
190
191
192 if self._exec_info.intro:
193 text = self._exec_info.ps3 + "pcs.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 pcs.corr_plot(format=format, file=file, dir=dir, force=force)
208
209
210 - def delete(self, align_id=None):
211 """Delete the PCS 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 PCS data corresponding to align_id='PH_gel', type:
223
224 relax> pcs.delete('PH_gel')
225 """
226
227
228 if self._exec_info.intro:
229 text = self._exec_info.ps3 + "pcs.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 pcs.delete(align_id=align_id)
238
239
240 - def display(self, align_id=None, bc=False):
241 """Display the PCS 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' PCS data, type:
255
256 relax> pcs.display('phage')
257 """
258
259
260 if self._exec_info.intro:
261 text = self._exec_info.ps3 + "pcs.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 pcs.display(align_id=align_id, bc=bc)
272
273
274 - def read(self, align_id=None, file=None, dir=None, 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):
275 """Read the PCS 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 PCS data.
283
284 dir: The directory where the file is located.
285
286 spin_id_col: The spin ID string column (an alternative to the mol, res, and spin name and
287 number columns).
288
289 mol_name_col: The molecule name column (alternative to the spin_id_col).
290
291 res_num_col: The residue number column (alternative to the spin_id_col).
292
293 res_name_col: The residue name column (alternative to the spin_id_col).
294
295 spin_num_col: The spin number column (alternative to the spin_id_col).
296
297 spin_name_col: The spin name column (alternative to the spin_id_col).
298
299 data_col: The PCS data column.
300
301 error_col: The experimental error column.
302
303 sep: The column separator (the default is white space).
304
305 spin_id: The spin ID string to restrict the loading of data to certain spin subsets.
306
307
308 Description
309 ~~~~~~~~~~~
310
311 The spin system can be identified in the file using two different formats. The first is the
312 spin ID string column which can include the molecule name, the residue name and number, and
313 the spin name and number. Alternatively the mol_name_col, res_num_col, res_name_col,
314 spin_num_col, and/or spin_name_col arguments can be supplied allowing this information to be
315 in separate columns. Note that the numbering of columns starts at one. The spin_id
316 argument can be used to restrict the reading to certain spin types, for example only 15N
317 spins when only residue information is in the file.
318
319
320 Examples
321 ~~~~~~~~
322
323 The following commands will read the PCS data out of the file 'Tb.txt' where the columns are
324 separated by the symbol ',', and store the PCSs under the ID 'Tb'.
325
326 relax> pcs.read('Tb', 'Tb.txt', sep=',')
327
328
329 To read the 15N and 1H PCSs from the file 'Eu.txt', where the 15N values are in the 4th
330 column and the 1H in the 9th, type both the following:
331
332 relax> pcs.read('Tb', 'Tb.txt', spin_id='@N', res_num_col=1, data_col=4)
333 relax> pcs.read('Tb', 'Tb.txt', spin_id='@H', res_num_col=1, data_col=9)
334 """
335
336
337 if self._exec_info.intro:
338 text = self._exec_info.ps3 + "pcs.read("
339 text = text + "align_id=" + repr(align_id)
340 text = text + ", file=" + repr(file)
341 text = text + ", dir=" + repr(dir)
342 text = text + ", spin_id_col=" + repr(spin_id_col)
343 text = text + ", mol_name_col=" + repr(mol_name_col)
344 text = text + ", res_num_col=" + repr(res_num_col)
345 text = text + ", res_name_col=" + repr(res_name_col)
346 text = text + ", spin_num_col=" + repr(spin_num_col)
347 text = text + ", spin_name_col=" + repr(spin_name_col)
348 text = text + ", data_col=" + repr(data_col)
349 text = text + ", error_col=" + repr(error_col)
350 text = text + ", sep=" + repr(sep)
351 text = text + ", spin_id=" + repr(spin_id) + ")"
352 print(text)
353
354
355 arg_check.is_str(align_id, 'alignment ID string')
356 arg_check.is_str(file, 'file name')
357 arg_check.is_str(dir, 'directory name', can_be_none=True)
358 arg_check.is_int(spin_id_col, 'spin ID string column', can_be_none=True)
359 arg_check.is_int(mol_name_col, 'molecule name column', can_be_none=True)
360 arg_check.is_int(res_num_col, 'residue number column', can_be_none=True)
361 arg_check.is_int(res_name_col, 'residue name column', can_be_none=True)
362 arg_check.is_int(spin_num_col, 'spin number column', can_be_none=True)
363 arg_check.is_int(spin_name_col, 'spin name column', can_be_none=True)
364 arg_check.is_int(data_col, 'data column', can_be_none=True)
365 arg_check.is_int(error_col, 'error column', can_be_none=True)
366 arg_check.is_str(sep, 'column separator', can_be_none=True)
367 arg_check.is_str(spin_id, 'spin ID string', can_be_none=True)
368
369
370 pcs.read(align_id=align_id, file=file, dir=dir, 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)
371
372
373 - def weight(self, align_id=None, spin_id=None, weight=1.0):
374 """Set optimisation weights on the PCS data.
375
376 Keyword Arguments
377 ~~~~~~~~~~~~~~~~~
378
379 align_id: The alignment ID string.
380
381 spin_id: The spin ID string.
382
383 weight: The weighting value.
384
385
386 Description
387 ~~~~~~~~~~~
388
389 This function can be used to force the PCS to contribute more or less to the chi-squared
390 optimisation statistic. The higher the value, the more importance the PCS will have.
391 """
392
393
394 if self._exec_info.intro:
395 text = self._exec_info.ps3 + "pcs.weight("
396 text = text + "align_id=" + repr(align_id)
397 text = text + ", spin_id=" + repr(spin_id)
398 text = text + ", weight=" + repr(weight) + ")"
399 print(text)
400
401
402 arg_check.is_str(align_id, 'alignment ID string')
403 arg_check.is_str(spin_id, 'spin ID string', can_be_none=True)
404 arg_check.is_num(weight, 'weight')
405
406
407 pcs.weight(align_id=align_id, spin_id=spin_id, weight=weight)
408
409
410 - def write(self, align_id=None, file=None, dir=None, bc=False, force=False):
411 """Write the PCS data to file.
412
413 Keyword Arguments
414 ~~~~~~~~~~~~~~~~~
415
416 align_id: The alignment ID string.
417
418 file: The name of the file.
419
420 dir: The directory name.
421
422 bc: A flag which if set will write out the back-calculated rather than measured RDCs.
423
424 force: A flag which if True will cause the file to be overwritten.
425
426
427 Description
428 ~~~~~~~~~~~
429
430 If no directory name is given, the file will be placed in the current working directory.
431 The 'align_id' argument are required for selecting which PCS data set will be written to file.
432 """
433
434
435 if self._exec_info.intro:
436 text = self._exec_info.ps3 + "pcs.write("
437 text = text + "align_id=" + repr(align_id)
438 text = text + ", file=" + repr(file)
439 text = text + ", dir=" + repr(dir)
440 text = text + ", bc=" + repr(bc)
441 text = text + ", force=" + repr(force) + ")"
442 print(text)
443
444
445 arg_check.is_str(align_id, 'alignment ID string')
446 arg_check.is_str(file, 'file name')
447 arg_check.is_str(dir, 'directory name', can_be_none=True)
448 arg_check.is_bool(bc, 'back-calculation flag')
449 arg_check.is_bool(force, 'force flag')
450
451
452 pcs.write(align_id=align_id, file=file, dir=dir, bc=bc, force=force)
453