Package specific_fns :: Module jw_mapping
[hide private]
[frames] | no frames]

Source Code for Module specific_fns.jw_mapping

  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  from re import search 
 24  from string import replace 
 25   
 26  from base_class import Common_functions 
 27  from maths_fns.jw_mapping import Mapping 
 28   
 29   
30 -class Jw_mapping(Common_functions):
31 - def __init__(self, relax):
32 """Class containing functions specific to reduced spectral density mapping.""" 33 34 self.relax = relax
35 36
37 - def calculate(self, run=None, print_flag=1, sim_index=None):
38 """Calculation of the spectral density values.""" 39 40 # Run argument. 41 self.run = run 42 43 # Test if the frequency has been set. 44 if not hasattr(self.relax.data, 'jw_frq') or not self.relax.data.jw_frq.has_key(self.run) or type(self.relax.data.jw_frq[self.run]) != float: 45 raise RelaxError, "The frequency for the run " + `self.run` + " has not been set up." 46 47 # Test if the nucleus type has been set. 48 if not hasattr(self.relax.data, 'gx'): 49 raise RelaxNucleusError 50 51 # Test if the sequence data is loaded. 52 if not self.relax.data.res.has_key(self.run): 53 raise RelaxNoSequenceError, self.run 54 55 # Test if the CSA and bond length values have been set. 56 for i in xrange(len(self.relax.data.res[self.run])): 57 # Skip unselected residues. 58 if not self.relax.data.res[self.run][i].select: 59 continue 60 61 # CSA value. 62 if not hasattr(self.relax.data.res[self.run][i], 'csa') or self.relax.data.res[self.run][i].csa == None: 63 raise RelaxNoValueError, "CSA" 64 65 # Bond length value. 66 if not hasattr(self.relax.data.res[self.run][i], 'r') or self.relax.data.res[self.run][i].r == None: 67 raise RelaxNoValueError, "bond length" 68 69 # Frequency index. 70 if self.relax.data.jw_frq[self.run] not in self.relax.data.frq[self.run]: 71 raise RelaxError, "No relaxation data corresponding to the frequency " + `self.relax.data.jw_frq[self.run]` + " has been loaded." 72 73 # Reduced spectral density mapping. 74 for i in xrange(len(self.relax.data.res[self.run])): 75 # Reassign data structure. 76 data = self.relax.data.res[self.run][i] 77 78 # Skip unselected residues. 79 if not data.select: 80 continue 81 82 # Residue specific frequency index. 83 frq_index = None 84 for j in xrange(data.num_frq): 85 if data.frq[j] == self.relax.data.jw_frq[self.run]: 86 frq_index = j 87 if frq_index == None: 88 continue 89 90 # Set the r1, r2, and NOE to None. 91 r1 = None 92 r2 = None 93 noe = None 94 95 # Get the R1, R2, and NOE values corresponding to the set frequency. 96 for j in xrange(data.num_ri): 97 # R1. 98 if data.remap_table[j] == frq_index and data.ri_labels[j] == 'R1': 99 if sim_index == None: 100 r1 = data.relax_data[j] 101 else: 102 r1 = data.relax_sim_data[sim_index][j] 103 104 # R2. 105 if data.remap_table[j] == frq_index and data.ri_labels[j] == 'R2': 106 if sim_index == None: 107 r2 = data.relax_data[j] 108 else: 109 r2 = data.relax_sim_data[sim_index][j] 110 111 # NOE. 112 if data.remap_table[j] == frq_index and data.ri_labels[j] == 'NOE': 113 if sim_index == None: 114 noe = data.relax_data[j] 115 else: 116 noe = data.relax_sim_data[sim_index][j] 117 118 # Skip the residue if not all of the three value exist. 119 if r1 == None or r2 == None or noe == None: 120 continue 121 122 # Initialise the function to calculate. 123 self.jw = Mapping(frq=self.relax.data.jw_frq[self.run], gx=self.relax.data.gx, gh=self.relax.data.gh, mu0=self.relax.data.mu0, h_bar=self.relax.data.h_bar) 124 125 # Calculate the spectral density values. 126 j0, jwx, jwh = self.jw.func(r=data.r, csa=data.csa, r1=r1, r2=r2, noe=noe) 127 128 # Reduced spectral density values. 129 if sim_index == None: 130 data.j0 = j0 131 data.jwx = jwx 132 data.jwh = jwh 133 134 # Monte Carlo simulated reduced spectral density values. 135 else: 136 # Initialise the simulation data structures. 137 self.data_init(data, sim=1) 138 if data.j0_sim == None: 139 data.j0_sim = [] 140 data.jwx_sim = [] 141 data.jwh_sim = [] 142 143 # Reduced spectral density values. 144 data.j0_sim.append(j0) 145 data.jwx_sim.append(jwx) 146 data.jwh_sim.append(jwh)
147 148
149 - def data_init(self, data, sim=0):
150 """Function for initialising the data structures.""" 151 152 # Get the data names. 153 data_names = self.data_names() 154 155 # Loop over the data structure names. 156 for name in data_names: 157 # Simulation data structures. 158 if sim: 159 # Add '_sim' to the names. 160 name = name + '_sim' 161 162 # If the name is not in 'data', add it. 163 if not hasattr(data, name): 164 # Set the attribute. 165 setattr(data, name, None)
166 167
168 - def data_names(self):
169 """Function for returning a list of names of data structures. 170 171 Description 172 ~~~~~~~~~~~ 173 174 r: Bond length. 175 176 csa: CSA value. 177 178 j0: Spectral density value at 0 MHz. 179 180 jwx: Spectral density value at the frequency of the heteronucleus. 181 182 jwh: Spectral density value at the frequency of the heteronucleus. 183 """ 184 185 # Initialise. 186 names = [] 187 188 # Values. 189 names.append('r') 190 names.append('csa') 191 192 # Spectral density values. 193 names.append('j0') 194 names.append('jwx') 195 names.append('jwh') 196 197 return names
198 199
200 - def default_value(self, param):
201 """ 202 Reduced spectral density mapping default values 203 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 204 205 _______________________________________________________________________________________ 206 | | | | 207 | Data type | Object name | Value | 208 |_______________________________________|______________|______________________________| 209 | | | | 210 | Bond length | 'r' | 1.02 * 1e-10 | 211 | | | | 212 | CSA | 'csa' | -170 * 1e-6 | 213 |_______________________________________|______________|______________________________| 214 215 """ 216 217 # Bond length. 218 if param == 'r': 219 return 1.02 * 1e-10 220 221 # CSA. 222 if param == 'CSA': 223 return -170 * 1e-6
224 225
226 - def num_instances(self, run=None):
227 """Function for returning the number of instances.""" 228 229 # Arguments. 230 self.run = run 231 232 return len(self.relax.data.res[self.run])
233 234
235 - def return_conversion_factor(self, stat_type):
236 """Dummy function for returning 1.0.""" 237 238 return 1.0
239 240
241 - def return_data_name(self, name):
242 """ 243 Reduced spectral density mapping data type string matching patterns 244 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 245 246 ____________________________________________________________________________________________ 247 | | | | 248 | Data type | Object name | Patterns | 249 |________________________|______________|__________________________________________________| 250 | | | | 251 | J(0) | 'j0' | '^[Jj]0$' or '[Jj](0)' | 252 | | | | 253 | J(wX) | 'jwx' | '^[Jj]w[Xx]$' or '[Jj](w[Xx])' | 254 | | | | 255 | J(wH) | 'jwh' | '^[Jj]w[Hh]$' or '[Jj](w[Hh])' | 256 | | | | 257 | Bond length | 'r' | '^r$' or '[Bb]ond[ -_][Ll]ength' | 258 | | | | 259 | CSA | 'csa' | '^[Cc][Ss][Aa]$' | 260 |________________________|______________|__________________________________________________| 261 262 """ 263 264 # J(0). 265 if search('^[Jj]0$', name) or search('[Jj](0)', name): 266 return 'j0' 267 268 # J(wX). 269 if search('^[Jj]w[Xx]$', name) or search('[Jj](w[Xx])', name): 270 return 'jwx' 271 272 # J(wH). 273 if search('^[Jj]w[Hh]$', name) or search('[Jj](w[Hh])', name): 274 return 'jwh' 275 276 # Bond length. 277 if search('^r$', name) or search('[Bb]ond[ -_][Ll]ength', name): 278 return 'r' 279 280 # CSA. 281 if search('^[Cc][Ss][Aa]$', name): 282 return 'csa'
283 284
285 - def return_grace_string(self, data_type):
286 """Function for returning the Grace string representing the data type for axis labelling.""" 287 288 # Get the object name. 289 object_name = self.return_data_name(data_type) 290 291 # J(0). 292 if object_name == 'j0': 293 return '\\qJ(0)\\Q' 294 295 # J(wX). 296 elif object_name == 'jwx': 297 return '\\qJ(\\xw\\f{}\\sX\\N)\\Q' 298 299 # J(wH). 300 elif object_name == 'jwh': 301 return '\\qJ(\\xw\\f{}\\sH\\N)\\Q' 302 303 # Bond length. 304 elif object_name == 'r': 305 return 'Bond length' 306 307 # CSA. 308 elif object_name == 'csa': 309 return '\\qCSA\\Q'
310 311
312 - def return_units(self, data_type):
313 """Function for returning a string representing the parameters units. 314 315 For example, the internal representation of te is in seconds, whereas the external 316 representation is in picoseconds, therefore this function will return the string 317 'picoseconds' for te. 318 """ 319 320 # Get the object name. 321 object_name = self.return_data_name(data_type) 322 323 # Bond length (Angstrom). 324 if object_name == 'r': 325 return 'Angstrom' 326 327 # CSA (ppm). 328 elif object_name == 'csa': 329 return 'ppm'
330 331
332 - def return_value(self, run, i, data_type):
333 """Function for returning the value and error corresponding to 'data_type'.""" 334 335 # Arguments. 336 self.run = run 337 338 # Remap the data structure 'self.relax.data.res[run][i]'. 339 data = self.relax.data.res[run][i] 340 341 # Get the object. 342 object_name = self.return_data_name(data_type) 343 if not object_name: 344 raise RelaxError, "The reduced spectral density mapping data type " + `data_type` + " does not exist." 345 object_error = object_name + "_err" 346 347 # Get the value. 348 value = None 349 if hasattr(data, object_name): 350 value = getattr(data, object_name) 351 352 # Get the error. 353 error = None 354 if hasattr(data, object_error): 355 error = getattr(data, object_error) 356 357 # Return the data. 358 return value, error
359 360
361 - def set(self, run=None, value=None, error=None, data_type=None, index=None):
362 """ 363 Reduced spectral density mapping set details 364 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 365 366 In reduced spectral density mapping, only two values can be set, the bond length and CSA 367 value. These must be set prior to the calculation of spectral density values. 368 369 """ 370 371 # Arguments. 372 self.run = run 373 374 # Setting the model parameters prior to calculation. 375 #################################################### 376 377 if data_type == None: 378 # The values are supplied by the user: 379 if value: 380 # Test if the length of the value array is equal to 2. 381 if len(value) != 2: 382 raise RelaxError, "The length of " + `len(value)` + " of the value array must be equal to two." 383 384 # Default values. 385 else: 386 # Set 'value' to an empty array. 387 value = [] 388 389 # CSA and Bond length. 390 value.append(self.default_value('csa')) 391 value.append(self.default_value('r')) 392 393 # Initilise data. 394 if not hasattr(self.relax.data.res[self.run][index], 'csa') or not hasattr(self.relax.data.res[self.run][index], 'csa'): 395 self.data_init(self.relax.data.res[self.run][index]) 396 397 # CSA and Bond length. 398 setattr(self.relax.data.res[self.run][index], 'csa', float(value[0])) 399 setattr(self.relax.data.res[self.run][index], 'r', float(value[1])) 400 401 402 # Individual data type. 403 ####################### 404 405 else: 406 # Get the object. 407 object_name = self.return_data_name(data_type) 408 if not object_name: 409 raise RelaxError, "The reduced spectral density mapping data type " + `data_type` + " does not exist." 410 411 # Initialise all data if it doesn't exist. 412 if not hasattr(self.relax.data.res[self.run][index], object_name): 413 self.data_init(self.relax.data.res[self.run][index]) 414 415 # Default value. 416 if value == None: 417 value = self.default_value(object_name) 418 419 # Set the value. 420 setattr(self.relax.data.res[self.run][index], object_name, float(value)) 421 422 # Set the error. 423 if error != None: 424 setattr(self.relax.data.res[self.run][index], object_name+'_error', float(error))
425 426
427 - def set_frq(self, run=None, frq=None):
428 """Function for selecting which relaxation data to use in the J(w) mapping.""" 429 430 # Run argument. 431 self.run = run 432 433 # Test if the run exists. 434 if not self.run in self.relax.data.run_names: 435 raise RelaxNoRunError, self.run 436 437 # Test if the run type is set to 'jw'. 438 function_type = self.relax.data.run_types[self.relax.data.run_names.index(self.run)] 439 if function_type != 'jw': 440 raise RelaxFuncSetupError, self.relax.specific_setup.get_string(function_type) 441 442 # Test if the frequency has been set. 443 if hasattr(self.relax.data, 'jw_frq') and self.relax.data.jw_frq.has_key(self.run): 444 raise RelaxError, "The frequency for the run " + `self.run` + " has already been set." 445 446 # Create the data structure if it doesn't exist. 447 if not hasattr(self.relax.data, 'jw_frq'): 448 self.relax.data.jw_frq = {} 449 450 # Set the frequency. 451 self.relax.data.jw_frq[self.run] = frq
452 453
454 - def set_error(self, run, instance, index, error):
455 """Function for setting parameter errors.""" 456 457 # Arguments. 458 self.run = run 459 460 # Return J(0) sim data. 461 if index == 0: 462 self.relax.data.res[self.run][instance].j0_err = error 463 464 # Return J(wX) sim data. 465 if index == 1: 466 self.relax.data.res[self.run][instance].jwx_err = error 467 468 # Return J(wH) sim data. 469 if index == 2: 470 self.relax.data.res[self.run][instance].jwh_err = error
471 472
473 - def sim_return_param(self, run, instance, index):
474 """Function for returning the array of simulation parameter values.""" 475 476 # Arguments. 477 self.run = run 478 479 # Return J(0) sim data. 480 if index == 0: 481 return self.relax.data.res[self.run][instance].j0_sim 482 483 # Return J(wX) sim data. 484 if index == 1: 485 return self.relax.data.res[self.run][instance].jwx_sim 486 487 # Return J(wH) sim data. 488 if index == 2: 489 return self.relax.data.res[self.run][instance].jwh_sim
490 491
492 - def write_columnar_line(self, file=None, num=None, name=None, select=None, data_set=None, nucleus=None, wH=None, j0=None, jwx=None, jwh=None, r=None, csa=None, ri_labels=None, remap_table=None, frq_labels=None, frq=None, ri=None, ri_error=None):
493 """Function for printing a single line of the columnar formatted results.""" 494 495 # Residue number and name. 496 file.write("%-4s %-5s " % (num, name)) 497 498 # Selected flag and data set. 499 file.write("%-9s %-9s " % (select, data_set)) 500 if not select: 501 file.write("\n") 502 return 503 504 # Nucleus. 505 file.write("%-7s " % nucleus) 506 507 # Proton frequency. 508 file.write("%-25s " % wH) 509 510 # Parameters. 511 file.write("%-25s " % j0) 512 file.write("%-25s " % jwx) 513 file.write("%-25s " % jwh) 514 file.write("%-25s " % r) 515 file.write("%-25s " % csa) 516 517 # Relaxation data setup. 518 if ri_labels: 519 file.write("%-40s " % ri_labels) 520 file.write("%-25s " % remap_table) 521 file.write("%-25s " % frq_labels) 522 file.write("%-30s " % frq) 523 524 # Relaxation data. 525 if ri: 526 for i in xrange(len(ri)): 527 if ri[i] == None: 528 file.write("%-25s " % 'None') 529 else: 530 file.write("%-25s " % ri[i]) 531 532 # Relaxation errors. 533 if ri_error: 534 for i in xrange(len(ri_error)): 535 if ri_error[i] == None: 536 file.write("%-25s " % 'None') 537 else: 538 file.write("%-25s " % ri_error[i]) 539 540 # End of the line. 541 file.write("\n")
542 543
544 - def write_columnar_results(self, file, run):
545 """Function for printing the results into a file.""" 546 547 # Arguments. 548 self.run = run 549 550 # Test if the run exists. 551 if not self.run in self.relax.data.run_names: 552 raise RelaxNoRunError, self.run 553 554 # Test if sequence data is loaded. 555 if not self.relax.data.res.has_key(self.run): 556 raise RelaxNoSequenceError, self.run 557 558 559 # Header. 560 ######### 561 562 # Relaxation data and errors. 563 ri = [] 564 ri_error = [] 565 if hasattr(self.relax.data, 'num_ri'): 566 for i in xrange(self.relax.data.num_ri[self.run]): 567 ri.append('Ri_(' + self.relax.data.ri_labels[self.run][i] + "_" + self.relax.data.frq_labels[self.run][self.relax.data.remap_table[self.run][i]] + ")") 568 ri_error.append('Ri_error_(' + self.relax.data.ri_labels[self.run][i] + "_" + self.relax.data.frq_labels[self.run][self.relax.data.remap_table[self.run][i]] + ")") 569 570 # Write the header line. 571 self.write_columnar_line(file=file, num='Num', name='Name', select='Selected', data_set='Data_set', nucleus='Nucleus', wH='Proton_frq_(MHz)', j0='J(0)', jwx='J(wX)', jwh='J(wH)', r='Bond_length_(A)', csa='CSA_(ppm)', ri_labels='Ri_labels', remap_table='Remap_table', frq_labels='Frq_labels', frq='Frequencies', ri=ri, ri_error=ri_error) 572 573 574 # Values. 575 ######### 576 577 # Nucleus. 578 nucleus = self.relax.generic.nuclei.find_nucleus() 579 580 # The proton frequency in MHz. 581 wH = self.relax.data.jw_frq[self.run] / 1e6 582 583 # Relaxation data setup. 584 try: 585 ri_labels = replace(`self.relax.data.ri_labels[self.run]`, ' ', '') 586 remap_table = replace(`self.relax.data.remap_table[self.run]`, ' ', '') 587 frq_labels = replace(`self.relax.data.frq_labels[self.run]`, ' ', '') 588 frq = replace(`self.relax.data.frq[self.run]`, ' ', '') 589 except AttributeError: 590 ri_labels = `None` 591 remap_table = `None` 592 frq_labels = `None` 593 frq = `None` 594 595 # Loop over the sequence. 596 for i in xrange(len(self.relax.data.res[self.run])): 597 # Reassign data structure. 598 data = self.relax.data.res[self.run][i] 599 600 # Unselected residues. 601 if not data.select: 602 self.write_columnar_line(file=file, num=data.num, name=data.name, select=0, data_set='value') 603 continue 604 605 # J(0). 606 j0 = None 607 if hasattr(data, 'j0'): 608 j0 = data.j0 609 610 # J(wX). 611 jwx = None 612 if hasattr(data, 'jwx'): 613 jwx = data.jwx 614 615 # J(wH). 616 jwh = None 617 if hasattr(data, 'jwh'): 618 jwh = data.jwh 619 620 # Bond length. 621 r = None 622 if hasattr(data, 'r') and data.r != None: 623 r = data.r / 1e-10 624 625 # CSA. 626 csa = None 627 if hasattr(data, 'csa') and data.csa != None: 628 csa = data.csa / 1e-6 629 630 # Relaxation data and errors. 631 ri = [] 632 ri_error = [] 633 if hasattr(self.relax.data, 'num_ri'): 634 for i in xrange(self.relax.data.num_ri[self.run]): 635 # Find the residue specific data corresponding to i. 636 index = None 637 for j in xrange(data.num_ri): 638 if data.ri_labels[j] == self.relax.data.ri_labels[self.run][i] and data.frq_labels[data.remap_table[j]] == self.relax.data.frq_labels[self.run][self.relax.data.remap_table[self.run][i]]: 639 index = j 640 641 # Data exists for this data type. 642 try: 643 ri.append(`data.relax_data[index]`) 644 ri_error.append(`data.relax_error[index]`) 645 except: 646 ri.append(None) 647 ri_error.append(None) 648 649 # Write the line. 650 self.write_columnar_line(file=file, num=data.num, name=data.name, select=data.select, data_set='value', nucleus=nucleus, wH=`wH`, j0=`j0`, jwx=`jwx`, jwh=`jwh`, r=`r`, csa=`csa`, ri_labels=ri_labels, remap_table=remap_table, frq_labels=frq_labels, frq=frq, ri=ri, ri_error=ri_error) 651 652 653 # Errors. 654 ######### 655 656 # Skip this section and the next if no simulations have been setup. 657 if not hasattr(self.relax.data, 'sim_state'): 658 return 659 elif self.relax.data.sim_state[self.run] == 0: 660 return 661 662 # Loop over the sequence. 663 for i in xrange(len(self.relax.data.res[self.run])): 664 # Reassign data structure. 665 data = self.relax.data.res[self.run][i] 666 667 # Unselected residues. 668 if not data.select: 669 self.write_columnar_line(file=file, num=data.num, name=data.name, select=0, data_set='error') 670 continue 671 672 # J(0). 673 j0 = None 674 if hasattr(data, 'j0_err'): 675 j0 = data.j0_err 676 677 # J(wX). 678 jwx = None 679 if hasattr(data, 'jwx_err'): 680 jwx = data.jwx_err 681 682 # J(wH). 683 jwh = None 684 if hasattr(data, 'jwh_err'): 685 jwh = data.jwh_err 686 687 # Bond length. 688 r = None 689 if hasattr(data, 'r_err') and data.r_err != None: 690 r = data.r_err / 1e-10 691 692 # CSA. 693 csa = None 694 if hasattr(data, 'csa_err') and data.csa_err != None: 695 csa = data.csa_err / 1e-6 696 697 # Relaxation data and errors. 698 ri = [] 699 ri_error = [] 700 for i in xrange(self.relax.data.num_ri[self.run]): 701 ri.append(None) 702 ri_error.append(None) 703 704 # Write the line. 705 self.write_columnar_line(file=file, num=data.num, name=data.name, select=data.select, data_set='error', nucleus=nucleus, wH=`wH`, j0=`j0`, jwx=`jwx`, jwh=`jwh`, r=`r`, csa=`csa`, ri_labels=ri_labels, remap_table=remap_table, frq_labels=frq_labels, frq=frq, ri=ri, ri_error=ri_error) 706 707 708 # Simulation values. 709 #################### 710 711 # Loop over the simulations. 712 for i in xrange(self.relax.data.sim_number[self.run]): 713 # Loop over the sequence. 714 for j in xrange(len(self.relax.data.res[self.run])): 715 # Reassign data structure. 716 data = self.relax.data.res[self.run][j] 717 718 # Unselected residues. 719 if not data.select: 720 self.write_columnar_line(file=file, num=data.num, name=data.name, select=0, data_set='sim_'+`i`) 721 continue 722 723 # J(0). 724 j0 = None 725 if hasattr(data, 'j0_sim'): 726 j0 = data.j0_sim[i] 727 728 # J(wX). 729 jwx = None 730 if hasattr(data, 'jwx_sim'): 731 jwx = data.jwx_sim[i] 732 733 # J(wH). 734 jwh = None 735 if hasattr(data, 'jwh_sim'): 736 jwh = data.jwh_sim[i] 737 738 # Bond length. 739 r = None 740 if hasattr(data, 'r_sim') and data.r_sim != None and data.r_sim[i] != None: 741 r = data.r_sim[i] / 1e-10 742 743 # CSA. 744 csa = None 745 if hasattr(data, 'csa_sim') and data.csa_sim != None and data.csa_sim[i] != None: 746 csa = data.csa_sim[i] / 1e-6 747 748 # Relaxation data and errors. 749 ri = [] 750 ri_error = [] 751 for k in xrange(self.relax.data.num_ri[self.run]): 752 # Find the residue specific data corresponding to k. 753 index = None 754 for l in xrange(data.num_ri): 755 if data.ri_labels[l] == self.relax.data.ri_labels[self.run][k] and data.frq_labels[data.remap_table[l]] == self.relax.data.frq_labels[self.run][self.relax.data.remap_table[self.run][k]]: 756 index = l 757 758 # Data exists for this data type. 759 try: 760 ri.append(`data.relax_sim_data[i][index]`) 761 ri_error.append(`data.relax_error[index]`) 762 except: 763 ri.append(None) 764 ri_error.append(None) 765 766 # Write the line. 767 self.write_columnar_line(file=file, num=data.num, name=data.name, select=data.select, data_set='sim_'+`i`, nucleus=nucleus, wH=`wH`, j0=`j0`, jwx=`jwx`, jwh=`jwh`, r=`r`, csa=`csa`, ri_labels=ri_labels, remap_table=remap_table, frq_labels=frq_labels, frq=frq, ri=ri, ri_error=ri_error)
768