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

Source Code for Module user_functions.spectrum

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2004-2014 Edward d'Auvergne                                   # 
  4  # Copyright (C) 2013 Troels E. Linnet                                         # 
  5  #                                                                             # 
  6  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  7  #                                                                             # 
  8  # This program is free software: you can redistribute it and/or modify        # 
  9  # it under the terms of the GNU General Public License as published by        # 
 10  # the Free Software Foundation, either version 3 of the License, or           # 
 11  # (at your option) any later version.                                         # 
 12  #                                                                             # 
 13  # This program is distributed in the hope that it will be useful,             # 
 14  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 16  # GNU General Public License for more details.                                # 
 17  #                                                                             # 
 18  # You should have received a copy of the GNU General Public License           # 
 19  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Module docstring. 
 24  """The spectrum user function definitions.""" 
 25   
 26  # Python module imports. 
 27  from os import sep 
 28  import dep_check 
 29  if dep_check.wx_module: 
 30      from wx import FD_OPEN 
 31  else: 
 32      FD_OPEN = -1 
 33   
 34  # relax module imports. 
 35  from graphics import WIZARD_IMAGE_PATH 
 36  from pipe_control import spectrum 
 37  from user_functions.data import Uf_info; uf_info = Uf_info() 
 38  from user_functions.data import Uf_tables; uf_tables = Uf_tables() 
 39  from user_functions.objects import Desc_container 
 40  from user_functions.wildcards import WILDCARD_SPECTRUM_PEAKLIST 
 41   
 42   
 43  # The user function class. 
 44  uf_class = uf_info.add_class('spectrum') 
 45  uf_class.title = "Class for supporting the input of spectral data." 
 46  uf_class.menu_text = "&spectrum" 
 47  uf_class.gui_icon = "relax.fid" 
 48   
 49   
 50  # The spectrum.baseplane_rmsd user function. 
 51  uf = uf_info.add_uf('spectrum.baseplane_rmsd') 
 52  uf.title = "Set the baseplane RMSD of a given spin in a spectrum for error analysis." 
 53  uf.title_short = "Baseplane RMSD setting." 
 54  uf.add_keyarg( 
 55      name = "error", 
 56      default = 0.0, 
 57      py_type = "num", 
 58      desc_short = "error", 
 59      desc = "The baseplane RMSD error value." 
 60  ) 
 61  uf.add_keyarg( 
 62      name = "spectrum_id", 
 63      py_type = "str", 
 64      desc_short = "spectrum ID string", 
 65      desc = "The spectrum ID string.", 
 66      wiz_element_type = 'combo', 
 67      wiz_combo_iter = spectrum.get_ids, 
 68      wiz_read_only = True 
 69  ) 
 70  uf.add_keyarg( 
 71      name = "spin_id", 
 72      py_type = "str", 
 73      desc_short = "spin ID string", 
 74      desc = "The spin ID string.", 
 75      can_be_none = True 
 76  ) 
 77  # Description. 
 78  uf.desc.append(Desc_container()) 
 79  uf.desc[-1].add_paragraph("The spectrum ID identifies the spectrum associated with the error and must correspond to a previously loaded set of intensities.  If the spin ID is unset, then the error value for all spins will be set to the supplied value.") 
 80  uf.backend = spectrum.baseplane_rmsd 
 81  uf.menu_text = "&baseplane_rmsd" 
 82  uf.gui_icon = "oxygen.actions.edit-rename" 
 83  uf.wizard_size = (800, 500) 
 84  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
 85   
 86   
 87  # The spectrum.delete user function. 
 88  uf = uf_info.add_uf('spectrum.delete') 
 89  uf.title = "Delete the spectral data corresponding to the spectrum ID string." 
 90  uf.title_short = "Spectral data deletion." 
 91  uf.add_keyarg( 
 92      name = "spectrum_id", 
 93      py_type = "str", 
 94      desc_short = "spectrum ID string", 
 95      desc = "The unique spectrum ID string.", 
 96      wiz_element_type = 'combo', 
 97      wiz_combo_iter = spectrum.get_ids, 
 98      wiz_read_only = True 
 99  ) 
