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

Source Code for Module prompt.noe

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2004-2005 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 Noe:
29 - def __init__(self, relax):
30 # Help. 31 self.__relax_help__ = \ 32 """Class for calculating NOE data.""" 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 error(self, run=None, error=0.0, spectrum_type=None, res_num=None, res_name=None):
42 """Function for setting the errors in the reference or saturated NOE spectra. 43 44 Keyword Arguments 45 ~~~~~~~~~~~~~~~~~ 46 47 run: The name of the run. 48 49 error: The error. 50 51 spectrum_type: The type of spectrum. 52 53 res_num: The residue number. 54 55 res_name: The residue name. 56 57 58 Description 59 ~~~~~~~~~~~ 60 61 The spectrum_type argument can have the following values: 62 'ref': The NOE reference spectrum. 63 'sat': The NOE spectrum with proton saturation turned on. 64 65 If the 'res_num' and 'res_name' arguments are left as the defaults of None, then the error 66 value for all residues will be set to the supplied value. Otherwise the residue number can 67 be set to either an integer for selecting a single residue or a python regular expression 68 string for selecting multiple residues. The residue name argument must be a string and can 69 use regular expression as well. 70 """ 71 72 # Function intro text. 73 if self.__relax__.interpreter.intro: 74 text = sys.ps3 + "noe.error(" 75 text = text + "run=" + `run` 76 text = text + ", error=" + `error` 77 text = text + ", spectrum_type=" + `spectrum_type` 78 text = text + ", res_num=" + `res_num` 79 text = text + ", res_name=" + `res_name` + ")" 80 print text 81 82 # The run argument. 83 if type(run) != str: 84 raise RelaxStrError, ('run', run) 85 86 # The error. 87 if type(error) != float and type(error) != int: 88 raise RelaxNumError, ('error', error) 89 90 # The spectrum type. 91 if type(spectrum_type) != str: 92 raise RelaxStrError, ('spectrum type', spectrum_type) 93 94 # Residue number. 95 if res_num != None and type(res_num) != int and type(res_num) != str: 96 raise RelaxNoneIntStrError, ('residue number', res_num) 97 98 # Residue name. 99 if res_name != None and type(res_name) != str: 100 raise RelaxNoneStrError, ('residue name', res_name) 101 102 # Execute the functional code. 103 self.__relax__.specific.noe.set_error(run=run, error=error, spectrum_type=spectrum_type, res_num=res_num, res_name=res_name)
104 105
106 - def read(self, run=None, file=None, dir=None, spectrum_type=None, format='sparky', heteronuc='N', proton='HN', int_col=None):
107 """Function for reading peak intensities from a file for NOE calculations. 108 109 Keyword Arguments 110 ~~~~~~~~~~~~~~~~~ 111 112 run: The name of the run. 113 114 file: The name of the file containing the sequence data. 115 116 dir: The directory where the file is located. 117 118 spectrum_type: The type of spectrum. 119 120 format: The type of file containing peak intensities. 121 122 heteronuc: The name of the heteronucleus as specified in the peak intensity file. 123 124 proton: The name of the proton as specified in the peak intensity file. 125 126 int_col: The column containing the peak intensity data (for a non-standard formatted file). 127 128 129 Description 130 ~~~~~~~~~~~ 131 132 The peak intensity can either be from peak heights or peak volumes. 133 134 135 The 'spectrum_type' argument can have the following values: 136 'ref': The NOE reference spectrum. 137 'sat': The NOE spectrum with proton saturation turned on. 138 139 140 The 'format' argument can currently be set to: 141 'sparky' 142 'xeasy' 143 144 If the 'format' argument is set to 'sparky', the file should be a Sparky peak list saved 145 after typing the command 'lt'. The default is to assume that columns 0, 1, 2, and 3 (1st, 146 2nd, 3rd, and 4th) contain the Sparky assignment, w1, w2, and peak intensity data 147 respectively. The frequency data w1 and w2 are ignored while the peak intensity data can 148 either be the peak height or volume displayed by changing the window options. If the peak 149 intensity data is not within column 3, set the argument 'int_col' to the appropriate value 150 (column numbering starts from 0 rather than 1). 151 152 If the 'format' argument is set to 'xeasy', the file should be the saved XEasy text window 153 output of the list peak entries command, 'tw' followed by 'le'. As the columns are fixed, 154 the peak intensity column is hardwired to number 10 (the 11th column) which contains either 155 the peak height or peak volume data. Because the columns are fixed, the 'int_col' argument 156 will be ignored. 157 158 159 The 'heteronuc' and 'proton' arguments should be set respectively to the name of the 160 heteronucleus and proton in the file. Only those lines which match these labels will be 161 used. 162 163 164 Examples 165 ~~~~~~~~ 166 167 To read the reference and saturated spectra peak heights from the Sparky formatted files 168 'ref.list' and 'sat.list' to the run 'noe', type: 169 170 relax> noe.read('noe', file='ref.list', spectrum_type='ref') 171 relax> noe.read('noe', file='sat.list', spectrum_type='sat') 172 173 To read the reference and saturated spectra peak heights from the XEasy formatted files 174 'ref.text' and 'sat.text' to the run 'noe', type: 175 176 relax> noe.read('noe', file='ref.text', spectrum_type='ref', format='xeasy') 177 relax> noe.read('noe', file='sat.text', spectrum_type='sat', format='xeasy') 178 """ 179 180 # Function intro text. 181 if self.__relax__.interpreter.intro: 182 text = sys.ps3 + "noe.read(" 183 text = text + "run=" + `run` 184 text = text + ", file=" + `file` 185 text = text + ", dir=" + `dir` 186 text = text + ", spectrum_type=" + `spectrum_type` 187 text = text + ", format=" + `format` 188 text = text + ", heteronuc=" + `heteronuc` 189 text = text + ", proton=" + `proton` 190 text = text + ", int_col=" + `int_col` + ")" 191 print text 192 193 # The run argument. 194 if type(run) != str: 195 raise RelaxStrError, ('run', run) 196 197 # The file name. 198 if type(file) != str: 199 raise RelaxStrError, ('file name', file) 200 201 # Directory. 202 if dir != None and type(dir) != str: 203 raise RelaxNoneStrError, ('directory name', dir) 204 205 # The spectrum type. 206 if type(spectrum_type) != str: 207 raise RelaxStrError, ('spectrum type', spectrum_type) 208 209 # The format. 210 if type(format) != str: 211 raise RelaxStrError, ('format', format) 212 213 # The heteronucleus name. 214 if type(heteronuc) != str: 215 raise RelaxStrError, ('heteronucleus name', heteronuc) 216 217 # The proton name. 218 if type(proton) != str: 219 raise RelaxStrError, ('proton name', proton) 220 221 # The intensity column. 222 if int_col and type(int_col) != int: 223 raise RelaxNoneIntError, ('intensity column', int_col) 224 225 # Execute the functional code. 226 self.__relax__.specific.noe.read(run=run, file=file, dir=dir, spectrum_type=spectrum_type, format=format, heteronuc=heteronuc, proton=proton, int_col=int_col)
227