Package maths_fns :: Module consistency_tests
[hide private]
[frames] | no frames]

Source Code for Module maths_fns.consistency_tests

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2004 Edward d'Auvergne                                        # 
  4  # Copyright (C) 2007-2008 Sebastien Morin                                     # 
  5  #                                                                             # 
  6  # This file is part of the program relax.                                     # 
  7  #                                                                             # 
  8  # relax is free software; you can redistribute it and/or modify               # 
  9  # it under the terms of the GNU General Public License as published by        # 
 10  # the Free Software Foundation; either version 2 of the License, or           # 
 11  # (at your option) any later version.                                         # 
 12  #                                                                             # 
 13  # relax is distributed in the hope that it will be useful,                    # 
 14  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 16  # GNU General Public License for more details.                                # 
 17  #                                                                             # 
 18  # You should have received a copy of the GNU General Public License           # 
 19  # along with relax; if not, write to the Free Software                        # 
 20  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 21  #                                                                             # 
 22  ############################################################################### 
 23   
 24  from Numeric import Float64, zeros 
 25  from math import pi, cos 
 26   
 27  from ri_comps import calc_fixed_csa, calc_fixed_dip, comp_csa_const_func, comp_dip_const_func 
 28   
 29   
30 -class Consistency:
31 - def __init__(self, frq=None, gx=None, gh=None, mu0=None, h_bar=None):
32 """Consistency tests for data acquired at different magnetic fields. 33 34 These three tests are used to assess the consistency of datasets aquired at different 35 magnetic fields. Inconsistency can affect extracted information from experimental data and 36 can be caused by variations in temperature, concentration, pH, water suppression, etc. 37 38 This code calculates three functions for each residue. When comparing datasets from 39 different magnetic field, the value should be the same for each function as these are field 40 independent. The J(0) function is the spectral density at the zero frequency and is obtained 41 using a reduced spectral density approach. The F_eta and F_R2 functions are the 42 consistency functions proposed by Fushman D. et al. (1998) JACS, 120: 10947-10952. 43 44 To assess the consistency of its datasets, one should first calculate those values (J(0), 45 F_eta and F_R2) for each field. Then, the user should compare values obtained for different 46 magnetic fields. Comparisons could proceed using correlation plots and histograms, and the 47 user could also calculate correlation, skewness and kurtosis coefficients. 48 """ 49 50 # Initialise the data container. 51 self.data = Data() 52 53 # Add the initial data to self.data. 54 self.data.gx = gx 55 self.data.gh = gh 56 self.data.mu0 = mu0 57 self.data.h_bar = h_bar 58 59 # The number of frequencies. 60 self.data.num_frq = 1 61 62 # Dipolar and CSA data structures. 63 self.data.dip_const_fixed = 0.0 64 self.data.csa_const_fixed = [0.0] 65 self.data.dip_const_func = 0.0 66 self.data.csa_const_func = zeros(1, Float64) 67 68 # Nuclear frequencies. 69 frq = frq * 2 * pi 70 frqX = frq * self.data.gx / self.data.gh 71 72 # Calculate the five frequencies which cause R1, R2, and NOE relaxation. 73 self.data.frq_list = zeros((1, 5), Float64) 74 self.data.frq_list[0, 1] = frqX 75 self.data.frq_list[0, 2] = frq - frqX 76 self.data.frq_list[0, 3] = frq 77 self.data.frq_list[0, 4] = frq + frqX 78 self.data.frq_sqrd_list = self.data.frq_list ** 2
79 80
81 - def calc_sigma_noe(self, noe, r1):
82 """Function for calculating the sigma NOE value.""" 83 84 return (noe - 1.0) * r1 * self.data.gx / self.data.gh
85 86
87 - def func(self, orientation=None, tc=None, r=None, csa=None, r1=None, r2=None, noe=None):
88 """Function for calculating the three consistency testing values. 89 90 Three values are returned, J(0), F_eta and F_R2. 91 """ 92 93 # Calculate the fixed component of the dipolar and CSA constants. 94 calc_fixed_dip(self.data) 95 calc_fixed_csa(self.data) 96 97 # Calculate the dipolar and CSA constants. 98 comp_dip_const_func(self.data, r) 99 comp_csa_const_func(self.data, csa) 100 101 # Rename the dipolar and CSA constants. 102 d = self.data.dip_const_func 103 c = self.data.csa_const_func[0] 104 105 # Calculate the sigma NOE value. 106 sigma_noe = self.calc_sigma_noe(noe, r1) 107 108 # Calculate J(0). 109 j0 = -1.5 / (3.0*d + c) * (0.5*r1 - r2 + 0.6*sigma_noe) 110 111 # Calculate J(wX). 112 jwx = 1.0 / (3.0*d + c) * (r1 - 1.4*sigma_noe) 113 114 # Calculate P_2. 115 # p_2 is a second rank Legendre polynomial as p_2(x) = 0.5 * (3 * (x ** 2) -1) 116 # where x is the cosine of the angle Theta when expressed in radians. 117 # 118 # Note that the angle Theta (called 'orientation' in relax) is the angle between the 15N-1H 119 # vector and the principal axis of the 15N chemical shift tensor. 120 p_2 = 0.5 * ((3.0 * (cos(orientation * pi / 180)) ** 2) -1) 121 122 # Calculate eta. 123 # eta is the cross-correlation rate between 15N CSA and 15N-1H dipolar interaction. It is 124 # expressed here as proposed in Fushman D. & Cowburn D. (1998) JACS, 120: 7109-7110. 125 eta = ((d * c/3.0) ** 0.5) * (4.0 * j0 + 3.0 * jwx) * p_2 126 127 # Calculate F_eta. 128 # F_eta is independent of the magnetic field for residues with local mobility 129 f_eta = eta * self.data.gh / (self.data.frq_list[0, 3] * (4.0 + 3.0 / (1 + (self.data.frq_list[0, 1] * tc) ** 2))) 130 131 # Calculate P_HF. 132 # P_HF is the contribution to R2 from high frequency motions. 133 # P_HF = 0.5 * d * [J(wH-wN) + 6 * J(wH) + 6 * J(wH+wN)]. 134 # Here, P_HF is described using a reduced spectral density approach. 135 p_hf = 1.3 * (self.data.gx / self.data.gh) * (1.0 - noe) * r1 136 137 # Calculate F_R2. 138 # F_R2 tests the consistency of the transverse relaxation data. 139 f_r2 = (r2 - p_hf) / ((4.0 + 3.0 / (1 + (self.data.frq_list[0, 1] * tc) ** 2)) * (d + c/3.0)) 140 141 # Return the three values. 142 return j0, f_eta, f_r2
143 144
145 -class Data:
146 - def __init__(self):
147 """Empty container for storing data."""
148