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-2006 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' | -172 * 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 -172 * 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 # Test if sequence data is loaded. 233 if not self.relax.data.res.has_key(self.run): 234 return 0 235 236 # Return the number of residues. 237 return len(self.relax.data.res[self.run])
238 239
240 - def overfit_deselect(self, run):
241 """Function for deselecting residues without sufficient data to support calculation""" 242 243 # Test the sequence data exists: 244 if not self.relax.data.res.has_key(run): 245 raise RelaxNoSequenceError, run 246 247 # Loop over residue data: 248 for residue in self.relax.data.res[run]: 249 250 # Check for sufficient data 251 if not hasattr(residue, 'relax_data'): 252 residue.select = 0 253 continue 254 255 # Require 3 or more data points 256 if len(residue.relax_data) < 3: 257 residue.select = 0 258 continue
259 260
261 - def return_conversion_factor(self, stat_type):
262 """Dummy function for returning 1.0.""" 263 264 return 1.0
265 266
267 - def return_data_name(self, name):
268 """ 269 Reduced spectral density mapping data type string matching patterns 270 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 271 272 ____________________________________________________________________________________________ 273 | | | | 274 | Data type | Object name | Patterns | 275 |________________________|______________|__________________________________________________| 276 | | | | 277 | J(0) | 'j0' | '^[Jj]0$' or '[Jj]\(0\)' | 278 | | | | 279 | J(wX) | 'jwx' | '^[Jj]w[Xx]$' or '[Jj]\(w[Xx]\)' | 280 | | | | 281 | J(wH) | 'jwh' | '^[Jj]w[Hh]$' or '[Jj]\(w[Hh]\)' | 282 | | | | 283 | Bond length | 'r' | '^r$' or '[Bb]ond[ -_][Ll]ength' | 284 | | | | 285 | CSA | 'csa' | '^[Cc][Ss][Aa]$' | 286 |________________________|______________|__________________________________________________| 287 288 """ 289 290 # J(0). 291 if search('^[Jj]0$', name) or search('[Jj]\(0\)', name): 292 return 'j0' 293 294 # J(wX). 295 if search('^[Jj]w[Xx]$', name) or search('[Jj]\(w[Xx]\)', name): 296 return 'jwx' 297 298 # J(wH). 299 if search('^[Jj]w[Hh]$', name) or search('[Jj]\(w[Hh]\)', name): 300 return 'jwh' 301 302 # Bond length. 303 if search('^r$', name) or search('[Bb]ond[ -_][Ll]ength', name): 304 return 'r' 305 306 # CSA. 307 if search('^[Cc][Ss][Aa]$', name): 308 return 'csa'
309 310
311 - def return_grace_string(self, data_type):
312 """Function for returning the Grace string representing the data type for axis labelling.""" 313 314 # Get the object name. 315 object_name = self.return_data_name(data_type) 316 317 # J(0). 318 if object_name == 'j0': 319 return '\\qJ(0)\\Q' 320 321 # J(wX). 322 elif object_name == 'jwx': 323 return '\\qJ(\\xw\\f{}\\sX\\N)\\Q' 324 325 # J(wH). 326 elif object_name == 'jwh': 327 return '\\qJ(\\xw\\f{}\\sH\\N)\\Q' 328 329 # Bond length. 330 elif object_name == 'r': 331 return 'Bond length' 332 333 # CSA. 334 elif object_name == 'csa': 335 return '\\qCSA\\Q'
336 337
338 - def return_units(self, data_type):
339 """Function for returning a string representing the parameters units. 340 341 For example, the internal representation of te is in seconds, whereas the external 342 representation is in picoseconds, therefore this function will return the string 343 'picoseconds' for te. 344 """ 345 346 # Get the object name. 347 object_name = self.return_data_name(data_type) 348 349 # Bond length (Angstrom). 350 if object_name == 'r': 351 return 'Angstrom' 352 353 # CSA (ppm). 354 elif object_name == 'csa': 355 return 'ppm'
356 357
358 - def set(self, run=None, value=None, error=None, param=None, index=None):
359 """ 360 Reduced spectral density mapping set details 361 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 362 363 In reduced spectral density mapping, only two values can be set, the bond length and CSA 364 value. These must be set prior to the calculation of spectral density values. 365 366 """ 367 368 # Arguments. 369 self.run = run 370 371 # Setting the model parameters prior to calculation. 372 #################################################### 373 374 if param == None: 375 # The values are supplied by the user: 376 if value: 377 # Test if the length of the value array is equal to 2. 378 if len(value) != 2: 379 raise RelaxError, "The length of " + `len(value)` + " of the value array must be equal to two." 380 381 # Default values. 382 else: 383 # Set 'value' to an empty array. 384 value = [] 385 386 # CSA and Bond length. 387 value.append(self.default_value('csa')) 388 value.append(self.default_value('r')) 389 390 # Initilise data. 391 if not hasattr(self.relax.data.res[self.run][index], 'csa') or not hasattr(self.relax.data.res[self.run][index], 'r'): 392 self.data_init(self.relax.data.res[self.run][index]) 393 394 # CSA and Bond length. 395 setattr(self.relax.data.res[self.run][index], 'csa', float(value[0])) 396 setattr(self.relax.data.res[self.run][index], 'r', float(value[1])) 397 398 399 # Individual data type. 400 ####################### 401 402 else: 403 # Get the object. 404 object_name = self.return_data_name(param) 405 if not object_name: 406 raise RelaxError, "The reduced spectral density mapping data type " + `param` + " does not exist." 407 408 # Initialise all data if it doesn't exist. 409 if not hasattr(self.relax.data.res[self.run][index], object_name): 410 self.data_init(self.relax.data.res[self.run][index]) 411 412 # Default value. 413 if value == None: 414 value = self.default_value(object_name) 415 416 # Set the value. 417 setattr(self.relax.data.res[self.run][index], object_name, float(value)) 418 419 # Set the error. 420 if error != None: 421 setattr(self.relax.data.res[self.run][index], object_name+'_err', float(error))
422 423
424 - def set_frq(self, run=None, frq=None):
425 """Function for selecting which relaxation data to use in the J(w) mapping.""" 426 427 # Run argument. 428 self.run = run 429 430 # Test if the run exists. 431 if not self.run in self.relax.data.run_names: 432 raise RelaxNoRunError, self.run 433 434 # Test if the run type is set to 'jw'. 435 function_type = self.relax.data.run_types[self.relax.data.run_names.index(self.run)] 436 if function_type != 'jw': 437 raise RelaxFuncSetupError, self.relax.specific_setup.get_string(function_type) 438 439 # Test if the frequency has been set. 440 if hasattr(self.relax.data, 'jw_frq') and self.relax.data.jw_frq.has_key(self.run): 441 raise RelaxError, "The frequency for the run " + `self.run` + " has already been set." 442 443 # Create the data structure if it doesn't exist. 444 if not hasattr(self.relax.data, 'jw_frq'): 445 self.relax.data.jw_frq = {} 446 447 # Set the frequency. 448 self.relax.data.jw_frq[self.run] = frq
449 450
451 - def set_error(self, run, instance, index, error):
452 """Function for setting parameter errors.""" 453 454 # Arguments. 455 self.run = run 456 457 # Return J(0) sim data. 458 if index == 0: 459 self.relax.data.res[self.run][instance].j0_err = error 460 461 # Return J(wX) sim data. 462 if index == 1: 463 self.relax.data.res[self.run][instance].jwx_err = error 464 465 # Return J(wH) sim data. 466 if index == 2: 467 self.relax.data.res[self.run][instance].jwh_err = error
468 469
470 - def sim_return_param(self, run, instance, index):
471 """Function for returning the array of simulation parameter values.""" 472 473 # Arguments. 474 self.run = run 475 476 # Skip unselected residues. 477 if not self.relax.data.res[self.run][instance].select: 478 return 479 480 # Return J(0) sim data. 481 if index == 0: 482 return self.relax.data.res[self.run][instance].j0_sim 483 484 # Return J(wX) sim data. 485 if index == 1: 486 return self.relax.data.res[self.run][instance].jwx_sim 487 488 # Return J(wH) sim data. 489 if index == 2: 490 return self.relax.data.res[self.run][instance].jwh_sim
491 492
493 - def sim_return_selected(self, run, instance):
494 """Function for returning the array of selected simulation flags.""" 495 496 # Arguments. 497 self.run = run 498 499 # Multiple instances. 500 return self.relax.data.res[self.run][instance].select_sim
501 502
503 - def set_selected_sim(self, run, instance, select_sim):
504 """Function for returning the array of selected simulation flags.""" 505 506 # Arguments. 507 self.run = run 508 509 # Multiple instances. 510 self.relax.data.res[self.run][instance].select_sim = select_sim
511 512
513 - def sim_pack_data(self, run, i, sim_data):
514 """Function for packing Monte Carlo simulation data.""" 515 516 # Test if the simulation data already exists. 517 if hasattr(self.relax.data.res[run][i], 'relax_sim_data'): 518 raise RelaxError, "Monte Carlo simulation data already exists." 519 520 # Create the data structure. 521 self.relax.data.res[run][i].relax_sim_data = sim_data
522 523
524 - 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):
525 """Function for printing a single line of the columnar formatted results.""" 526 527 # Residue number and name. 528 file.write("%-4s %-5s " % (num, name)) 529 530 # Selected flag and data set. 531 file.write("%-9s %-9s " % (select, data_set)) 532 533 # Nucleus. 534 file.write("%-7s " % nucleus) 535 536 # Proton frequency. 537 file.write("%-25s " % wH) 538 539 # Parameters. 540 file.write("%-25s " % j0) 541 file.write("%-25s " % jwx) 542 file.write("%-25s " % jwh) 543 file.write("%-25s " % r) 544 file.write("%-25s " % csa) 545 546 # Relaxation data setup. 547 if ri_labels: 548 file.write("%-40s " % ri_labels) 549 file.write("%-25s " % remap_table) 550 file.write("%-25s " % frq_labels) 551 file.write("%-30s " % frq) 552 553 # Relaxation data. 554 if ri: 555 for i in xrange(len(ri)): 556 if ri[i] == None: 557 file.write("%-25s " % 'None') 558 else: 559 file.write("%-25s " % ri[i]) 560 561 # Relaxation errors. 562 if ri_error: 563 for i in xrange(len(ri_error)): 564 if ri_error[i] == None: 565 file.write("%-25s " % 'None') 566 else: 567 file.write("%-25s " % ri_error[i]) 568 569 # End of the line. 570 file.write("\n")
571 572
573 - def write_columnar_results(self, file, run):
574 """Function for printing the results into a file.""" 575 576 # Arguments. 577 self.run = run 578 579 # Test if the run exists. 580 if not self.run in self.relax.data.run_names: 581 raise RelaxNoRunError, self.run 582 583 # Test if sequence data is loaded. 584 if not self.relax.data.res.has_key(self.run): 585 raise RelaxNoSequenceError, self.run 586 587 588 # Header. 589 ######### 590 591 # Relaxation data and errors. 592 ri = [] 593 ri_error = [] 594 if hasattr(self.relax.data, 'num_ri'): 595 for i in xrange(self.relax.data.num_ri[self.run]): 596 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]] + ")") 597 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]] + ")") 598 599 # Write the header line. 600 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) 601 602 603 # Values. 604 ######### 605 606 # Nucleus. 607 nucleus = self.relax.generic.nuclei.find_nucleus() 608 609 # The proton frequency in MHz. 610 wH = self.relax.data.jw_frq[self.run] / 1e6 611 612 # Relaxation data setup. 613 try: 614 ri_labels = replace(`self.relax.data.ri_labels[self.run]`, ' ', '') 615 remap_table = replace(`self.relax.data.remap_table[self.run]`, ' ', '') 616 frq_labels = replace(`self.relax.data.frq_labels[self.run]`, ' ', '') 617 frq = replace(`self.relax.data.frq[self.run]`, ' ', '') 618 except AttributeError: 619 ri_labels = `None` 620 remap_table = `None` 621 frq_labels = `None` 622 frq = `None` 623 624 # Loop over the sequence. 625 for i in xrange(len(self.relax.data.res[self.run])): 626 # Reassign data structure. 627 data = self.relax.data.res[self.run][i] 628 629 # J(0). 630 j0 = None 631 if hasattr(data, 'j0'): 632 j0 = data.j0 633 634 # J(wX). 635 jwx = None 636 if hasattr(data, 'jwx'): 637 jwx = data.jwx 638 639 # J(wH). 640 jwh = None 641 if hasattr(data, 'jwh'): 642 jwh = data.jwh 643 644 # Bond length. 645 r = None 646 if hasattr(data, 'r') and data.r != None: 647 r = data.r / 1e-10 648 649 # CSA. 650 csa = None 651 if hasattr(data, 'csa') and data.csa != None: 652 csa = data.csa / 1e-6 653 654 # Relaxation data and errors. 655 ri = [] 656 ri_error = [] 657 if hasattr(self.relax.data, 'num_ri'): 658 for i in xrange(self.relax.data.num_ri[self.run]): 659 try: 660 # Find the residue specific data corresponding to i. 661 index = None 662 for j in xrange(data.num_ri): 663 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]]: 664 index = j 665 666 # Data exists for this data type. 667 ri.append(`data.relax_data[index]`) 668 ri_error.append(`data.relax_error[index]`) 669 670 # No data exists for this data type. 671 except: 672 ri.append(None) 673 ri_error.append(None) 674 675 # Write the line. 676 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) 677 678 679 # Errors. 680 ######### 681 682 # Skip this section and the next if no simulations have been setup. 683 if not hasattr(self.relax.data, 'sim_state'): 684 return 685 elif self.relax.data.sim_state[self.run] == 0: 686 return 687 688 # Loop over the sequence. 689 for i in xrange(len(self.relax.data.res[self.run])): 690 # Reassign data structure. 691 data = self.relax.data.res[self.run][i] 692 693 # J(0). 694 j0 = None 695 if hasattr(data, 'j0_err'): 696 j0 = data.j0_err 697 698 # J(wX). 699 jwx = None 700 if hasattr(data, 'jwx_err'): 701 jwx = data.jwx_err 702 703 # J(wH). 704 jwh = None 705 if hasattr(data, 'jwh_err'): 706 jwh = data.jwh_err 707 708 # Bond length. 709 r = None 710 if hasattr(data, 'r_err') and data.r_err != None: 711 r = data.r_err / 1e-10 712 713 # CSA. 714 csa = None 715 if hasattr(data, 'csa_err') and data.csa_err != None: 716 csa = data.csa_err / 1e-6 717 718 # Relaxation data and errors. 719 ri = [] 720 ri_error = [] 721 for i in xrange(self.relax.data.num_ri[self.run]): 722 ri.append(None) 723 ri_error.append(None) 724 725 # Write the line. 726 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) 727 728 729 # Simulation values. 730 #################### 731 732 # Loop over the simulations. 733 for i in xrange(self.relax.data.sim_number[self.run]): 734 # Loop over the sequence. 735 for j in xrange(len(self.relax.data.res[self.run])): 736 # Reassign data structure. 737 data = self.relax.data.res[self.run][j] 738 739 # J(0). 740 j0 = None 741 if hasattr(data, 'j0_sim'): 742 j0 = data.j0_sim[i] 743 744 # J(wX). 745 jwx = None 746 if hasattr(data, 'jwx_sim'): 747 jwx = data.jwx_sim[i] 748 749 # J(wH). 750 jwh = None 751 if hasattr(data, 'jwh_sim'): 752 jwh = data.jwh_sim[i] 753 754 # Bond length. 755 r = None 756 if hasattr(data, 'r_sim') and data.r_sim != None and data.r_sim[i] != None: 757 r = data.r_sim[i] / 1e-10 758 759 # CSA. 760 csa = None 761 if hasattr(data, 'csa_sim') and data.csa_sim != None and data.csa_sim[i] != None: 762 csa = data.csa_sim[i] / 1e-6 763 764 # Relaxation data and errors. 765 ri = [] 766 ri_error = [] 767 if hasattr(self.relax.data, 'num_ri'): 768 for k in xrange(self.relax.data.num_ri[self.run]): 769 try: 770 # Find the residue specific data corresponding to k. 771 index = None 772 for l in xrange(data.num_ri): 773 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]]: 774 index = l 775 776 # Data exists for this data type. 777 ri.append(`data.relax_sim_data[i][index]`) 778 ri_error.append(`data.relax_error[index]`) 779 780 # No data exists for this data type. 781 except: 782 ri.append(None) 783 ri_error.append(None) 784 785 # Write the line. 786 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)
787