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   
 41   
 42  # The user function class. 
 43  uf_class = uf_info.add_class('spectrum') 
 44  uf_class.title = "Class for supporting the input of spectral data." 
 45  uf_class.menu_text = "&spectrum" 
 46  uf_class.gui_icon = "relax.fid" 
 47   
 48   
 49  # The spectrum.baseplane_rmsd user function. 
 50  uf = uf_info.add_uf('spectrum.baseplane_rmsd') 
 51  uf.title = "Set the baseplane RMSD of a given spin in a spectrum for error analysis." 
 52  uf.title_short = "Baseplane RMSD setting." 
 53  uf.add_keyarg( 
 54      name = "error", 
 55      default = 0.0, 
 56      py_type = "num", 
 57      desc_short = "error", 
 58      desc = "The baseplane RMSD error value." 
 59  ) 
 60  uf.add_keyarg( 
 61      name = "spectrum_id", 
 62      py_type = "str", 
 63      desc_short = "spectrum ID string", 
 64      desc = "The spectrum ID string.", 
 65      wiz_element_type = 'combo', 
 66      wiz_combo_iter = spectrum.get_ids, 
 67      wiz_read_only = True 
 68  ) 
 69  uf.add_keyarg( 
 70      name = "spin_id", 
 71      py_type = "str", 
 72      desc_short = "spin ID string", 
 73      desc = "The spin ID string.", 
 74      can_be_none = True 
 75  ) 
 76  # Description. 
 77  uf.desc.append(Desc_container()) 
 78  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.") 
 79  uf.backend = spectrum.baseplane_rmsd 
 80  uf.menu_text = "&baseplane_rmsd" 
 81  uf.gui_icon = "oxygen.actions.edit-rename" 
 82  uf.wizard_size = (800, 500) 
 83  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
 84   
 85   
 86  # The spectrum.delete user function. 
 87  uf = uf_info.add_uf('spectrum.delete') 
 88  uf.title = "Delete the spectral data corresponding to the spectrum ID string." 
 89  uf.title_short = "Spectral data deletion." 
 90  uf.add_keyarg( 
 91      name = "spectrum_id", 
 92      py_type = "str", 
 93      desc_short = "spectrum ID string", 
 94      desc = "The unique spectrum ID string.", 
 95      wiz_element_type = 'combo', 
 96      wiz_combo_iter = spectrum.get_ids, 
 97      wiz_read_only = True 
 98  ) 
 99  # Description. 
