Package user_functions :: Module pcs
[hide private]
[frames] | no frames]

Source Code for Module user_functions.pcs

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003-2015 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Module docstring. 
 23  """The pcs user function definitions.""" 
 24   
 25  # Python module imports. 
 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  # relax module imports. 
 34  from graphics import WIZARD_IMAGE_PATH 
 35  from pipe_control import align_tensor, pcs, pipes 
 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  # The user function class. 
 43  uf_class = uf_info.add_class('pcs') 
 44  uf_class.title = "Class for handling pseudo-contact shifts." 
 45  uf_class.menu_text = "&pcs" 
 46  uf_class.gui_icon = "relax.align_tensor" 
 47   
 48   
 49  # The pcs.back_calc user function. 
 50  uf = uf_info.add_uf('pcs.back_calc') 
 51  uf.title = "Back calculate the pseudo-contact shifts." 
 52  uf.title_short = "PCS 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  # Description. 
 65  uf.desc.append(Desc_container()) 
 66  uf.desc[-1].add_paragraph("This will back calculate the pseudo-contact shifts if the paramagnetic centre, temperature and magnetic field strength has been specified, an alignment tensor is present, and atomic positions have been loaded into the relax data store.") 
 67  uf.backend = pcs.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  # The pcs.calc_q_factors user function. 
 75  uf = uf_info.add_uf('pcs.calc_q_factors') 
 76  uf.title = "Calculate the PCS Q factor for the selected spins." 
 77  uf.title_short = "PCS 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  # Description. 
 94  uf.desc.append(Desc_container()) 
 95  uf.desc[-1].add_paragraph("For this to work, the back-calculated PCS data must first be generated by the analysis specific code.  Otherwise a warning will be given.") 
 96  # Prompt examples. 
 97  uf.desc.append(Desc_container("Prompt examples")) 
 98  uf.desc[-1].add_paragraph("To calculate the PCS Q factor for only the spins '@H26', '@H27', and '@H28', type one of:") 
 99  uf.desc[-1].add_prompt("relax> pcs.calc_q_factors('@H26 & @H27 & @H28')") 
