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

Source Code for Module user_functions.spectrum

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2004-2005,2008-2014,2019 Edward d'Auvergne                    # 
  4  # Copyright (C) 2008 Sebastien Morin                                          # 
  5  # Copyright (C) 2013-2014 Troels E. Linnet                                    # 
  6  #                                                                             # 
  7  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  8  #                                                                             # 
  9  # This program is free software: you can redistribute it and/or modify        # 
 10  # it under the terms of the GNU General Public License as published by        # 
 11  # the Free Software Foundation, either version 3 of the License, or           # 
 12  # (at your option) any later version.                                         # 
 13  #                                                                             # 
 14  # This program is distributed in the hope that it will be useful,             # 
 15  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 16  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 17  # GNU General Public License for more details.                                # 
 18  #                                                                             # 
 19  # You should have received a copy of the GNU General Public License           # 
 20  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 21  #                                                                             # 
 22  ############################################################################### 
 23   
 24  # Module docstring. 
 25  """The spectrum user function definitions.""" 
 26   
 27  # Python module imports. 
 28  from os import sep 
 29   
 30  # relax module imports. 
 31  from graphics import WIZARD_IMAGE_PATH 
 32  from pipe_control import spectrum 
 33  from user_functions.data import Uf_info; uf_info = Uf_info() 
 34  from user_functions.data import Uf_tables; uf_tables = Uf_tables() 
 35  from user_functions.objects import Desc_container 
 36  from user_functions.wildcards import WILDCARD_SPECTRUM_PEAKLIST 
 37   
 38   
 39  # The user function class. 
 40  uf_class = uf_info.add_class('spectrum') 
 41  uf_class.title = "Class for supporting the input of spectral data." 
 42  uf_class.menu_text = "&spectrum" 
 43  uf_class.gui_icon = "relax.fid" 
 44   
 45   
 46  # The spectrum.baseplane_rmsd user function. 
 47  uf = uf_info.add_uf('spectrum.baseplane_rmsd') 
 48  uf.title = "Set the baseplane RMSD of a given spin in a spectrum for error analysis." 
 49  uf.title_short = "Baseplane RMSD setting." 
 50  uf.add_keyarg( 
 51      name = "error", 
 52      default = 0.0, 
 53      basic_types = ["number"], 
 54      desc_short = "error", 
 55      desc = "The baseplane RMSD error value." 
 56  ) 
 57  uf.add_keyarg( 
 58      name = "spectrum_id", 
 59      basic_types = ["str"], 
 60      desc_short = "spectrum ID string", 
 61      desc = "The spectrum ID string.", 
 62      wiz_element_type = 'combo', 
 63      wiz_combo_iter = spectrum.get_ids, 
 64      wiz_read_only = True 
 65  ) 
 66  uf.add_keyarg( 
 67      name = "spin_id", 
 68      basic_types = ["str"], 
 69      desc_short = "spin ID string", 
 70      desc = "The spin ID string.", 
 71      can_be_none = True 
 72  ) 
 73  # Description. 
 74  uf.desc.append(Desc_container()) 
 75  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.") 
 76  uf.backend = spectrum.baseplane_rmsd 
 77  uf.menu_text = "&baseplane_rmsd" 
 78  uf.gui_icon = "oxygen.actions.edit-rename" 
 79  uf.wizard_size = (800, 500) 
 80  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
 81   
 82   
 83  # The spectrum.delete user function. 
 84  uf = uf_info.add_uf('spectrum.delete') 
 85  uf.title = "Delete the spectral data corresponding to the spectrum ID string." 
 86  uf.title_short = "Spectral data deletion." 
 87  uf.add_keyarg( 
 88      name = "spectrum_id", 
 89      basic_types = ["str"], 
 90      desc_short = "spectrum ID string", 
 91      desc = "The unique spectrum ID string.", 
 92      wiz_element_type = 'combo', 
 93      wiz_combo_iter = spectrum.get_ids, 
 94      wiz_read_only = True 
 95  ) 
 96  # Description. 
 97  uf.desc.append(Desc_container()) 
 98  uf.desc[-1].add_paragraph("The spectral data corresponding to the given spectrum ID string will be removed from the current data pipe.") 
 99  # Prompt examples. 
