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

Source Code for Module prompt.relax_data

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003, 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_data:
29 - def __init__(self, relax):
30 # Help. 31 self.__relax_help__ = \ 32 """Class for manipulating R1, R2, and NOE relaxation 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 back_calc(self, run=None, ri_label=None, frq_label=None, frq=None):
42 """Function for back calculating relaxation data. 43 44 Keyword Arguments 45 ~~~~~~~~~~~~~~~~~ 46 47 run: The name of the run. 48 49 ri_label: The relaxation data type, ie 'R1', 'R2', or 'NOE'. 50 51 frq_label: The field strength label. 52 53 frq: The spectrometer frequency in Hz. 54 55 """ 56 57 # Function intro text. 58 if self.__relax__.interpreter.intro: 59 text = sys.ps3 + "relax_data.back_calc(" 60 text = text + "run=" + `run` 61 text = text + ", ri_label=" + `ri_label` 62 text = text + ", frq_label=" + `frq_label` 63 text = text + ", frq=" + `frq` + ")" 64 print text 65 66 # The run name. 67 if type(run) != str: 68 raise RelaxStrError, ('run', run) 69 70 # Relaxation data type. 71 if type(ri_label) != str: 72 raise RelaxStrError, ('relaxation label', ri_label) 73 74 # Frequency label. 75 if type(frq_label) != str: 76 raise RelaxStrError, ('frequency label', frq_label) 77 78 # Frequency. 79 if type(frq) != float: 80 raise RelaxFloatError, ('frequency', frq) 81 82 # Execute the functional code. 83 self.__relax__.specific.relax_data.back_calc(run=run, ri_label=ri_label, frq_label=frq_label, frq=frq)
84 85
86 - def copy(self, run1=None, run2=None, ri_label=None, frq_label=None):
87 """Function for copying relaxation data from run1 to run2. 88 89 Keyword Arguments 90 ~~~~~~~~~~~~~~~~~ 91 92 run1: The name of the run to copy the sequence from. 93 94 run2: The name of the run to copy the sequence to. 95 96 ri_label: The relaxation data type, ie 'R1', 'R2', or 'NOE'. 97 98 frq_label: The field strength label. 99 100 101 Description 102 ~~~~~~~~~~~ 103 104 This function will copy relaxation data from 'run1' to 'run2'. If ri_label and frq_label 105 are not given then all relaxation data will be copied, otherwise only a specific data set 106 will be copied. 107 108 109 Examples 110 ~~~~~~~~ 111 112 To copy all relaxation data from run 'm1' to run 'm9', type one of: 113 114 relax> relax_data.copy('m1', 'm9') 115 relax> relax_data.copy(run1='m1', run2='m9') 116 relax> relax_data.copy('m1', 'm9', None, None) 117 relax> relax_data.copy(run1='m1', run2='m9', ri_label=None, frq_label=None) 118 119 To copy only the NOE relaxation data with the frq_label of '800' from 'm3' to 'm6', type one 120 of: 121 122 relax> relax_data.copy('m3', 'm6', 'NOE', '800') 123 relax> relax_data.copy(run1='m3', run2='m6', ri_label='NOE', frq_label='800') 124 """ 125 126 # Function intro text. 127 if self.__relax__.interpreter.intro: 128 text = sys.ps3 + "relax_data.copy(" 129 text = text + "run1=" + `run1` 130 text = text + ", run2=" + `run2` 131 text = text + ", ri_label=" + `ri_label` 132 text = text + ", frq_label=" + `frq_label` + ")" 133 print text 134 135 # The run1 argument. 136 if type(run1) != str: 137 raise RelaxStrError, ('run1', run1) 138 139 # The run2 argument. 140 if type(run2) != str: 141 raise RelaxStrError, ('run2', run2) 142 143 # Relaxation data type. 144 if ri_label != None and type(ri_label) != str: 145 raise RelaxNoneStrError, ('relaxation label', ri_label) 146 147 # Frequency label. 148 if frq_label != None and type(frq_label) != str: 149 raise RelaxNoneStrError, ('frequency label', frq_label) 150 151 # Execute the functional code. 152 self.__relax__.specific.relax_data.copy(run1=run1, run2=run2, ri_label=ri_label, frq_label=frq_label)
153 154
155 - def delete(self, run=None, ri_label=None, frq_label=None):
156 """Function for deleting the relaxation data corresponding to ri_label and frq_label. 157 158 Keyword Arguments 159 ~~~~~~~~~~~~~~~~~ 160 161 run: The name of the run. 162 163 ri_label: The relaxation data type, ie 'R1', 'R2', or 'NOE'. 164 165 frq_label: The field strength label. 166 167 168 Examples 169 ~~~~~~~~ 170 171 To delete the relaxation data corresponding to ri_label='NOE', frq_label='600', and the run 172 'm4', type: 173 174 relax> relax_data.delete('m4', 'NOE', '600') 175 """ 176 177 # Function intro text. 178 if self.__relax__.interpreter.intro: 179 text = sys.ps3 + "relax_data.delete(" 180 text = text + "run=" + `run` 181 text = text + ", ri_label=" + `ri_label` 182 text = text + ", frq_label=" + `frq_label` + ")" 183 print text 184 185 # The run name. 186 if type(run) != str: 187 raise RelaxStrError, ('run', run) 188 189 # Relaxation data type. 190 if type(ri_label) != str: 191 raise RelaxStrError, ('relaxation label', ri_label) 192 193 # Frequency label. 194 if type(frq_label) != str: 195 raise RelaxStrError, ('frequency label', frq_label) 196 197 # Execute the functional code. 198 self.__relax__.specific.relax_data.delete(run=run, ri_label=ri_label, frq_label=frq_label)
199 200
201 - def display(self, run=None, ri_label=None, frq_label=None):
202 """Function for displaying the relaxation data corresponding to ri_label and frq_label. 203 204 Keyword Arguments 205 ~~~~~~~~~~~~~~~~~ 206 207 run: The name of the run. 208 209 ri_label: The relaxation data type, ie 'R1', 'R2', or 'NOE'. 210 211 frq_label: The field strength label. 212 213 214 Examples 215 ~~~~~~~~ 216 217 To show the relaxation data corresponding to ri_label='NOE', frq_label='600', and the run 218 'm4', type: 219 220 relax> relax_data.display('m4', 'NOE', '600') 221 """ 222 223 # Function intro text. 224 if self.__relax__.interpreter.intro: 225 text = sys.ps3 + "relax_data.display(" 226 text = text + "run=" + `run` 227 text = text + ", ri_label=" + `ri_label` 228 text = text + ", frq_label=" + `frq_label` + ")" 229 print text 230 231 # The run name. 232 if type(run) != str: 233 raise RelaxStrError, ('run', run) 234 235 # Relaxation data type. 236 if type(ri_label) != str: 237 raise RelaxStrError, ('relaxation label', ri_label) 238 239 # Frequency label. 240 if type(frq_label) != str: 241 raise RelaxStrError, ('frequency label', frq_label) 242 243 # Execute the functional code. 244 self.__relax__.specific.relax_data.display(run=run, ri_label=ri_label, frq_label=frq_label)
245 246
247 - def read(self, run=None, ri_label=None, frq_label=None, frq=None, file=None, dir=None, num_col=0, name_col=1, data_col=2, error_col=3, sep=None):
248 """Function for reading R1, R2, or NOE relaxation data from a file. 249 250 Keyword Arguments 251 ~~~~~~~~~~~~~~~~~ 252 253 run: The name of the run. 254 255 ri_label: The relaxation data type, ie 'R1', 'R2', or 'NOE'. 256 257 frq_label: The field strength label. 258 259 frq: The spectrometer frequency in Hz. 260 261 file: The name of the file containing the relaxation data. 262 263 dir: The directory where the file is located. 264 265 num_col: The residue number column (the default is 0, ie the first column). 266 267 name_col: The residue name column (the default is 1). 268 269 data_col: The relaxation data column (the default is 2). 270 271 error_col: The experimental error column (the default is 3). 272 273 sep: The column separator (the default is white space). 274 275 276 Description 277 ~~~~~~~~~~~ 278 279 The frequency label argument can be anything as long as data collected at the same field 280 strength have the same label. 281 282 283 Examples 284 ~~~~~~~~ 285 286 The following commands will read the NOE relaxation data collected at 600 MHz out of a file 287 called 'noe.600.out' where the residue numbers, residue names, data, errors are in the 288 first, second, third, and forth columns respectively. 289 290 relax> relax_data.read('m1', 'NOE', '600', 599.7 * 1e6, 'noe.600.out') 291 relax> relax_data.read('m1', ri_label='NOE', frq_label='600', frq=600.0 * 1e6, 292 file='noe.600.out') 293 294 295 The following commands will read the R2 data out of the file 'r2.out' where the residue 296 numbers, residue names, data, errors are in the second, third, fifth, and sixth columns 297 respectively. The columns are separated by commas. 298 299 relax> relax_data.read('m1', 'R2', '800 MHz', 8.0 * 1e8, 'r2.out', 1, 2, 4, 5, ',') 300 relax> relax_data.read('m1', ri_label='R2', frq_label='800 MHz', frq=8.0*1e8, 301 file='r2.out', num_col=1, name_col=2, data_col=4, error_col=5, 302 sep=',') 303 304 305 The following commands will read the R1 data out of the file 'r1.out' where the columns are 306 separated by the symbol '%' 307 308 relax> relax_data.read('m1', 'R1', '300', 300.1 * 1e6, 'r1.out', sep='%') 309 """ 310 311 # Function intro text. 312 if self.__relax__.interpreter.intro: 313 text = sys.ps3 + "relax_data.read(" 314 text = text + "run=" + `run` 315 text = text + ", ri_label=" + `ri_label` 316 text = text + ", frq_label=" + `frq_label` 317 text = text + ", frq=" + `frq` 318 text = text + ", file=" + `file` 319 text = text + ", dir=" + `dir` 320 text = text + ", num_col=" + `num_col` 321 text = text + ", name_col=" + `name_col` 322 text = text + ", data_col=" + `data_col` 323 text = text + ", error_col=" + `error_col` 324 text = text + ", sep=" + `sep` + ")" 325 print text 326 327 # The run name. 328 if type(run) != str: 329 raise RelaxStrError, ('run', run) 330 331 # Relaxation data type. 332 if type(ri_label) != str: 333 raise RelaxStrError, ('relaxation label', ri_label) 334 335 # Frequency label. 336 if type(frq_label) != str: 337 raise RelaxStrError, ('frequency label', frq_label) 338 339 # Frequency. 340 if type(frq) != float: 341 raise RelaxFloatError, ('frequency', frq) 342 343 # The file name. 344 if type(file) != str: 345 raise RelaxStrError, ('file', file) 346 347 # Directory. 348 if dir != None and type(dir) != str: 349 raise RelaxNoneStrError, ('directory name', dir) 350 351 # The number column. 352 if type(num_col) != int: 353 raise RelaxIntError, ('residue number column', num_col) 354 355 # The name column. 356 if type(name_col) != int: 357 raise RelaxIntError, ('residue name column', name_col) 358 359 # The data column. 360 if type(data_col) != int: 361 raise RelaxIntError, ('data column', data_col) 362 363 # The error column. 364 if type(error_col) != int: 365 raise RelaxIntError, ('error column', error_col) 366 367 # Column separator. 368 if sep != None and type(sep) != str: 369 raise RelaxNoneStrError, ('column separator', sep) 370 371 # Execute the functional code. 372 self.__relax__.specific.relax_data.read(run=run, ri_label=ri_label, frq_label=frq_label, frq=frq, file=file, dir=dir, num_col=num_col, name_col=name_col, data_col=data_col, error_col=error_col, sep=sep)
373 374
375 - def write(self, run=None, ri_label=None, frq_label=None, file=None, dir=None, force=0):
376 """Function for writing R1, R2, or NOE relaxation data to a file. 377 378 Keyword Arguments 379 ~~~~~~~~~~~~~~~~~ 380 381 run: The name of the run. 382 383 ri_label: The relaxation data type, ie 'R1', 'R2', or 'NOE'. 384 385 frq_label: The field strength label. 386 387 file: The name of the file. 388 389 dir: The directory name. 390 391 force: A flag which, if set to 1, will cause the file to be overwritten. 392 393 394 Description 395 ~~~~~~~~~~~ 396 397 If no directory name is given, the file will be placed in the current working directory. 398 The 'ri_label' and 'frq_label' arguments are required for selecting which relaxation data 399 to write to file. 400 """ 401 402 # Function intro text. 403 if self.__relax__.interpreter.intro: 404 text = sys.ps3 + "relax_data.write(" 405 text = text + "run=" + `run` 406 text = text + ", ri_label=" + `ri_label` 407 text = text + ", frq_label=" + `frq_label` 408 text = text + ", file=" + `file` 409 text = text + ", dir=" + `dir` 410 text = text + ", force=" + `force` + ")" 411 print text 412 413 # The run argument. 414 if type(run) != str: 415 raise RelaxStrError, ('run', run) 416 417 # Relaxation data type. 418 if type(ri_label) != str: 419 raise RelaxStrError, ('relaxation label', ri_label) 420 421 # Frequency label. 422 if type(frq_label) != str: 423 raise RelaxStrError, ('frequency label', frq_label) 424 425 # File. 426 if file != None and type(file) != str: 427 raise RelaxNoneStrError, ('file name', file) 428 429 # Directory. 430 if dir != None and type(dir) != str: 431 raise RelaxNoneStrError, ('directory name', dir) 432 433 # The force flag. 434 if type(force) != int or (force != 0 and force != 1): 435 raise RelaxBinError, ('force flag', force) 436 437 # Execute the functional code. 438 self.__relax__.specific.relax_data.write(run=run, ri_label=ri_label, frq_label=frq_label, file=file, dir=dir, force=force)
439