100  uf.desc[-1].add_prompt("relax> pcs.calc_q_factors(spin_id='@H26 & @H27 & @H28')") 
101  uf.backend = pcs.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  # The pcs.copy user function. 
109  uf = uf_info.add_uf('pcs.copy') 
110  uf.title = "Copy PCS data from one data pipe to another." 
111  uf.title_short = "PCS 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 PCS 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 PCS 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 PCSs present to also be copied with the real values and errors." 
146  ) 
147  # Description. 
148  uf.desc.append(Desc_container()) 
149  uf.desc[-1].add_paragraph("This function will copy PCS data from 'pipe_from' to 'pipe_to'.  If align_id is not given then all PCS data will be copied, otherwise only a specific data set will be.") 
150  # Prompt examples. 
151  uf.desc.append(Desc_container("Prompt examples")) 
152  uf.desc[-1].add_paragraph("To copy all PCS data from pipe 'm1' to pipe 'm9', type one of:") 
153  uf.desc[-1].add_prompt("relax> pcs.copy('m1', 'm9')") 
154  uf.desc[-1].add_prompt("relax> pcs.copy(pipe_from='m1', pipe_to='m9')") 
155  uf.desc[-1].add_prompt("relax> pcs.copy('m1', 'm9', None)") 
156  uf.desc[-1].add_prompt("relax> pcs.copy(pipe_from='m1', pipe_to='m9', align_id=None)") 
157  uf.desc[-1].add_paragraph("To copy only the 'Th' PCS data from 'm3' to 'm6', type one of:") 
158  uf.desc[-1].add_prompt("relax> pcs.copy('m3', 'm6', 'Th')") 
159  uf.desc[-1].add_prompt("relax> pcs.copy(pipe_from='m3', pipe_to='m6', align_id='Th')") 
160  uf.backend = pcs.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  # The pcs.corr_plot user function. 
167  uf = uf_info.add_uf('pcs.corr_plot') 
168  uf.title = "Generate a correlation plot of the measured vs. the back-calculated PCSs." 
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 = "pcs_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  # Description. 
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  # Prompt examples. 
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> pcs.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> pcs.corr_plot(None)") 
229  uf.desc[-1].add_prompt("relax> pcs.corr_plot(format=None)") 
230  uf.backend = pcs.corr_plot 
231  uf.menu_text = "corr_&plot" 
232  uf.gui_icon = "relax.grace_icon" 
233  uf.wizard_size = (800, 500) 
234  uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png' 
235  uf.wizard_apply_button = False 
236   
237   
238  # The pcs.delete user function. 
239  uf = uf_info.add_uf('pcs.delete') 
240  uf.title = "Delete the PCS data corresponding to the alignment ID." 
241  uf.title_short = "PCS 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  # Description. 
253  uf.desc.append(Desc_container()) 
254  uf.desc[-1].add_paragraph("This will delete all PCS data associated with the alignment ID in the current data pipe.") 
255  # Prompt examples. 
256  uf.desc.append(Desc_container("Prompt examples")) 
257  uf.desc[-1].add_paragraph("To delete the PCS data corresponding to align_id='PH_gel', type:") 
258  uf.desc[-1].add_prompt("relax> pcs.delete('PH_gel')") 
259  uf.backend = pcs.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  # The pcs.display user function. 
266  uf = uf_info.add_uf('pcs.display') 
267  uf.title = "Display the PCS data corresponding to the alignment ID." 
268  uf.title_short = "PCS 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  # Description. 
287  uf.desc.append(Desc_container()) 
288  uf.desc[-1].add_paragraph("This will display all of the PCS data associated with the alignment ID in the current data pipe.") 
289  # Prompt examples. 
290  uf.desc.append(Desc_container("Prompt examples")) 
291  uf.desc[-1].add_paragraph("To display the 'phage' PCS data, type:") 
292  uf.desc[-1].add_prompt("relax> pcs.display('phage')") 
293  uf.backend = pcs.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  # The pcs.read user function. 
300  uf = uf_info.add_uf('pcs.read') 
301  uf.title = "Read the PCS data from file." 
302  uf.title_short = "PCS 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 PCS 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 = "spin_id_col", 
329      py_type = "int", 
330      arg_type = "free format", 
331      desc_short = "spin ID column", 
332      desc = "The spin ID string column (an alternative to the mol, res, and spin name and number columns).", 
333      can_be_none = True 
334  ) 
335  uf.add_keyarg( 
336      name = "mol_name_col", 
337      py_type = "int", 
338      arg_type = "free format", 
339      desc_short = "molecule name column", 
340      desc = "The molecule name column (alternative to the spin_id_col).", 
341      can_be_none = True 
342  ) 
343  uf.add_keyarg( 
344      name = "res_num_col", 
345      py_type = "int", 
346      arg_type = "free format", 
347      desc_short = "residue number column", 
348      desc = "The residue number column (alternative to the spin_id_col).", 
349      can_be_none = True 
350  ) 
351  uf.add_keyarg( 
352      name = "res_name_col", 
353      py_type = "int", 
354      arg_type = "free format", 
355      desc_short = "residue name column", 
356      desc = "The residue name column (alternative to the spin_id_col).", 
357      can_be_none = True 
358  ) 
359  uf.add_keyarg( 
360      name = "spin_num_col", 
361      py_type = "int", 
362      arg_type = "free format", 
363      desc_short = "spin number column", 
364      desc = "The spin number column (alternative to the spin_id_col).", 
365      can_be_none = True 
366  ) 
367  uf.add_keyarg( 
368      name = "spin_name_col", 
369      py_type = "int", 
370      arg_type = "free format", 
371      desc_short = "spin name column", 
372      desc = "The spin name column (alternative to the spin_id_col).", 
373      can_be_none = True 
374  ) 
375  uf.add_keyarg( 
376      name = "data_col", 
377      py_type = "int", 
378      arg_type = "free format", 
379      desc_short = "data column", 
380      desc = "The PCS data column.", 
381      can_be_none = True 
382  ) 
383  uf.add_keyarg( 
384      name = "error_col", 
385      py_type = "int", 
386      arg_type = "free format", 
387      desc_short = "error column", 
388      desc = "The experimental error column.", 
389      can_be_none = True 
390  ) 
391  uf.add_keyarg( 
392      name = "sep", 
393      py_type = "str", 
394      arg_type = "free format", 
395      desc_short = "column separator", 
396      desc = "The column separator (the default is white space).", 
397      can_be_none = True 
398  ) 
399  uf.add_keyarg( 
400      name = "spin_id", 
401      py_type = "str", 
402      desc_short = "spin ID string", 
403      desc = "The spin ID string to restrict the loading of data to certain spin subsets.", 
404      can_be_none = True 
405  ) 
406  # Description. 
407  uf.desc.append(Desc_container()) 
408  uf.desc[-1].add_paragraph("This will read PCS data from a file and associate it with an alignment ID, either a new ID or a preexisting one with no PCS data.") 
409  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.") 
410  # Prompt examples. 
411  uf.desc.append(Desc_container("Prompt examples")) 
412  uf.desc[-1].add_paragraph("The following commands will read the PCS data out of the file 'Tb.txt' where the columns are separated by the symbol ',', and store the PCSs under the ID 'Tb'.") 
413  uf.desc[-1].add_prompt("relax> pcs.read('Tb', 'Tb.txt', sep=',')") 
414  uf.desc[-1].add_paragraph("To read the 15N and 1H PCSs from the file 'Eu.txt', where the 15N values are in the 4th column and the 1H in the 9th, type both the following:") 
415  uf.desc[-1].add_prompt("relax> pcs.read('Tb', 'Tb.txt', spin_id='@N', res_num_col=1, data_col=4)") 
416  uf.desc[-1].add_prompt("relax> pcs.read('Tb', 'Tb.txt', spin_id='@H', res_num_col=1, data_col=9)") 
417  uf.backend = pcs.read 
418  uf.menu_text = "&read" 
419  uf.gui_icon = "oxygen.actions.document-open" 
420  uf.wizard_size = (900, 600) 
421  uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png' 
422   
423   
424  # The pcs.set_errors user function. 
425  uf = uf_info.add_uf('pcs.set_errors') 
426  uf.title = "Set the errors for the PCSs." 
427  uf.title_short = "PCS error setting." 
428  uf.add_keyarg( 
429      name = "align_id", 
430      py_type = "str", 
431      desc_short = "alignment ID string", 
432      desc = "The optional alignment ID string.", 
433      wiz_element_type = 'combo', 
434      wiz_combo_iter = align_tensor.get_align_ids, 
435      wiz_read_only = True, 
436      can_be_none = True 
437  ) 
438  uf.add_keyarg( 
439      name = "spin_id", 
440      py_type = "str", 
441      arg_type = "spin ID", 
442      desc_short = "spin ID string", 
443      desc = "The optional spin ID string.", 
444      wiz_combo_iter = get_spin_ids, 
445      can_be_none = True 
446  ) 
447  uf.add_keyarg( 
448      name = "sd", 
449      default = 0.1, 
450      py_type = "num", 
451      desc_short = "PCS error (ppm)", 
452      desc = "The PCS standard deviation value in ppm." 
453  ) 
454  # Description. 
455  uf.desc.append(Desc_container()) 
456  uf.desc[-1].add_paragraph("If the PCS errors have not already been read from a PCS data file or if they need to be changed, then the errors can be set via this user function.") 
457  uf.backend = pcs.set_errors 
458  uf.menu_text = "&set_errors" 
459  uf.gui_icon = "oxygen.actions.edit-rename" 
460  uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png' 
461   
462   
463  # The pcs.structural_noise user function. 
464  uf = uf_info.add_uf('pcs.structural_noise') 
465  uf.title = "Determine the PCS error due to structural noise via simulation." 
466  uf.title_short = "PCS structural noise simulation." 
467  uf.display = True 
468  uf.add_keyarg( 
469      name = "align_id", 
470      py_type = "str", 
471      desc_short = "alignment ID string", 
472      desc = "The optional alignment ID string.", 
473      wiz_element_type = 'combo', 
474      wiz_combo_iter = align_tensor.get_align_ids, 
475      wiz_read_only = True, 
476      can_be_none = True 
477  ) 
478  uf.add_keyarg( 
479      name = "rmsd", 
480      default = 0.2, 
481      py_type = "float", 
482      desc_short = "structural RMSD", 
483      desc = "The atomic position RMSD, in Angstrom, to randomise the spin positions with for the simulations." 
484  ) 
485  uf.add_keyarg( 
486      name = "sim_num", 
487      default = 1000, 
488      min = 3, 
489      max = 10000000, 
490      py_type = "int", 
491      desc_short = "simulation number N", 
492      desc = "The number of simulations, N, to perform to determine the structural noise component of the PCS errors." 
493  ) 
494  uf.add_keyarg( 
495      name = "file", 
496      py_type = "str", 
497      arg_type = "file sel", 
498      desc_short = "Grace file name", 
499      desc = "The optional name of the Grace file to plot the structural errors verses the paramagnetic centre to spin distances.", 
500      wiz_filesel_wildcard = WILDCARD_GRACE_ALL, 
501      wiz_filesel_style = FD_SAVE, 
502      can_be_none = True 
503  ) 
504  uf.add_keyarg( 
505      name = "dir", 
506      py_type = "str", 
507      arg_type = "dir", 
508      desc_short = "directory name", 
509      desc = "The directory name to place the Grace file into.", 
510      can_be_none = True 
511  ) 
512  uf.add_keyarg( 
513      name = "force", 
514      default = False, 
515      py_type = "bool", 
516      desc_short = "force flag", 
517      desc = "A flag which if True will cause the file to be overwritten." 
518  ) 
519  # Description. 
520  uf.desc.append(Desc_container()) 
521  uf.desc[-1].add_paragraph("The analysis of the pseudo-contact shift is influenced by two significant sources of noise - that of the NMR experiment and structural noise from the 3D molecular structure used.  The closer the spin to the paramagnetic centre, the greater the influence of structural noise.  This distance dependence is governed by the equation:") 
522  uf.desc[-1].add_verbatim(""" 
523                   sqrt(3) * abs(delta) * RMSD 
524      sigma_dist = --------------------------- , 
525                              r 
526  """) 
527  uf.desc[-1].add_paragraph("where sigma_dist is the distance component of the structural noise as a standard deviation, delta is the PCS value, RMSD is the atomic position root-mean-square deviation, and r is the paramagnetic centre to spin distance.  When close to the paramagnetic centre, this error source can exceed that of the NMR experiment.  The equation for the angular component of the structural noise is more complicated.  The PCS error is influenced by distance, angle in the alignment frame, and the magnetic susceptibility tensor.") 
528  uf.desc[-1].add_paragraph("For the simulation the following must already be set up in the current data pipe:") 
529  uf.desc[-1].add_list_element("The position of the paramagnetic centre.") 
530  uf.desc[-1].add_list_element("The alignment and magnetic susceptibility tensor.") 
531  uf.desc[-1].add_paragraph("The protocol for the simulation is as follows:") 
532  uf.desc[-1].add_list_element("The lanthanide or paramagnetic centre position will be fixed.  Its motion is assumed to be on the femto- to pico- and nanosecond timescales.  Hence the motion is averaged over the evolution of the PCS and can be ignored.") 
533  uf.desc[-1].add_list_element("The positions of the nuclear spins will be randomised N times.  For each simulation a random unit vector will be generated.  Then a random distance along the unit vector will be generated by sampling from a Gaussian distribution centered at zero, the original spin position, with a standard deviation set to the given RMSD.  Both positive and negative displacements will be used.") 
534  uf.desc[-1].add_list_element("The PCS for the randomised position will be back calculated.") 
535  uf.desc[-1].add_list_element("The PCS standard deviation will be calculated from the N randomised PCS values.") 
536  uf.desc[-1].add_paragraph("The standard deviation will both be stored in the spin container data structure in the relax data store as well as being added to the already present PCS error (using variance addition).  This will then be used in any optimisations involving the PCS.") 
537  uf.desc[-1].add_paragraph("If the alignment ID string is not supplied, the procedure will be applied to the PCS data from all alignments.") 
538  uf.backend = pcs.structural_noise 
539  uf.menu_text = "&structural_noise" 
540  uf.wizard_size = (1000, 700) 
541  uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png' 
542  uf.wizard_apply_button = False 
543   
544   
545  # The pcs.weight user function. 
546  uf = uf_info.add_uf('pcs.weight') 
547  uf.title = "Set optimisation weights on the PCS data." 
548  uf.title_short = "PCS weighting." 
549  uf.add_keyarg( 
550      name = "align_id", 
551      py_type = "str", 
552      desc_short = "alignment ID string", 
553      desc = "The alignment ID string.", 
554      wiz_element_type = 'combo', 
555      wiz_combo_iter = align_tensor.get_align_ids, 
556      wiz_read_only = True 
557  ) 
558  uf.add_keyarg( 
559      name = "spin_id", 
560      py_type = "str", 
561      desc_short = "spin ID string", 
562      desc = "The spin ID string.", 
563      can_be_none = True 
564  ) 
565  uf.add_keyarg( 
566      name = "weight", 
567      default = 1.0, 
568      py_type = "num", 
569      desc_short = "weight", 
570      desc = "The weighting value." 
571  ) 
572  # Description. 
573  uf.desc.append(Desc_container()) 
574  uf.desc[-1].add_paragraph("This can be used to force the PCS to contribute more or less to the chi-squared optimisation statistic.  The higher the value, the more importance the PCS will have.") 
575  uf.backend = pcs.weight 
576  uf.menu_text = "wei&ght" 
577  uf.wizard_size = (700, 500) 
578  uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png' 
579   
580   
581  # The pcs.write user function. 
582  uf = uf_info.add_uf('pcs.write') 
583  uf.title = "Write the PCS data to file." 
584  uf.title_short = "PCS data writing." 
585  uf.add_keyarg( 
586      name = "align_id", 
587      py_type = "str", 
588      desc_short = "alignment ID string", 
589      desc = "The alignment ID string.", 
590      wiz_element_type = 'combo', 
591      wiz_combo_iter = align_tensor.get_align_ids, 
592      wiz_read_only = True 
593  ) 
594  uf.add_keyarg( 
595      name = "file", 
596      py_type = "str", 
597      arg_type = "file sel", 
598      desc_short = "file name", 
599      desc = "The name of the file.", 
600      wiz_filesel_style = FD_SAVE 
601  ) 
602  uf.add_keyarg( 
603      name = "dir", 
604      py_type = "str", 
605      arg_type = "dir", 
606      desc_short = "directory name", 
607      desc = "The directory name.", 
608      can_be_none = True 
609  ) 
610  uf.add_keyarg( 
611      name = "bc", 
612      default = False, 
613      py_type = "bool", 
614      desc_short = "back-calculation flag", 
615      desc = "A flag which if set will write out the back-calculated rather than measured RDCs." 
616  ) 
617  uf.add_keyarg( 
618      name = "force", 
619      default = False, 
620      py_type = "bool", 
621      desc_short = "force flag", 
622      desc = "A flag which if True will cause the file to be overwritten." 
623  ) 
624  # Description. 
625  uf.desc.append(Desc_container()) 
626  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 PCS data set will be written to file.") 
627  uf.backend = pcs.write 
628  uf.menu_text = "&write" 
629  uf.gui_icon = "oxygen.actions.document-save" 
630  uf.wizard_size = (800, 600) 
631  uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png' 
632