Package prompt :: Module relax_fit
[hide private]
[frames] | no frames]

Source Code for Module prompt.relax_fit

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2004 Edward d'Auvergne                                        # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  import sys 
 24   
 25  import help 
 26   
 27   
28 -class Relax_fit:
29 - def __init__(self, relax):
30 # Help. 31 self.__relax_help__ = \ 32 """Class for relaxation curve fitting.""" 33 34 # Add the generic help string. 35 self.__relax_help__ = self.__relax_help__ + "\n" + help.relax_class_help 36 37 # Place relax in the class namespace. 38 self.__relax__ = relax
39 40
41 - def read(self, run=None, file=None, dir=None, relax_time=0.0, fit_type='exp', format='sparky', heteronuc='N', proton='HN', int_col=None):
42 """Function for reading peak intensities from a file. 43 44 Keyword Arguments 45 ~~~~~~~~~~~~~~~~~ 46 47 run: The name of the run. 48 49 file: The name of the file containing the sequence data. 50 51 dir: The directory where the file is located. 52 53 relax_time: The time, in seconds, of the relaxation period. 54 55 fit_type: The type of relaxation curve to fit. 56 57 format: The type of file containing peak intensities. 58 59 heteronuc: The name of the heteronucleus as specified in the peak intensity file. 60 61 proton: The name of the proton as specified in the peak intensity file. 62 63 int_col: The column containing the peak intensity data (for a non-standard formatted file). 64 65 66 Description 67 ~~~~~~~~~~~ 68 69 The peak intensity can either be from peak heights or peak volumes. 70 71 72 The supported relaxation experiments include the default two parameter exponential fit, 73 selected by setting the 'fit_type' argument to 'exp', and the three parameter inversion 74 recovery experiment in which the peak intensity limit is a non-zero value, selected by 75 setting the argument to 'inv'. 76 77 78 The format argument can currently be set to: 79 'sparky' 80 'xeasy' 81 82 If the format argument is set to 'sparky', the file should be a Sparky peak list saved after 83 typing the command 'lt'. The default is to assume that columns 0, 1, 2, and 3 (1st, 2nd, 84 3rd, and 4th) contain the Sparky assignment, w1, w2, and peak intensity data respectively. 85 The frequency data w1 and w2 are ignored while the peak intensity data can either be the 86 peak height or volume displayed by changing the window options. If the peak intensity data 87 is not within column 3, set the argument int_col to the appropriate value (column numbering 88 starts from 0 rather than 1). 89 90 If the format argument is set to 'xeasy', the file should be the saved XEasy text window 91 output of the list peak entries command, 'tw' followed by 'le'. As the columns are fixed, 92 the peak intensity column is hardwired to number 10 (the 11th column) which contains either 93 the peak height or peak volume data. Because the columns are fixed, the int_col argument 94 will be ignored. 95 96 97 The heteronuc and proton arguments should be set respectively to the name of the 98 heteronucleus and proton in the file. Only those lines which match these labels will be 99 used. 100 101 102 """ 103 104 # Function intro text. 105 if self.__relax__.interpreter.intro: 106 text = sys.ps3 + "relax_fit.read(" 107 text = text + "run=" + `run` 108 text = text + ", file=" + `file` 109 text = text + ", dir=" + `dir` 110 text = text + ", relax_time=" + `relax_time` 111 text = text + ", fit_type=" + `fit_type` 112 text = text + ", format=" + `format` 113 text = text + ", heteronuc=" + `heteronuc` 114 text = text + ", proton=" + `proton` 115 text = text + ", int_col=" + `int_col` + ")" 116 print text 117 118 # The run argument. 119 if type(run) != str: 120 raise RelaxStrError, ('run', run) 121 122 # The file name. 123 if type(file) != str: 124 raise RelaxStrError, ('file name', file) 125 126 # Directory. 127 if dir != None and type(dir) != str: 128 raise RelaxNoneStrError, ('directory name', dir) 129 130 # The relaxation time. 131 if type(relax_time) != float: 132 raise RelaxFloatError, ('relaxation time', relax_time) 133 134 # The fit type. 135 if type(fit_type) != str: 136 raise RelaxStrError, ('fit type', fit_type) 137 138 # The format. 139 if type(format) != str: 140 raise RelaxStrError, ('format', format) 141 142 # The heteronucleus name. 143 if type(heteronuc) != str: 144 raise RelaxStrError, ('heteronucleus name', heteronuc) 145 146 # The proton name. 147 if type(proton) != str: 148 raise RelaxStrError, ('proton name', proton) 149 150 # The intensity column. 151 if int_col and type(int_col) != int: 152 raise RelaxNoneIntError, ('intensity column', int_col) 153 154 # Execute the functional code. 155 self.__relax__.specific.relax_fit.read(run=run, file=file, dir=dir, relax_time=relax_time, fit_type=fit_type, format=format, heteronuc=heteronuc, proton=proton, int_col=int_col)
156