100  # Description. 
101  uf.desc.append(Desc_container()) 
102  uf.desc[-1].add_paragraph("The spectral data corresponding to the given spectrum ID string will be removed from the current data pipe.") 
103  # Prompt examples. 
104  uf.desc.append(Desc_container("Prompt examples")) 
105  uf.desc[-1].add_paragraph("To delete the peak height data corresponding to the ID 'R1 ncyc5', type:") 
106  uf.desc[-1].add_prompt("relax> spectrum.delete('R1 ncyc5')") 
107  uf.backend = spectrum.delete 
108  uf.menu_text = "&delete" 
109  uf.gui_icon = "oxygen.actions.list-remove" 
110  uf.wizard_size = (700, 400) 
111  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
112   
113   
114  # The spectrum.error_analysis user function. 
115  uf = uf_info.add_uf('spectrum.error_analysis') 
116  uf.title = "Perform an error analysis for peak intensities." 
117  uf.title_short = "Peak intensity error analysis." 
118  uf.add_keyarg( 
119      name = "subset", 
120      py_type = "str_list", 
121      desc_short = "subset spectrum IDs", 
122      desc = "The list of spectrum ID strings to restrict the error analysis to.", 
123      wiz_combo_iter = spectrum.get_ids, 
124      wiz_read_only = True, 
125      can_be_none = True 
126  ) 
127  # Description. 
128  uf.desc.append(Desc_container()) 
129  uf.desc[-1].add_paragraph("This user function must only be called after all peak intensities have been loaded and all other necessary spectral information set.  This includes the baseplane RMSD and the number of points used in volume integration, both of which are only used if spectra have not been replicated.") 
130  uf.desc[-1].add_paragraph("The error analysis can be restricted to a subset of the loaded spectral data.  This is useful, for example, if half the spectra have been collected on one spectrometer and the other half on a different spectrometer.") 
131  uf.desc[-1].add_paragraph("Six different types of error analysis are supported depending on whether peak heights or volumes are supplied, whether noise is determined from replicated spectra or the RMSD of the baseplane noise, and whether all spectra or only a subset have been duplicated.  These are:") 
132  table = uf_tables.add_table(label="table: peak intensity error analysis", caption="The six peak intensity error analysis types.") 
133  table.add_headings(["Int type", "Noise source", "Error scope"]) 
134  table.add_row(["Heights", "RMSD baseplane", "One sigma per peak per spectrum"]) 
135  table.add_row(["Heights", "Partial duplicate + variance averaging", "One sigma for all peaks, all spectra"]) 
136  table.add_row(["Heights", "All replicated + variance averaging", "One sigma per replicated spectra set"]) 
137  table.add_row(["Volumes", "RMSD baseplane", "One sigma per peak per spectrum"]) 
138  table.add_row(["Volumes", "Partial duplicate + variance averaging", "One sigma for all peaks, all spectra"]) 
139  table.add_row(["Volumes", "All replicated + variance averaging", "One sigma per replicated spectra set"]) 
140  uf.desc[-1].add_table(table.label) 
141  # Peak heights with baseplane noise RMSD. 
142  uf.desc.append(Desc_container("Peak heights with baseplane noise RMSD")) 
143  uf.desc[-1].add_paragraph("When none of the spectra have been replicated, then the peak height errors are calculated using the RMSD of the baseplane noise, the value of which is set by the spectrum.baseplane_rmsd user function.  This results in a different error per peak per spectrum.  The standard deviation error measure for the peak height, sigma_I, is set to the RMSD value.") 
144  # Peak heights with partially replicated spectra. 
145  uf.desc.append(Desc_container("Peak heights with partially replicated spectra")) 
146  uf.desc[-1].add_paragraph("When spectra are replicated, the variance for a single spin at a single replicated spectra set is calculated by the formula") 
147  uf.desc[-1].add_item_list_element(None, "sigma^2 =  sum({Ii - Iav}^2) / (n - 1),") 
148  uf.desc[-1].add_paragraph("where sigma^2 is the variance, sigma is the standard deviation, n is the size of the replicated spectra set with i being the corresponding index, Ii is the peak intensity for spectrum i, and Iav is the mean over all spectra i.e. the sum of all peak intensities divided by n.") 
149  uf.desc[-1].add_paragraph("As the value of n in the above equation is always very low since normally only a couple of spectra are collected per replicated spectra set, the variance of all spins is averaged for a single replicated spectra set.  Although this results in all spins having the same error, the accuracy of the error estimate is significantly improved.") 
150  uf.desc[-1].add_paragraph("If there are in addition to the replicated spectra loaded peak intensities which only consist of a single spectrum, i.e. not all spectra are replicated, then the variances of replicated replicated spectra sets will be averaged.  This will be used for the entire experiment so that there will be only a single error value for all spins and for all spectra.") 
151  # Peak heights with all spectra replicated. 
152  uf.desc.append(Desc_container("Peak heights with all spectra replicated")) 
153  uf.desc[-1].add_paragraph("If all spectra are collected in duplicate (triplicate or higher number of spectra are supported), the each replicated spectra set will have its own error estimate.  The error for a single peak is calculated as when partially replicated spectra are collected, and these are again averaged to give a single error per replicated spectra set.  However as all replicated spectra sets will have their own error estimate, variance averaging across all spectra sets will not be performed.") 
154  # Peak volumes with baseplane noise RMSD. 
155  uf.desc.append(Desc_container("Peak volumes with baseplane noise RMSD")) 
156  uf.desc[-1].add_paragraph("The method of error analysis when no spectra have been replicated and peak volumes are used is highly dependent on the integration method.  Many methods simply sum the number of points within a fixed region, either a box or oval object.  The number of points used, N, must be specified by another user function in this class.  Then the error is simply given by the sum of variances:") 
157  uf.desc[-1].add_item_list_element(None, "sigma_vol^2 = sigma_i^2 * N,") 
158  uf.desc[-1].add_paragraph("where sigma_vol is the standard deviation of the volume, sigma_i is the standard deviation of a single point assumed to be equal to the RMSD of the baseplane noise, and N is the total number of points used in the summation integration method.  For a box integration method, this converts to the Nicholson, Kay, Baldisseri, Arango, Young, Bax, and Torchia (1992) Biochemistry, 31: 5253-5263 equation:") 
159  uf.desc[-1].add_item_list_element(None, "sigma_vol = sigma_i * sqrt(n*m),") 
160  uf.desc[-1].add_paragraph("where n and m are the dimensions of the box.  Note that a number of programs, for example peakint (http://hugin.ethz.ch/wuthrich/software/xeasy/xeasy_m15.html) does not use all points within the box.  And if the number N can not be determined, this category of error analysis is not possible.") 
161  uf.desc[-1].add_paragraph("Also note that non-point summation methods, for example when line shape fitting is used to determine peak volumes, the equations above cannot be used.  Hence again this category of error analysis cannot be used.  This is the case for one of the three integration methods used by Sparky (http://www.cgl.ucsf.edu/home/sparky/manual/peaks.html#Integration).  And if fancy techniques are used, for example as Cara does to deconvolute overlapping peaks (http://www.cara.ethz.ch/Wiki/Integration), this again makes this error analysis impossible.") 
162  # Peak volumes with partially replicated spectra. 
163  uf.desc.append(Desc_container("Peak volumes with partially replicated spectra")) 
164  uf.desc[-1].add_paragraph("When peak volumes are measured by any integration method and a few of the spectra are replicated, then the intensity errors are calculated identically as described in the 'Peak heights with partially replicated spectra' section above.") 
165  # Peak volumes with all spectra replicated. 
166  uf.desc.append(Desc_container("Peak volumes with all spectra replicated")) 
167  uf.desc[-1].add_paragraph("With all spectra replicated and again using any integration methodology, the intensity errors can be calculated as described in the 'Peak heights with all spectra replicated' section above.") 
168  uf.backend = spectrum.error_analysis 
169  uf.menu_text = "&error_analysis" 
170  uf.gui_icon = "oxygen.categories.applications-education" 
171  uf.wizard_height_desc = 530 
172  uf.wizard_size = (1000, 700) 
173  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
174  uf.wizard_apply_button = False 
175   
176   
177  # The spectrum.integration_points user function. 
178  uf = uf_info.add_uf('spectrum.integration_points') 
179  uf.title = "Set the number of summed points used in volume integration of a given spin in a spectrum." 
180  uf.title_short = "Number of integration points." 
181  uf.add_keyarg( 
182      name = "N", 
183      py_type = "int", 
184      min = 1, 
185      max = 10000000, 
186      desc_short = "number of summed points", 
187      desc = "The number of points used by the summation volume integration method." 
188  ) 
189  uf.add_keyarg( 
190      name = "spectrum_id", 
191      py_type = "str", 
192      desc_short = "spectrum ID string", 
193      desc = "The spectrum ID string.", 
194      wiz_element_type = 'combo', 
195      wiz_combo_iter = spectrum.get_ids, 
196      wiz_read_only = True 
197  ) 
198  uf.add_keyarg( 
199      name = "spin_id", 
200      py_type = "str", 
201      desc_short = "spin ID string", 
202      desc = "Restrict setting the number to certain spins.", 
203      can_be_none = True 
204  ) 
205  # Description. 
206  uf.desc.append(Desc_container()) 
207  uf.desc[-1].add_paragraph("For a complete description of which integration methods and how many points N are used for different integration techniques, please see the spectrum.error_analysis user function documentation.") 
208  uf.desc[-1].add_paragraph("The spectrum ID identifies the spectrum associated with the value of N and must correspond to a previously loaded set of intensities.  If the spin ID is unset, then the number of summed points for all spins will be set to the supplied value.") 
209  uf.backend = spectrum.integration_points 
210  uf.menu_text = "&integration_points" 
211  uf.gui_icon = "oxygen.actions.edit-rename" 
212  uf.wizard_size = (900, 600) 
213  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
214   
215   
216  # The spectrum.read_intensities user function. 
217  uf = uf_info.add_uf('spectrum.read_intensities') 
218  uf.title = "Read peak intensities from a file." 
219  uf.title_short = "Peak intensity reading." 
220  uf.add_keyarg( 
221      name = "file", 
222      py_type = "str_or_str_list", 
223      arg_type = "file sel multi", 
224      desc_short = "file name(s)", 
225      desc = "The name of the file or the list of files containing the intensity data.", 
226      wiz_filesel_wildcard = WILDCARD_SPECTRUM_PEAKLIST, 
227      wiz_filesel_style = FD_OPEN 
228  ) 
229  uf.add_keyarg( 
230      name = "dir", 
231      py_type = "str", 
232      arg_type = "dir", 
233      desc_short = "directory name", 
234      desc = "The directory where the file is located.", 
235      can_be_none = True 
236  ) 
237  uf.add_keyarg( 
238      name = "spectrum_id", 
239      py_type = "str_or_str_list", 
240      desc_short = "spectrum ID string", 
241      desc = "The unique spectrum ID string or list of strings to associate with the peak intensity values.  If multiple files are given, then each file should have a corresponding spectrum ID string.  If 'auto' is provided for a NMRPipe seriesTab formatted file, the IDs are auto generated in form of Z_A{i}." 
242  ) 
243  uf.add_keyarg( 
244      name = "dim", 
245      default = 1, 
246      py_type = "int", 
247      min = 1, 
248      desc_short = "spectral dimension to read", 
249      desc = "Associate the data with the spins of any dimension in the peak list.  This defaults to w1, the heteronucleus in HSQC type experiments." 
250  ) 
251  uf.add_keyarg( 
252      name = "int_method", 
253      default = "height", 
254      py_type = "str", 
255      desc_short = "peak integration method", 
256      desc = "The method by which peaks were integrated.", 
257      wiz_element_type = "combo", 
258      wiz_combo_choices = ["height", "point sum", "other"], 
259      wiz_read_only = True 
260  ) 
261  uf.add_keyarg( 
262      name = "int_col", 
263      py_type = "int_or_int_list", 
264      desc_short = "intensity column", 
265      desc = "The optional column containing the peak intensity data (used by the generic intensity file format, or if the intensities are in a non-standard column).", 
266      can_be_none = True 
267  ) 
268  uf.add_keyarg( 
269      name = "spin_id_col", 
270      py_type = "int", 
271      arg_type = "free format", 
272      desc_short = "spin ID string column", 
273      desc = "The spin ID string column used by the generic intensity file format (an alternative to the mol, res, and spin name and number columns).", 
274      can_be_none = True 
275  ) 
276  uf.add_keyarg( 
277      name = "mol_name_col", 
278      py_type = "int", 
279      arg_type = "free format", 
280      desc_short = "molecule name column", 
281      desc = "The molecule name column used by the generic intensity file format (alternative to the spin ID column).", 
282      can_be_none = True 
283  ) 
284  uf.add_keyarg( 
285      name = "res_num_col", 
286      py_type = "int", 
287      arg_type = "free format", 
288      desc_short = "residue number column", 
289      desc = "The residue number column used by the generic intensity file format (alternative to the spin ID column).", 
290      can_be_none = True 
291  ) 
292  uf.add_keyarg( 
293      name = "res_name_col", 
294      py_type = "int", 
295      arg_type = "free format", 
296      desc_short = "residue name column", 
297      desc = "The residue name column used by the generic intensity file format (alternative to the spin ID column).", 
298      can_be_none = True 
299  ) 
300  uf.add_keyarg( 
301      name = "spin_num_col", 
302      py_type = "int", 
303      arg_type = "free format", 
304      desc_short = "spin number column", 
305      desc = "The spin number column used by the generic intensity file format (alternative to the spin ID column).", 
306      can_be_none = True 
307  ) 
308  uf.add_keyarg( 
309      name = "spin_name_col", 
310      py_type = "int", 
311      arg_type = "free format", 
312      desc_short = "spin name column", 
313      desc = "The spin name column used by the generic intensity file format (alternative to the spin ID column).", 
314      can_be_none = True 
315  ) 
316  uf.add_keyarg( 
317      name = "sep", 
318      py_type = "str", 
319      arg_type = "free format", 
320      desc_short = "column separator", 
321      desc = "The column separator used by the generic intensity format (the default is white space).", 
322      can_be_none = True 
323  ) 
324  uf.add_keyarg( 
325      name = "spin_id", 
326      py_type = "str", 
327      desc_short = "spin ID string", 
328      desc = "The spin ID string used to restrict the loading of data to certain spin subsets.", 
329      can_be_none = True 
330  ) 
331  uf.add_keyarg( 
332      name = "ncproc", 
333      py_type = "int", 
334      desc_short = "Bruker ncproc parameter", 
335      desc = "The Bruker specific FID intensity scaling factor.", 
336      can_be_none = True 
337  ) 
338  # Description. 
339  uf.desc.append(Desc_container()) 
340  uf.desc[-1].add_paragraph("The peak intensity can either be from peak heights or peak volumes.") 
341  uf.desc[-1].add_paragraph("The spectrum ID is a label which is subsequently utilised by other user functions.  If this identifier matches that of a previously loaded set of intensities, then this indicates a replicated spectrum.") 
342  uf.desc[-1].add_paragraph("The spectral dimension is used to specify if the intensity data should be loaded into the spins identified by the first dimension w1, second dimension w2, etc.") 
343  uf.desc[-1].add_paragraph("The integration method is required for the subsequent error analysis.  When peak heights are measured, this should be set to 'height'.  Volume integration methods are a bit varied and hence two values are accepted.  If the volume integration involves pure point summation, with no deconvolution algorithms or other methods affecting peak heights, then the value should be set to 'point sum'.  All other volume integration methods, e.g. line shape fitting, the value should be set to 'other'.") 
344  uf.desc[-1].add_paragraph("If a series of intensities extracted from Bruker FID files processed in Topspin or XWinNMR are to be compared, the ncproc parameter may need to be supplied.  This is because this FID is stored using integer representation and is scaled using ncproc to avoid numerical truncation artifacts.  If two spectra have significantly different maximal intensities, then ncproc will be different for both.  The intensity scaling is binary, i.e. 2**ncproc. Therefore if spectrum A has an ncproc of 6 and and spectrum B a value of 7, then a reference intensity in B will be double that of A.  Internally, relax stores the intensities scaled by 2**ncproc.") 
345  # File formats. 
346  uf.desc.append(Desc_container("File formats")) 
347  uf.desc[-1].add_paragraph("The peak list or intensity file will be automatically determined.") 
348  uf.desc[-1].add_paragraph("Sparky peak list:  The file should be a Sparky peak list saved after typing the command 'lt'.  The default is to assume that columns 0, 1, 2, and 3 (1st, 2nd, 3rd, and 4th) contain the Sparky assignment, w1, w2, and peak intensity data respectively.  The frequency data w1 and w2 are ignored while the peak intensity data can either be the peak height or volume displayed by changing the window options.  If the peak intensity data is not within column 3, set the integration column to the appropriate number (column numbering starts from 0 rather than 1).") 
349  uf.desc[-1].add_paragraph("XEasy peak list:  The file should be the saved XEasy text window output of the list peak entries command, 'tw' followed by 'le'.  As the columns are fixed, the peak intensity column is hardwired to number 10 (the 11th column) which contains either the peak height or peak volume data.  Because the columns are fixed, the integration column number will be ignored.") 
350  uf.desc[-1].add_paragraph("NMRView:  The file should be a NMRView peak list. The default is to use column 16 (which contains peak heights) for peak intensities. To use use peak volumes (or evolumes), int_col must be set to 15.") 
351  uf.desc[-1].add_paragraph("NMRPipe seriesTab:  The file should be a NMRPipe-format Spectral Series list.  If the spectrum_id='auto', the IDs are auto generated in form of Z_A{i}.") 
352  uf.desc[-1].add_paragraph("Generic intensity file:  This is a generic format which can be created by scripting to support non-supported peak lists.  It should contain in the first few columns enough information to identify the spin.  This can include columns for the molecule name, residue number, residue name, spin number, and spin name.  Alternatively a spin ID string column can be used. The peak intensities can be placed in another column specified by the integration column number.  Intensities from multiple spectra can be placed into different columns, and these can then be specified simultaneously by setting the integration column value to a list of columns.  This list must be matched by setting the spectrum ID to a list of the same length.  If columns are delimited by a character other than whitespace, this can be specified with the column separator.  The spin ID can be used to restrict the loading to specific spin subsets.") 
353  uf.desc.append(Desc_container("Multiple files")) 
354  uf.desc[-1].add_paragraph("The data from multiple files can be loaded simultaneously if a list of files is supplied.  In this case, a list of spectrum ID strings of equal length must be supplied.") 
355  # Prompt examples. 
356  uf.desc.append(Desc_container("Prompt examples")) 
357  uf.desc[-1].add_paragraph("To read the reference and saturated spectra peak heights from the Sparky formatted files 'ref.list' and 'sat.list', type:") 
358  uf.desc[-1].add_prompt("relax> spectrum.read_intensities(file='ref.list', spectrum_id='ref')") 
359  uf.desc[-1].add_prompt("relax> spectrum.read_intensities(file='sat.list', spectrum_id='sat')") 
360  uf.desc[-1].add_paragraph("To read the reference and saturated spectra peak heights from the XEasy formatted files 'ref.text' and 'sat.text', type:") 
361  uf.desc[-1].add_prompt("relax> spectrum.read_intensities(file='ref.text', spectrum_id='ref')") 
362  uf.desc[-1].add_prompt("relax> spectrum.read_intensities(file='sat.text', spectrum_id='sat')") 
363  uf.backend = spectrum.read 
364  uf.menu_text = "&read_intensities" 
365  uf.gui_icon = "oxygen.actions.document-open" 
366  uf.wizard_height_desc = 300 
367  uf.wizard_size = (1000, 750) 
368  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
369   
370   
371  # The spectrum.read_spins user function. 
372  uf = uf_info.add_uf('spectrum.read_spins') 
373  uf.title = "Read peak assignments from a file and create spins." 
374  uf.title_short = "Peak assignments reading." 
375  uf.add_keyarg( 
376      name = "file", 
377      py_type = "str", 
378      arg_type = "file sel", 
379      desc_short = "file name", 
380      desc = "The name of the file containing the intensity data.", 
381      wiz_filesel_wildcard = WILDCARD_SPECTRUM_PEAKLIST, 
382      wiz_filesel_style = FD_OPEN 
383  ) 
384  uf.add_keyarg( 
385      name = "dir", 
386      py_type = "str", 
387      arg_type = "dir", 
388      desc_short = "directory name", 
389      desc = "The directory where the file is located.", 
390      can_be_none = True 
391  ) 
392  uf.add_keyarg( 
393      name = "dim", 
394      default = 1, 
395      py_type = "int", 
396      min = 1, 
397      desc_short = "spectral dimension to read", 
398      desc = "Associate the data with the spins of any dimension in the peak list.  This defaults to w1, the heteronucleus in HSQC type experiments." 
399  ) 
400  uf.add_keyarg( 
401      name = "spin_id_col", 
402      py_type = "int", 
403      arg_type = "free format", 
404      desc_short = "spin ID string column", 
405      desc = "The spin ID string column used by the generic intensity file format (an alternative to the mol, res, and spin name and number columns).", 
406      can_be_none = True 
407  ) 
408  uf.add_keyarg( 
409      name = "mol_name_col", 
410      py_type = "int", 
411      arg_type = "free format", 
412      desc_short = "molecule name column", 
413      desc = "The molecule name column used by the generic intensity file format (alternative to the spin ID column).", 
414      can_be_none = True 
415  ) 
416  uf.add_keyarg( 
417      name = "res_num_col", 
418      py_type = "int", 
419      arg_type = "free format", 
420      desc_short = "residue number column", 
421      desc = "The residue number column used by the generic intensity file format (alternative to the spin ID column).", 
422      can_be_none = True 
423  ) 
424  uf.add_keyarg( 
425      name = "res_name_col", 
426      py_type = "int", 
427      arg_type = "free format", 
428      desc_short = "residue name column", 
429      desc = "The residue name column used by the generic intensity file format (alternative to the spin ID column).", 
430      can_be_none = True 
431  ) 
432  uf.add_keyarg( 
433      name = "spin_num_col", 
434      py_type = "int", 
435      arg_type = "free format", 
436      desc_short = "spin number column", 
437      desc = "The spin number column used by the generic intensity file format (alternative to the spin ID column).", 
438      can_be_none = True 
439  ) 
440  uf.add_keyarg( 
441      name = "spin_name_col", 
442      py_type = "int", 
443      arg_type = "free format", 
444      desc_short = "spin name column", 
445      desc = "The spin name column used by the generic intensity file format (alternative to the spin ID column).", 
446      can_be_none = True 
447  ) 
448  uf.add_keyarg( 
449      name = "sep", 
450      py_type = "str", 
451      arg_type = "free format", 
452      desc_short = "column separator", 
453      desc = "The column separator used by the generic intensity format (the default is white space).", 
454      can_be_none = True 
455  ) 
456  uf.add_keyarg( 
457      name = "spin_id", 
458      py_type = "str", 
459      desc_short = "spin ID string", 
460      desc = "The spin ID string used to restrict the loading of data to certain spin subsets.", 
461      can_be_none = True 
462  ) 
463  # Description. 
464  uf.desc.append(Desc_container()) 
465  uf.desc[-1].add_paragraph("The spectral dimension is used to specify if the intensity data should be loaded into the spins identified by the first dimension w1, second dimension w2, etc.") 
466  # File formats. 
467  uf.desc.append(Desc_container("File formats")) 
468  uf.desc[-1].add_paragraph("The peak list or intensity file will be automatically determined.") 
469  uf.desc[-1].add_paragraph("Sparky peak list:  The file should be a Sparky peak list saved after typing the command 'lt'.  The default is to assume that columns 0, 1, 2, and 3 (1st, 2nd, 3rd, and 4th) contain the Sparky assignment, w1, w2, and peak intensity data respectively.  The frequency data w1 and w2 are ignored while the peak intensity data can either be the peak height or volume displayed by changing the window options.  If the peak intensity data is not within column 3, set the integration column to the appropriate number (column numbering starts from 0 rather than 1).") 
470  uf.desc[-1].add_paragraph("XEasy peak list:  The file should be the saved XEasy text window output of the list peak entries command, 'tw' followed by 'le'.  As the columns are fixed, the peak intensity column is hardwired to number 10 (the 11th column) which contains either the peak height or peak volume data.  Because the columns are fixed, the integration column number will be ignored.") 
471  uf.desc[-1].add_paragraph("NMRView:  The file should be a NMRView peak list. The default is to use column 16 (which contains peak heights) for peak intensities. To use use peak volumes (or evolumes), int_col must be set to 15.") 
472  uf.desc[-1].add_paragraph("NMRPipe seriesTab:  The file should be a NMRPipe-format Spectral Series list.  If the spectrum_id='auto', the IDs are auto generated in form of Z_A{i}.") 
473  uf.desc[-1].add_paragraph("Generic intensity file:  This is a generic format which can be created by scripting to support non-supported peak lists.  It should contain in the first few columns enough information to identify the spin.  This can include columns for the molecule name, residue number, residue name, spin number, and spin name.  Alternatively a spin ID string column can be used. The peak intensities can be placed in another column specified by the integration column number.  Intensities from multiple spectra can be placed into different columns, and these can then be specified simultaneously by setting the integration column value to a list of columns.  This list must be matched by setting the spectrum ID to a list of the same length.  If columns are delimited by a character other than whitespace, this can be specified with the column separator.  The spin ID can be used to restrict the loading to specific spin subsets.") 
474  # Prompt examples. 
475  uf.desc.append(Desc_container("Prompt examples")) 
476  uf.desc[-1].add_paragraph("To read the spin assignments from the Sparky formatted files 'ref.list' and 'sat.list', type:") 
477  uf.desc[-1].add_prompt("relax> spectrum.read_spins(file='ref.list')") 
478  uf.desc[-1].add_prompt("relax> spectrum.read_spins(file='sat.list')") 
479  uf.desc[-1].add_paragraph("To read the spin assignments from the XEasy formatted files 'ref.text' and 'sat.text', type:") 
480  uf.desc[-1].add_prompt("relax> spectrum.read_spins(file='ref.text')") 
481  uf.desc[-1].add_prompt("relax> spectrum.read_spins(file='sat.text')") 
482  uf.backend = spectrum.read_spins 
483  uf.menu_text = "&read_spins" 
484  uf.gui_icon = "oxygen.actions.document-open" 
485  uf.wizard_height_desc = 300 
486  uf.wizard_size = (1000, 750) 
487  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
488   
489   
490  # The spectrum.replicated user function. 
491  uf = uf_info.add_uf('spectrum.replicated') 
492  uf.title = "Specify which spectra are replicates of each other." 
493  uf.title_short = "Replicate spectra." 
494  uf.add_keyarg( 
495      name = "spectrum_ids", 
496      py_type = "str_or_str_list", 
497      desc_short = "spectrum ID strings", 
498      desc = "The list of replicated spectra ID strings.", 
499      wiz_element_type = 'combo_list', 
500      wiz_combo_iter = spectrum.get_ids, 
501      wiz_combo_list_min = 2, 
502      wiz_read_only = True 
503  ) 
504  # Description. 
505  uf.desc.append(Desc_container()) 
506  uf.desc[-1].add_paragraph("This is used to identify which of the loaded spectra are replicates of each other.  Specifying the replicates is essential for error analysis if the baseplane RMSD has not been supplied.") 
507  # Prompt examples. 
508  uf.desc.append(Desc_container("Prompt examples")) 
509  uf.desc[-1].add_paragraph("To specify that the NOE spectra labelled 'ref1', 'ref2', and 'ref3' are the same spectrum replicated, type one of:") 
510  uf.desc[-1].add_prompt("relax> spectrum.replicated(['ref1', 'ref2', 'ref3'])") 
511  uf.desc[-1].add_prompt("relax> spectrum.replicated(spectrum_ids=['ref1', 'ref2', 'ref3'])") 
512  uf.desc[-1].add_paragraph("To specify that the two R2 spectra 'ncyc2' and 'ncyc2b' are the same time point, type:") 
513  uf.desc[-1].add_prompt("relax> spectrum.replicated(['ncyc2', 'ncyc2b'])") 
514  uf.backend = spectrum.replicated 
515  uf.menu_text = "re&plicated" 
516  uf.gui_icon = "oxygen.actions.edit-rename" 
517  uf.wizard_size = (700, 500) 
518  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
519