100  uf.desc.append(Desc_container()) 
101  uf.desc[-1].add_paragraph("The spectral data corresponding to the given spectrum ID string will be removed from the current data pipe.") 
102  # Prompt examples. 
103  uf.desc.append(Desc_container("Prompt examples")) 
104  uf.desc[-1].add_paragraph("To delete the peak height data corresponding to the ID 'R1 ncyc5', type:") 
105  uf.desc[-1].add_prompt("relax> spectrum.delete('R1 ncyc5')") 
106  uf.backend = spectrum.delete 
107  uf.menu_text = "&delete" 
108  uf.gui_icon = "oxygen.actions.list-remove" 
109  uf.wizard_size = (700, 400) 
110  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
111   
112   
113  # The spectrum.error_analysis user function. 
114  uf = uf_info.add_uf('spectrum.error_analysis') 
115  uf.title = "Perform an error analysis for peak intensities." 
116  uf.title_short = "Peak intensity error analysis." 
117  uf.add_keyarg( 
118      name = "subset", 
119      py_type = "str_list", 
120      desc_short = "subset spectrum IDs", 
121      desc = "The list of spectrum ID strings to restrict the error analysis to.", 
122      wiz_combo_iter = spectrum.get_ids, 
123      wiz_read_only = True, 
124      can_be_none = True 
125  ) 
126  # Description. 
127  uf.desc.append(Desc_container()) 
128  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.") 
129  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.") 
130  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:") 
131  table = uf_tables.add_table(label="table: peak intensity error analysis", caption="The six peak intensity error analysis types.") 
132  table.add_headings(["Int type", "Noise source", "Error scope"]) 
133  table.add_row(["Heights", "RMSD baseplane", "One sigma per peak per spectrum"]) 
134  table.add_row(["Heights", "Partial duplicate + variance averaging", "One sigma for all peaks, all spectra"]) 
135  table.add_row(["Heights", "All replicated + variance averaging", "One sigma per replicated spectra set"]) 
136  table.add_row(["Volumes", "RMSD baseplane", "One sigma per peak per spectrum"]) 
137  table.add_row(["Volumes", "Partial duplicate + variance averaging", "One sigma for all peaks, all spectra"]) 
138  table.add_row(["Volumes", "All replicated + variance averaging", "One sigma per replicated spectra set"]) 
139  uf.desc[-1].add_table(table.label) 
140  # Peak heights with baseplane noise RMSD. 
141  uf.desc.append(Desc_container("Peak heights with baseplane noise RMSD")) 
142  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.") 
143  # Peak heights with partially replicated spectra. 
144  uf.desc.append(Desc_container("Peak heights with partially replicated spectra")) 
145  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") 
146  uf.desc[-1].add_item_list_element(None, "sigma^2 =  sum({Ii - Iav}^2) / (n - 1),") 
147  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.") 
148  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.") 
149  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.") 
150  # Peak heights with all spectra replicated. 
151  uf.desc.append(Desc_container("Peak heights with all spectra replicated")) 
152  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.") 
153  # Peak volumes with baseplane noise RMSD. 
154  uf.desc.append(Desc_container("Peak volumes with baseplane noise RMSD")) 
155  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:") 
156  uf.desc[-1].add_item_list_element(None, "sigma_vol^2 = sigma_i^2 * N,") 
157  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:") 
158  uf.desc[-1].add_item_list_element(None, "sigma_vol = sigma_i * sqrt(n*m),") 
159  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.") 
160  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.") 
161  # Peak volumes with partially replicated spectra. 
162  uf.desc.append(Desc_container("Peak volumes with partially replicated spectra")) 
163  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.") 
164  # Peak volumes with all spectra replicated. 
165  uf.desc.append(Desc_container("Peak volumes with all spectra replicated")) 
166  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.") 
167  uf.backend = spectrum.error_analysis 
168  uf.menu_text = "&error_analysis" 
169  uf.gui_icon = "oxygen.categories.applications-education" 
170  uf.wizard_height_desc = 530 
171  uf.wizard_size = (1000, 700) 
172  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
173  uf.wizard_apply_button = False 
174   
175   
176  # The spectrum.integration_points user function. 
177  uf = uf_info.add_uf('spectrum.integration_points') 
178  uf.title = "Set the number of summed points used in volume integration of a given spin in a spectrum." 
179  uf.title_short = "Number of integration points." 
180  uf.add_keyarg( 
181      name = "N", 
182      py_type = "int", 
183      min = 1, 
184      max = 10000000, 
185      desc_short = "number of summed points", 
186      desc = "The number of points used by the summation volume integration method." 
187  ) 
188  uf.add_keyarg( 
189      name = "spectrum_id", 
190      py_type = "str", 
191      desc_short = "spectrum ID string", 
192      desc = "The spectrum ID string.", 
193      wiz_element_type = 'combo', 
194      wiz_combo_iter = spectrum.get_ids, 
195      wiz_read_only = True 
196  ) 
197  uf.add_keyarg( 
198      name = "spin_id", 
199      py_type = "str", 
200      desc_short = "spin ID string", 
201      desc = "Restrict setting the number to certain spins.", 
202      can_be_none = True 
203  ) 
204  # Description. 
205  uf.desc.append(Desc_container()) 
206  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.") 
207  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.") 
208  uf.backend = spectrum.integration_points 
209  uf.menu_text = "&integration_points" 
210  uf.gui_icon = "oxygen.actions.edit-rename" 
211  uf.wizard_size = (900, 600) 
212  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
213   
214   
215  # The spectrum.read_intensities user function. 
216  uf = uf_info.add_uf('spectrum.read_intensities') 
217  uf.title = "Read peak intensities from a file." 
218  uf.title_short = "Peak intensity reading." 
219  uf.add_keyarg( 
220      name = "file", 
221      py_type = "str_or_str_list", 
222      arg_type = "file sel multi", 
223      desc_short = "file name(s)", 
224      desc = "The name of the file or the list of files containing the intensity data.", 
225      wiz_filesel_style = FD_OPEN 
226  ) 
227  uf.add_keyarg( 
228      name = "dir", 
229      py_type = "str", 
230      arg_type = "dir", 
231      desc_short = "directory name", 
232      desc = "The directory where the file is located.", 
233      can_be_none = True 
234  ) 
235  uf.add_keyarg( 
236      name = "spectrum_id", 
237      py_type = "str_or_str_list", 
238      desc_short = "spectrum ID string", 
239      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}." 
240  ) 
241  uf.add_keyarg( 
242      name = "dim", 
243      default = 1, 
244      py_type = "int", 
245      min = 1, 
246      desc_short = "spectral dimension to read", 
247      desc = "Associate the data with the spins of any dimension in the peak list.  This defaults to w1, the heteronucleus in HSQC type experiments." 
248  ) 
249  uf.add_keyarg( 
250      name = "int_method", 
251      default = "height", 
252      py_type = "str", 
253      desc_short = "peak integration method", 
254      desc = "The method by which peaks were integrated.", 
255      wiz_element_type = "combo", 
256      wiz_combo_choices = ["height", "point sum", "other"], 
257      wiz_read_only = True 
258  ) 
259  uf.add_keyarg( 
260      name = "int_col", 
261      py_type = "int_or_int_list", 
262      desc_short = "intensity column", 
263      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).", 
264      can_be_none = True 
265  ) 
266  uf.add_keyarg( 
267      name = "spin_id_col", 
268      py_type = "int", 
269      arg_type = "free format", 
270      desc_short = "spin ID string column", 
271      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).", 
272      can_be_none = True 
273  ) 
274  uf.add_keyarg( 
275      name = "mol_name_col", 
276      py_type = "int", 
277      arg_type = "free format", 
278      desc_short = "molecule name column", 
279      desc = "The molecule name column used by the generic intensity file format (alternative to the spin ID column).", 
280      can_be_none = True 
281  ) 
282  uf.add_keyarg( 
283      name = "res_num_col", 
284      py_type = "int", 
285      arg_type = "free format", 
286      desc_short = "residue number column", 
287      desc = "The residue number column used by the generic intensity file format (alternative to the spin ID column).", 
288      can_be_none = True 
289  ) 
290  uf.add_keyarg( 
291      name = "res_name_col", 
292      py_type = "int", 
293      arg_type = "free format", 
294      desc_short = "residue name column", 
295      desc = "The residue name column used by the generic intensity file format (alternative to the spin ID column).", 
296      can_be_none = True 
297  ) 
298  uf.add_keyarg( 
299      name = "spin_num_col", 
300      py_type = "int", 
301      arg_type = "free format", 
302      desc_short = "spin number column", 
303      desc = "The spin number column used by the generic intensity file format (alternative to the spin ID column).", 
304      can_be_none = True 
305  ) 
306  uf.add_keyarg( 
307      name = "spin_name_col", 
308      py_type = "int", 
309      arg_type = "free format", 
310      desc_short = "spin name column", 
311      desc = "The spin name column used by the generic intensity file format (alternative to the spin ID column).", 
312      can_be_none = True 
313  ) 
314  uf.add_keyarg( 
315      name = "sep", 
316      py_type = "str", 
317      arg_type = "free format", 
318      desc_short = "column separator", 
319      desc = "The column separator used by the generic intensity format (the default is white space).", 
320      can_be_none = True 
321  ) 
322  uf.add_keyarg( 
323      name = "spin_id", 
324      py_type = "str", 
325      desc_short = "spin ID string", 
326      desc = "The spin ID string used to restrict the loading of data to certain spin subsets.", 
327      can_be_none = True 
328  ) 
329  uf.add_keyarg( 
330      name = "ncproc", 
331      py_type = "int", 
332      desc_short = "Bruker ncproc parameter", 
333      desc = "The Bruker specific FID intensity scaling factor.", 
334      can_be_none = True 
335  ) 
336  # Description. 
337  uf.desc.append(Desc_container()) 
338  uf.desc[-1].add_paragraph("The peak intensity can either be from peak heights or peak volumes.") 
339  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.") 
340  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.") 
341  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'.") 
342  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.") 
343  # File formats. 
344  uf.desc.append(Desc_container("File formats")) 
345  uf.desc[-1].add_paragraph("The peak list or intensity file will be automatically determined.") 
346  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).") 
347  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.") 
348  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.") 
349  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}.") 
350  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.") 
351  uf.desc.append(Desc_container("Multiple files")) 
352  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.") 
353  # Prompt examples. 
354  uf.desc.append(Desc_container("Prompt examples")) 
355  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:") 
356  uf.desc[-1].add_prompt("relax> spectrum.read_intensities(file='ref.list', spectrum_id='ref')") 
357  uf.desc[-1].add_prompt("relax> spectrum.read_intensities(file='sat.list', spectrum_id='sat')") 
358  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:") 
359  uf.desc[-1].add_prompt("relax> spectrum.read_intensities(file='ref.text', spectrum_id='ref')") 
360  uf.desc[-1].add_prompt("relax> spectrum.read_intensities(file='sat.text', spectrum_id='sat')") 
361  uf.backend = spectrum.read 
362  uf.menu_text = "&read_intensities" 
363  uf.gui_icon = "oxygen.actions.document-open" 
364  uf.wizard_height_desc = 300 
365  uf.wizard_size = (1000, 750) 
366  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
367   
368   
369  # The spectrum.read_spins user function. 
370  uf = uf_info.add_uf('spectrum.read_spins') 
371  uf.title = "Read peak assignments from a file and create spins." 
372  uf.title_short = "Peak assignments reading." 
373  uf.add_keyarg( 
374      name = "file", 
375      py_type = "str", 
376      arg_type = "file sel", 
377      desc_short = "file name", 
378      desc = "The name of the file containing the intensity data.", 
379      wiz_filesel_style = FD_OPEN 
380  ) 
381  uf.add_keyarg( 
382      name = "dir", 
383      py_type = "str", 
384      arg_type = "dir", 
385      desc_short = "directory name", 
386      desc = "The directory where the file is located.", 
387      can_be_none = True 
388  ) 
389  uf.add_keyarg( 
390      name = "dim", 
391      default = 1, 
392      py_type = "int", 
393      min = 1, 
394      desc_short = "spectral dimension to read", 
395      desc = "Associate the data with the spins of any dimension in the peak list.  This defaults to w1, the heteronucleus in HSQC type experiments." 
396  ) 
397  uf.add_keyarg( 
398      name = "spin_id_col", 
399      py_type = "int", 
400      arg_type = "free format", 
401      desc_short = "spin ID string column", 
402      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).", 
403      can_be_none = True 
404  ) 
405  uf.add_keyarg( 
406      name = "mol_name_col", 
407      py_type = "int", 
408      arg_type = "free format", 
409      desc_short = "molecule name column", 
410      desc = "The molecule name column used by the generic intensity file format (alternative to the spin ID column).", 
411      can_be_none = True 
412  ) 
413  uf.add_keyarg( 
414      name = "res_num_col", 
415      py_type = "int", 
416      arg_type = "free format", 
417      desc_short = "residue number column", 
418      desc = "The residue number column used by the generic intensity file format (alternative to the spin ID column).", 
419      can_be_none = True 
420  ) 
421  uf.add_keyarg( 
422      name = "res_name_col", 
423      py_type = "int", 
424      arg_type = "free format", 
425      desc_short = "residue name column", 
426      desc = "The residue name column used by the generic intensity file format (alternative to the spin ID column).", 
427      can_be_none = True 
428  ) 
429  uf.add_keyarg( 
430      name = "spin_num_col", 
431      py_type = "int", 
432      arg_type = "free format", 
433      desc_short = "spin number column", 
434      desc = "The spin number column used by the generic intensity file format (alternative to the spin ID column).", 
435      can_be_none = True 
436  ) 
437  uf.add_keyarg( 
438      name = "spin_name_col", 
439      py_type = "int", 
440      arg_type = "free format", 
441      desc_short = "spin name column", 
442      desc = "The spin name column used by the generic intensity file format (alternative to the spin ID column).", 
443      can_be_none = True 
444  ) 
445  uf.add_keyarg( 
446      name = "sep", 
447      py_type = "str", 
448      arg_type = "free format", 
449      desc_short = "column separator", 
450      desc = "The column separator used by the generic intensity format (the default is white space).", 
451      can_be_none = True 
452  ) 
453  uf.add_keyarg( 
454      name = "spin_id", 
455      py_type = "str", 
456      desc_short = "spin ID string", 
457      desc = "The spin ID string used to restrict the loading of data to certain spin subsets.", 
458      can_be_none = True 
459  ) 
460  # Description. 
461  uf.desc.append(Desc_container()) 
462  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.") 
463  # File formats. 
464  uf.desc.append(Desc_container("File formats")) 
465  uf.desc[-1].add_paragraph("The peak list or intensity file will be automatically determined.") 
466  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).") 
467  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.") 
468  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.") 
469  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}.") 
470  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.") 
471  # Prompt examples. 
472  uf.desc.append(Desc_container("Prompt examples")) 
473  uf.desc[-1].add_paragraph("To read the spin assignments from the Sparky formatted files 'ref.list' and 'sat.list', type:") 
474  uf.desc[-1].add_prompt("relax> spectrum.read_spins(file='ref.list')") 
475  uf.desc[-1].add_prompt("relax> spectrum.read_spins(file='sat.list')") 
476  uf.desc[-1].add_paragraph("To read the spin assignments from the XEasy formatted files 'ref.text' and 'sat.text', type:") 
477  uf.desc[-1].add_prompt("relax> spectrum.read_spins(file='ref.text')") 
478  uf.desc[-1].add_prompt("relax> spectrum.read_spins(file='sat.text')") 
479  uf.backend = spectrum.read_spins 
480  uf.menu_text = "&read_spins" 
481  uf.gui_icon = "oxygen.actions.document-open" 
482  uf.wizard_height_desc = 300 
483  uf.wizard_size = (1000, 750) 
484  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
485   
486   
487  # The spectrum.replicated user function. 
488  uf = uf_info.add_uf('spectrum.replicated') 
489  uf.title = "Specify which spectra are replicates of each other." 
490  uf.title_short = "Replicate spectra." 
491  uf.add_keyarg( 
492      name = "spectrum_ids", 
493      py_type = "str_or_str_list", 
494      desc_short = "spectrum ID strings", 
495      desc = "The list of replicated spectra ID strings.", 
496      wiz_element_type = 'combo_list', 
497      wiz_combo_iter = spectrum.get_ids, 
498      wiz_combo_list_min = 2, 
499      wiz_read_only = True 
500  ) 
501  # Description. 
502  uf.desc.append(Desc_container()) 
503  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.") 
504  # Prompt examples. 
505  uf.desc.append(Desc_container("Prompt examples")) 
506  uf.desc[-1].add_paragraph("To specify that the NOE spectra labelled 'ref1', 'ref2', and 'ref3' are the same spectrum replicated, type one of:") 
507  uf.desc[-1].add_prompt("relax> spectrum.replicated(['ref1', 'ref2', 'ref3'])") 
508  uf.desc[-1].add_prompt("relax> spectrum.replicated(spectrum_ids=['ref1', 'ref2', 'ref3'])") 
509  uf.desc[-1].add_paragraph("To specify that the two R2 spectra 'ncyc2' and 'ncyc2b' are the same time point, type:") 
510  uf.desc[-1].add_prompt("relax> spectrum.replicated(['ncyc2', 'ncyc2b'])") 
511  uf.backend = spectrum.replicated 
512  uf.menu_text = "re&plicated" 
513  uf.gui_icon = "oxygen.actions.edit-rename" 
514  uf.wizard_size = (700, 500) 
515  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
516