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

Source Code for Module prompt.relax_data

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003-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 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 display the NOE relaxation data at 600 MHz from the run 'm4', type 218 219 relax> relax_data.display('m4', 'NOE', '600') 220 """ 221 222 # Function intro text. 223 if self.__relax__.interpreter.intro: 224 text = sys.ps3 + "relax_data.display(" 225 text = text + "run=" + `run` 226 text = text + ", ri_label=" + `ri_label` 227 text = text + ", frq_label=" + `frq_label` + ")" 228 print text 229 230 # The run name. 231 if type(run) != str: 232 raise RelaxStrError, ('run', run) 233 234 # Relaxation data type. 235 if type(ri_label) != str: 236 raise RelaxStrError, ('relaxation label', ri_label) 237 238 # Frequency label. 239 if type(frq_label) != str: 240 raise RelaxStrError, ('frequency label', frq_label) 241 242 # Execute the functional code. 243 self.__relax__.specific.relax_data.display(run=run, ri_label=ri_label, frq_label=frq_label)
244 245
246 - 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):
247 """Function for reading R1, R2, or NOE relaxation data from a file. 248 249 Keyword Arguments 250 ~~~~~~~~~~~~~~~~~ 251 252 run: The name of the run. 253 254 ri_label: The relaxation data type, ie 'R1', 'R2', or 'NOE'. 255 256 frq_label: The field strength label. 257 258 frq: The spectrometer frequency in Hz. 259 260 file: The name of the file containing the relaxation data. 261 262 dir: The directory where the file is located. 263 264 num_col: The residue number column (the default is 0, ie the first column). 265 266 name_col: The residue name column (the default is 1). 267 268 data_col: The relaxation data column (the default is 2). 269 270 error_col: The experimental error column (the default is 3). 271 272 sep: The column separator (the default is white space). 273 274 275 Description 276 ~~~~~~~~~~~ 277 278 The frequency label argument can be anything as long as data collected at the same field 279 strength have the same label. 280 281 282 Examples 283 ~~~~~~~~ 284 285 The following commands will read the NOE relaxation data collected at 600 MHz out of a file 286 called 'noe.600.out' where the residue numbers, residue names, data, errors are in the 287 first, second, third, and forth columns respectively. 288 289 relax> relax_data.read('m1', 'NOE', '600', 599.7 * 1e6, 'noe.600.out') 290 relax> relax_data.read('m1', ri_label='NOE', frq_label='600', frq=600.0 * 1e6, 291 file='noe.600.out') 292 293 294 The following commands will read the R2 data out of the file 'r2.out' where the residue 295 numbers, residue names, data, errors are in the second, third, fifth, and sixth columns 296 respectively. The columns are separated by commas. 297 298 relax> relax_data.read('m1', 'R2', '800 MHz', 8.0 * 1e8, 'r2.out', 1, 2, 4, 5, ',') 299 relax> relax_data.read('m1', ri_label='R2', frq_label='800 MHz', frq=8.0*1e8, 300 file='r2.out', num_col=1, name_col=2, data_col=4, error_col=5, 301 sep=',') 302 303 304 The following commands will read the R1 data out of the file 'r1.out' where the columns are 305 separated by the symbol '%' 306 307 relax> relax_data.read('m1', 'R1', '300', 300.1 * 1e6, 'r1.out', sep='%') 308 """ 309 310 # Function intro text. 311 if self.__relax__.interpreter.intro: 312 text = sys.ps3 + "relax_data.read(" 313 text = text + "run=" + `run` 314 text = text + ", ri_label=" + `ri_label` 315 text = text + ", frq_label=" + `frq_label` 316 text = text + ", frq=" + `frq` 317 text = text + ", file=" + `file` 318 text = text + ", dir=" + `dir` 319 text = text + ", num_col=" + `num_col` 320 text = text + ", name_col=" + `name_col` 321 text = text + ", data_col=" + `data_col` 322 text = text + ", error_col=" + `error_col` 323 text = text + ", sep=" + `sep` + ")" 324 print text 325 326 # The run name. 327 if type(run) != str: 328 raise RelaxStrError, ('run', run) 329 330 # Relaxation data type. 331 if type(ri_label) != str: 332 raise RelaxStrError, ('relaxation label', ri_label) 333 334 # Frequency label. 335 if type(frq_label) != str: 336 raise RelaxStrError, ('frequency label', frq_label) 337 338 # Frequency. 339 if type(frq) != float: 340 raise RelaxFloatError, ('frequency', frq) 341 342 # The file name. 343 if type(file) != str: 344 raise RelaxStrError, ('file', file) 345 346 # Directory. 347 if dir != None and type(dir) != str: 348 raise RelaxNoneStrError, ('directory name', dir) 349 350 # The number column. 351 if type(num_col) != int: 352 raise RelaxIntError, ('residue number column', num_col) 353 354 # The name column. 355 if type(name_col) != int: 356 raise RelaxIntError, ('residue name column', name_col) 357 358 # The data column. 359 if type(data_col) != int: 360 raise RelaxIntError, ('data column', data_col) 361 362 # The error column. 363 if type(error_col) != int: 364 raise RelaxIntError, ('error column', error_col) 365 366 # Column separator. 367 if sep != None and type(sep) != str: 368 raise RelaxNoneStrError, ('column separator', sep) 369 370 # Execute the functional code. 371 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)
372 373
374 - def write(self, run=None, ri_label=None, frq_label=None, file=None, dir=None, force=0):
375 """Function for writing R1, R2, or NOE relaxation data to a file. 376 377 Keyword Arguments 378 ~~~~~~~~~~~~~~~~~ 379 380 run: The name of the run. 381 382 ri_label: The relaxation data type, ie 'R1', 'R2', or 'NOE'. 383 384 frq_label: The field strength label. 385 386 file: The name of the file. 387 388 dir: The directory name. 389 390 force: A flag which, if set to 1, will cause the file to be overwritten. 391 392 393 Description 394 ~~~~~~~~~~~ 395 396 If no directory name is given, the file will be placed in the current working directory. 397 The 'ri_label' and 'frq_label' arguments are required for selecting which relaxation data 398 to write to file. 399 """ 400 401 # Function intro text. 402 if self.__relax__.interpreter.intro: 403 text = sys.ps3 + "relax_data.write(" 404 text = text + "run=" + `run` 405 text = text + ", ri_label=" + `ri_label` 406 text = text + ", frq_label=" + `frq_label` 407 text = text + ", file=" + `file` 408 text = text + ", dir=" + `dir` 409 text = text + ", force=" + `force` + ")" 410 print text 411 412 # The run argument. 413 if type(run) != str: 414 raise RelaxStrError, ('run', run) 415 416 # Relaxation data type. 417 if type(ri_label) != str: 418 raise RelaxStrError, ('relaxation label', ri_label) 419 420 # Frequency label. 421 if type(frq_label) != str: 422 raise RelaxStrError, ('frequency label', frq_label) 423 424 # File. 425 if file != None and type(file) != str: 426 raise RelaxNoneStrError, ('file name', file) 427 428 # Directory. 429 if dir != None and type(dir) != str: 430 raise RelaxNoneStrError, ('directory name', dir) 431 432 # The force flag. 433 if type(force) != int or (force != 0 and force != 1): 434 raise RelaxBinError, ('force flag', force) 435 436 # Execute the functional code. 437 self.__relax__.specific.relax_data.write(run=run, ri_label=ri_label, frq_label=frq_label, file=file, dir=dir, force=force)
438