100  uf.desc.append(Desc_container("Prompt examples")) 
101  uf.desc[-1].add_paragraph("To delete the peak height data corresponding to the ID 'R1 ncyc5', type:") 
102  uf.desc[-1].add_prompt("relax> spectrum.delete('R1 ncyc5')") 
103  uf.backend = spectrum.delete 
104  uf.menu_text = "&delete" 
105  uf.gui_icon = "oxygen.actions.list-remove" 
106  uf.wizard_size = (700, 400) 
107  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
108   
109   
110  # The spectrum.error_analysis user function. 
111  uf = uf_info.add_uf('spectrum.error_analysis') 
112  uf.title = "Perform an error analysis for peak intensities." 
113  uf.title_short = "Peak intensity error analysis." 
114  uf.add_keyarg( 
115      name = "subset", 
116      basic_types = ["str"], 
117      container_types = ["list"], 
118      dim = (None,), 
119      desc_short = "subset spectrum IDs", 
120      desc = "The list of spectrum ID strings to restrict the error analysis to.", 
121      wiz_combo_iter = spectrum.get_ids, 
122      wiz_read_only = True, 
123      can_be_none = True 
124  ) 
125  # Description. 
126  uf.desc.append(Desc_container()) 
127  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.") 
128  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.") 
129  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:") 
130  table = uf_tables.add_table(label="table: peak intensity error analysis", caption="The six peak intensity error analysis types.") 
131  table.add_headings(["Int type", "Noise source", "Error scope"]) 
132  table.add_row(["Heights", "RMSD baseplane", "One sigma per peak per spectrum"]) 
133  table.add_row(["Heights", "Partial duplicate + variance averaging", "One sigma for all peaks, all spectra"]) 
134  table.add_row(["Heights", "All replicated + variance averaging", "One sigma per replicated spectra set"]) 
135  table.add_row(["Volumes", "RMSD baseplane", "One sigma per peak per spectrum"]) 
136  table.add_row(["Volumes", "Partial duplicate + variance averaging", "One sigma for all peaks, all spectra"]) 
137  table.add_row(["Volumes", "All replicated + variance averaging", "One sigma per replicated spectra set"]) 
138  uf.desc[-1].add_table(table.label) 
139  # Peak heights with baseplane noise RMSD. 
140  uf.desc.append(Desc_container("Peak heights with baseplane noise RMSD")) 
141  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.") 
142  # Peak heights with partially replicated spectra. 
143  uf.desc.append(Desc_container("Peak heights with partially replicated spectra")) 
144  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") 
145  uf.desc[-1].add_item_list_element(None, "sigma^2 =  sum({Ii - Iav}^2) / (n - 1),") 
146  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.") 
147  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.") 
148  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.") 
149  # Peak heights with all spectra replicated. 
150  uf.desc.append(Desc_container("Peak heights with all spectra replicated")) 
151  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.") 
152  # Peak volumes with baseplane noise RMSD. 
153  uf.desc.append(Desc_container("Peak volumes with baseplane noise RMSD")) 
154  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:") 
155  uf.desc[-1].add_item_list_element(None, "sigma_vol^2 = sigma_i^2 * N,") 
156  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:") 
157  uf.desc[-1].add_item_list_element(None, "sigma_vol = sigma_i * sqrt(n*m),") 
158  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.") 
159  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.") 
160  # Peak volumes with partially replicated spectra. 
161  uf.desc.append(Desc_container("Peak volumes with partially replicated spectra")) 
162  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.") 
163  # Peak volumes with all spectra replicated. 
164  uf.desc.append(Desc_container("Peak volumes with all spectra replicated")) 
165  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.") 
166  uf.backend = spectrum.error_analysis 
167  uf.menu_text = "&error_analysis" 
168  uf.gui_icon = "oxygen.categories.applications-education" 
169  uf.wizard_height_desc = 530 
170  uf.wizard_size = (1000, 700) 
171  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
172  uf.wizard_apply_button = False 
173   
174   
175  # The spectrum.error_analysis_per_field user function. 
176  uf = uf_info.add_uf('spectrum.error_analysis_per_field') 
177  uf.title = "Use spectrum IDs per each field strength for an error analysis for peak intensities." 
178  uf.title_short = "Per field strength peak intensity error analysis." 
179  # Description. 
180  uf.desc.append(Desc_container()) 
181  uf.desc[-1].add_paragraph("Please see the spectrum.error_analysis user function documentation.") 
182  uf.desc[-1].add_paragraph("This user function will collect all spectrum IDs for each field strength separately, and call the spectrum.error_analysis with these.") 
183  uf.desc[-1].add_paragraph("This function is meant as a short-cut for the spectrum.error_analysis function.") 
184  # Prompt examples. 
185  uf.desc.append(Desc_container("Prompt examples")) 
186  uf.desc[-1].add_paragraph("To collect all spectrum IDs per field strength, and perform peak intensity error analysis:") 
187  uf.desc[-1].add_prompt("relax> spectrum.error_analysis_per_field()") 
188  uf.backend = spectrum.error_analysis_per_field 
189  uf.menu_text = "&error_analysis_per_field" 
190  uf.gui_icon = "oxygen.categories.applications-education" 
191  uf.wizard_height_desc = 530 
192  uf.wizard_size = (1000, 700) 
193  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
194  uf.wizard_apply_button = False 
195   
196   
197  # The spectrum.integration_points user function. 
198  uf = uf_info.add_uf('spectrum.integration_points') 
199  uf.title = "Set the number of summed points used in volume integration of a given spin in a spectrum." 
200  uf.title_short = "Number of integration points." 
201  uf.add_keyarg( 
202      name = "N", 
203      basic_types = ["int"], 
204      min = 1, 
205      max = 10000000, 
206      desc_short = "number of summed points", 
207      desc = "The number of points used by the summation volume integration method." 
208  ) 
209  uf.add_keyarg( 
210      name = "spectrum_id", 
211      basic_types = ["str"], 
212      desc_short = "spectrum ID string", 
213      desc = "The spectrum ID string.", 
214      wiz_element_type = 'combo', 
215      wiz_combo_iter = spectrum.get_ids, 
216      wiz_read_only = True 
217  ) 
218  uf.add_keyarg( 
219      name = "spin_id", 
220      basic_types = ["str"], 
221      desc_short = "spin ID string", 
222      desc = "Restrict setting the number to certain spins.", 
223      can_be_none = True 
224  ) 
225  # Description. 
226  uf.desc.append(Desc_container()) 
227  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.") 
228  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.") 
229  uf.backend = spectrum.integration_points 
230  uf.menu_text = "&integration_points" 
231  uf.gui_icon = "oxygen.actions.edit-rename" 
232  uf.wizard_size = (900, 600) 
233  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
234   
235   
236  # The spectrum.read_intensities user function. 
237  uf = uf_info.add_uf('spectrum.read_intensities') 
238  uf.title = "Read peak intensities from a file." 
239  uf.title_short = "Peak intensity reading." 
240  uf.add_keyarg( 
241      name = "file", 
242      arg_type = "file sel multi read", 
243      desc_short = "file name(s)", 
244      desc = "The name of the file or the list of files containing the intensity data.", 
245      wiz_filesel_wildcard = WILDCARD_SPECTRUM_PEAKLIST, 
246  ) 
247  uf.add_keyarg( 
248      name = "dir", 
249      arg_type = "dir", 
250      desc_short = "directory name", 
251      desc = "The directory where the file is located.", 
252      can_be_none = True 
253  ) 
254  uf.add_keyarg( 
255      name = "spectrum_id", 
256      basic_types = ["str"], 
257      container_types = ["list"], 
258      dim = [(), (None,)], 
259      desc_short = "spectrum ID string", 
260      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}." 
261  ) 
262  uf.add_keyarg( 
263      name = "dim", 
264      default = 1, 
265      basic_types = ["int"], 
266      min = 1, 
267      desc_short = "spectral dimension to read", 
268      desc = "Associate the data with the spins of any dimension in the peak list.  This defaults to w1, the heteronucleus in HSQC type experiments." 
269  ) 
270  uf.add_keyarg( 
271      name = "int_method", 
272      default = "height", 
273      basic_types = ["str"], 
274      desc_short = "peak integration method", 
275      desc = "The method by which peaks were integrated.", 
276      wiz_element_type = "combo", 
277      wiz_combo_choices = ["height", "point sum", "other"], 
278      wiz_read_only = True 
279  ) 
280  uf.add_keyarg( 
281      name = "int_col", 
282      basic_types = ["int"], 
283      container_types = ["list"], 
284      dim = [(), (None,)], 
285      desc_short = "intensity column", 
286      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).", 
287      can_be_none = True 
288  ) 
289  uf.add_keyarg( 
290      name = "spin_id_col", 
291      basic_types = ["int"], 
292      arg_type = "free format", 
293      desc_short = "spin ID string column", 
294      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).", 
295      can_be_none = True 
296  ) 
297  uf.add_keyarg( 
298      name = "mol_name_col", 
299      basic_types = ["int"], 
300      arg_type = "free format", 
301      desc_short = "molecule name column", 
302      desc = "The molecule name column used by the generic intensity file format (alternative to the spin ID column).", 
303      can_be_none = True 
304  ) 
305  uf.add_keyarg( 
306      name = "res_num_col", 
307      basic_types = ["int"], 
308      arg_type = "free format", 
309      desc_short = "residue number column", 
310      desc = "The residue number column used by the generic intensity file format (alternative to the spin ID column).", 
311      can_be_none = True 
312  ) 
313  uf.add_keyarg( 
314      name = "res_name_col", 
315      basic_types = ["int"], 
316      arg_type = "free format", 
317      desc_short = "residue name column", 
318      desc = "The residue name column used by the generic intensity file format (alternative to the spin ID column).", 
319      can_be_none = True 
320  ) 
321  uf.add_keyarg( 
322      name = "spin_num_col", 
323      basic_types = ["int"], 
324      arg_type = "free format", 
325      desc_short = "spin number column", 
326      desc = "The spin number column used by the generic intensity file format (alternative to the spin ID column).", 
327      can_be_none = True 
328  ) 
329  uf.add_keyarg( 
330      name = "spin_name_col", 
331      basic_types = ["int"], 
332      arg_type = "free format", 
333      desc_short = "spin name column", 
334      desc = "The spin name column used by the generic intensity file format (alternative to the spin ID column).", 
335      can_be_none = True 
336  ) 
337  uf.add_keyarg( 
338      name = "sep", 
339      basic_types = ["str"], 
340      arg_type = "free format", 
341      desc_short = "column separator", 
342      desc = "The column separator used by the generic intensity format (the default is white space).", 
343      can_be_none = True 
344  ) 
345  uf.add_keyarg( 
346      name = "spin_id", 
347      basic_types = ["str"], 
348      desc_short = "spin ID string", 
349      desc = "The spin ID string used to restrict the loading of data to certain spin subsets.", 
350      can_be_none = True 
351  ) 
352  uf.add_keyarg( 
353      name = "ncproc", 
354      basic_types = ["int"], 
355      desc_short = "Bruker ncproc parameter", 
356      desc = "The Bruker specific FID intensity scaling factor.", 
357      can_be_none = True 
358  ) 
359  # Description. 
360  uf.desc.append(Desc_container()) 
361  uf.desc[-1].add_paragraph("The peak intensity can either be from peak heights or peak volumes.") 
362  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.") 
363  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.") 
364  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'.") 
365  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.") 
366  # File formats. 
367  uf.desc.append(Desc_container("File formats")) 
368  uf.desc[-1].add_paragraph("The peak list or intensity file will be automatically determined.") 
369  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).") 
370  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.") 
371  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.") 
372  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}.") 
373  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.") 
374  uf.desc.append(Desc_container("Multiple files")) 
375  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.") 
376  # Prompt examples. 
377  uf.desc.append(Desc_container("Prompt examples")) 
378  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:") 
379  uf.desc[-1].add_prompt("relax> spectrum.read_intensities(file='ref.list', spectrum_id='ref')") 
380  uf.desc[-1].add_prompt("relax> spectrum.read_intensities(file='sat.list', spectrum_id='sat')") 
381  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:") 
382  uf.desc[-1].add_prompt("relax> spectrum.read_intensities(file='ref.text', spectrum_id='ref')") 
383  uf.desc[-1].add_prompt("relax> spectrum.read_intensities(file='sat.text', spectrum_id='sat')") 
384  uf.backend = spectrum.read 
385  uf.menu_text = "&read_intensities" 
386  uf.gui_icon = "oxygen.actions.document-open" 
387  uf.wizard_height_desc = 300 
388  uf.wizard_size = (1000, 750) 
389  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
390   
391   
392  # The spectrum.read_spins user function. 
393  uf = uf_info.add_uf('spectrum.read_spins') 
394  uf.title = "Read peak assignments from a file and create spins." 
395  uf.title_short = "Peak assignments reading." 
396  uf.add_keyarg( 
397      name = "file", 
398      arg_type = "file sel read", 
399      desc_short = "file name", 
400      desc = "The name of the file containing the intensity data.", 
401      wiz_filesel_wildcard = WILDCARD_SPECTRUM_PEAKLIST, 
402  ) 
403  uf.add_keyarg( 
404      name = "dir", 
405      arg_type = "dir", 
406      desc_short = "directory name", 
407      desc = "The directory where the file is located.", 
408      can_be_none = True 
409  ) 
410  uf.add_keyarg( 
411      name = "dim", 
412      default = 1, 
413      basic_types = ["int"], 
414      min = 1, 
415      desc_short = "spectral dimension to read", 
416      desc = "Associate the data with the spins of any dimension in the peak list.  This defaults to w1, the heteronucleus in HSQC type experiments." 
417  ) 
418  uf.add_keyarg( 
419      name = "spin_id_col", 
420      basic_types = ["int"], 
421      arg_type = "free format", 
422      desc_short = "spin ID string column", 
423      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).", 
424      can_be_none = True 
425  ) 
426  uf.add_keyarg( 
427      name = "mol_name_col", 
428      basic_types = ["int"], 
429      arg_type = "free format", 
430      desc_short = "molecule name column", 
431      desc = "The molecule name column used by the generic intensity file format (alternative to the spin ID column).", 
432      can_be_none = True 
433  ) 
434  uf.add_keyarg( 
435      name = "res_num_col", 
436      basic_types = ["int"], 
437      arg_type = "free format", 
438      desc_short = "residue number column", 
439      desc = "The residue number column used by the generic intensity file format (alternative to the spin ID column).", 
440      can_be_none = True 
441  ) 
442  uf.add_keyarg( 
443      name = "res_name_col", 
444      basic_types = ["int"], 
445      arg_type = "free format", 
446      desc_short = "residue name column", 
447      desc = "The residue name column used by the generic intensity file format (alternative to the spin ID column).", 
448      can_be_none = True 
449  ) 
450  uf.add_keyarg( 
451      name = "spin_num_col", 
452      basic_types = ["int"], 
453      arg_type = "free format", 
454      desc_short = "spin number column", 
455      desc = "The spin number column used by the generic intensity file format (alternative to the spin ID column).", 
456      can_be_none = True 
457  ) 
458  uf.add_keyarg( 
459      name = "spin_name_col", 
460      basic_types = ["int"], 
461      arg_type = "free format", 
462      desc_short = "spin name column", 
463      desc = "The spin name column used by the generic intensity file format (alternative to the spin ID column).", 
464      can_be_none = True 
465  ) 
466  uf.add_keyarg( 
467      name = "sep", 
468      basic_types = ["str"], 
469      arg_type = "free format", 
470      desc_short = "column separator", 
471      desc = "The column separator used by the generic intensity format (the default is white space).", 
472      can_be_none = True 
473  ) 
474  uf.add_keyarg( 
475      name = "spin_id", 
476      basic_types = ["str"], 
477      desc_short = "spin ID string", 
478      desc = "The spin ID string used to restrict the loading of data to certain spin subsets.", 
479      can_be_none = True 
480  ) 
481  # Description. 
482  uf.desc.append(Desc_container()) 
483  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.") 
484  # File formats. 
485  uf.desc.append(Desc_container("File formats")) 
486  uf.desc[-1].add_paragraph("The peak list or intensity file will be automatically determined.") 
487  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).") 
488  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.") 
489  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.") 
490  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}.") 
491  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.") 
492  # Prompt examples. 
493  uf.desc.append(Desc_container("Prompt examples")) 
494  uf.desc[-1].add_paragraph("To read the spin assignments from the Sparky formatted files 'ref.list' and 'sat.list', type:") 
495  uf.desc[-1].add_prompt("relax> spectrum.read_spins(file='ref.list')") 
496  uf.desc[-1].add_prompt("relax> spectrum.read_spins(file='sat.list')") 
497  uf.desc[-1].add_paragraph("To read the spin assignments from the XEasy formatted files 'ref.text' and 'sat.text', type:") 
498  uf.desc[-1].add_prompt("relax> spectrum.read_spins(file='ref.text')") 
499  uf.desc[-1].add_prompt("relax> spectrum.read_spins(file='sat.text')") 
500  uf.backend = spectrum.read_spins 
501  uf.menu_text = "&read_spins" 
502  uf.gui_icon = "oxygen.actions.document-open" 
503  uf.wizard_height_desc = 300 
504  uf.wizard_size = (1000, 750) 
505  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
506   
507   
508  # The spectrum.replicated user function. 
509  uf = uf_info.add_uf('spectrum.replicated') 
510  uf.title = "Specify which spectra are replicates of each other." 
511  uf.title_short = "Replicate spectra." 
512  uf.add_keyarg( 
513      name = "spectrum_ids", 
514      basic_types = ["str"], 
515      container_types = ["list"], 
516      dim = [(), (None,)], 
517      desc_short = "spectrum ID strings", 
518      desc = "The list of replicated spectra ID strings.", 
519      wiz_element_type = 'combo_list', 
520      wiz_combo_iter = spectrum.get_ids, 
521      wiz_combo_list_min = 2, 
522      wiz_read_only = True 
523  ) 
524  # Description. 
525  uf.desc.append(Desc_container()) 
526  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.") 
527  # Prompt examples. 
528  uf.desc.append(Desc_container("Prompt examples")) 
529  uf.desc[-1].add_paragraph("To specify that the NOE spectra labelled 'ref1', 'ref2', and 'ref3' are the same spectrum replicated, type one of:") 
530  uf.desc[-1].add_prompt("relax> spectrum.replicated(['ref1', 'ref2', 'ref3'])") 
531  uf.desc[-1].add_prompt("relax> spectrum.replicated(spectrum_ids=['ref1', 'ref2', 'ref3'])") 
532  uf.desc[-1].add_paragraph("To specify that the two R2 spectra 'ncyc2' and 'ncyc2b' are the same time point, type:") 
533  uf.desc[-1].add_prompt("relax> spectrum.replicated(['ncyc2', 'ncyc2b'])") 
534  uf.backend = spectrum.replicated 
535  uf.menu_text = "re&plicated" 
536  uf.gui_icon = "oxygen.actions.edit-rename" 
537  uf.wizard_size = (700, 500) 
538  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
539   
540   
541  # The spectrum.sn_ratio user function. 
542  uf = uf_info.add_uf('spectrum.sn_ratio') 
543  uf.title = "Calculate the signal to noise ratio for all selected spins." 
544  uf.title_short = "Signal to noise calculation." 
545  # Description. 
546  uf.desc.append(Desc_container()) 
547  uf.desc[-1].add_paragraph("This user function will per spin calculate the signal to noise ratio: S/N.") 
548  # Prompt examples. 
549  uf.desc.append(Desc_container("Prompt examples")) 
550  uf.desc[-1].add_paragraph("To calculate the Signal to Noise ratio per spin.") 
551  uf.desc[-1].add_prompt("relax> spectrum.sn_ratio()") 
552  uf.backend = spectrum.signal_noise_ratio 
553  uf.menu_text = "&sn_ratio" 
554  uf.gui_icon = "relax.fid" 
555  uf.wizard_size = (600, 400) 
556  uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' 
557  uf.wizard_apply_button = False 
558