Module data
[hide private]
[frames] | no frames]

Source Code for Module data

  1  from math import pi 
  2   
  3   
4 -class data:
5 - def __init__(self, mf):
6 "Class containing all the program data" 7 8 self.mf = mf 9 10 self.init_data() 11 self.init_constants() 12 self.mfin = self.mfin_data(self.mf) 13 self.asymptotic = self.init_asymptotic() 14 self.bootstrap = self.init_bootstrap() 15 self.cv = self.init_cv() 16 self.farrow = self.init_farrow() 17 self.palmer = self.init_palmer() 18 self.overall_disc = self.init_overall_disc()
19 20 21
22 - class init_asymptotic:
23 - def __init__(self):
24 "Data specific for the model-free analysis using asymptotic model selection." 25 26 self.name = 'Asymptotic'
27 28 29
30 - class init_bootstrap:
31 - def __init__(self):
32 "Data specific for the model-free analysis using bootstrap model selection." 33 34 self.name = 'Bootstrap'
35 36 37
38 - class init_cv:
39 - def __init__(self):
40 "Data specific for the model-free analysis using bootstrap model selection." 41 42 self.name = 'Cross validation' 43 self.cv_crit = []
44 45 46
47 - class init_farrow:
48 - def __init__(self):
49 "Data specific for Farrow's model-free analysis." 50 51 self.name = 'Farrow'
52 53 54
55 - class init_overall_disc:
56 - def __init__(self):
57 "Data specific for model-free analysis using the overall discrepancy." 58 59 self.name = 'Overall' 60 self.op_data = []
61 62
63 - class init_palmer:
64 - def __init__(self):
65 "Data specific for Palmer's model-free analysis." 66 67 self.name = 'Palmer'
68 69 70
71 - class mfin_data:
72 - def __init__(self, mf):
73 "Variables for the file mfin" 74 75 self.mf = mf
76 77
78 - def default_data(self):
79 80 self.diff = self.mf.usr_param.diff 81 self.diff_search = 'none' 82 self.algorithm = 'fix' 83 self.sims = 'n' 84 self.sim_type = 'pred' 85 self.trim = self.mf.usr_param.trim 86 self.selection = 'none' 87 self.num_sim = self.mf.usr_param.num_sim
88 89 90
91 - def calc_constants(self):
92 """Calculate the dipolar and CSA constants. 93 94 Dipolar constants 95 ~~~~~~~~~~~~~~~~~ 96 1 / mu0 \ 2 (gH.gN.h_bar)**2 97 d = - . | ---- | . ---------------- 98 4 \ 4.pi / <r**6> 99 100 101 3 / mu0 \ 2 (gH.gN.h_bar)**2 102 d' = - - . | ---- | . ---------------- 103 2 \ 4.pi / <r**7> 104 105 106 21 / mu0 \ 2 (gH.gN.h_bar)**2 107 d" = -- . | ---- | . ---------------- 108 2 \ 4.pi / <r**8> 109 110 111 CSA constants 112 ~~~~~~~~~~~~~ 113 (wN.csa)**2 114 c = ----------- 115 3 116 117 118 2.wN**2.csa 119 c' = ----------- 120 3 121 122 123 2.wN**2 124 c" = ------- 125 3 126 127 """ 128 129 self.rnh = float(self.mf.usr_param.const['rxh']) 130 self.csa = float(self.mf.usr_param.const['csa']) 131 132 # Dipolar constant. 133 134 a = ((self.mu0/(4.0*pi)) * self.h_bar * self.gh * self.gx) ** 2 135 self.dipole_const = 0.25 * a * self.rnh**-6 136 self.dipole_prime = -1.5 * a * self.rnh**-7 137 self.dipole_2prime = 10.5 * a * self.rnh**-8 138 dip_temp = self.dipole_const / 1e9 139 140 self.csa_const = [] 141 self.csa_prime = [] 142 self.csa_2prime = [] 143 csa_temp = [] 144 for i in range(self.num_frq): 145 a = (self.frq_list[i][1]**2) / 3.0 146 self.csa_const.append(a * self.csa**2) 147 self.csa_prime.append(2.0 * a * self.csa) 148 self.csa_2prime.append(2.0 * a) 149 csa_temp.append(0.0) 150 151 if self.mf.debug: 152 print "%-20s%-20s" % ("r(NH):", `self.rnh`) 153 print "%-20s%-20s" % ("CSA:", `self.csa`) 154 print "%-20s%-20s" % ("CSA squared:", `self.csa**2`) 155 print "%-20s%-20s" % ("gH:", `self.gh`) 156 print "%-20s%-20s" % ("gN:", `self.gx`) 157 print "%-20s%-20s" % ("h-bar:", `self.h_bar`) 158 print "%-20s%-20s" % ("mu0:", `self.mu0`) 159 print "%-20s%-20s" % ("Dipolar const / 1e9", dip_temp) 160 print "%-20s%-20s" % ("CSA const / 1e9", csa_temp) 161 print "\n"
162 163 164
165 - def calc_frq(self):
166 "Calculate all the frequencies which lead to relaxation." 167 168 self.frq_list = [] 169 self.frq_sqrd_list = [] 170 for i in range(self.num_frq): 171 self.frq_list.append([]) 172 self.frq_sqrd_list.append([]) 173 174 frqH = 2.0 * pi * self.frq[i] 175 frqN = frqH * ( self.gx / self.gh ) 176 177 # Normal frequencies. 178 self.frq_list[i].append(0.0) 179 self.frq_list[i].append(frqN) 180 self.frq_list[i].append(frqH - frqN) 181 self.frq_list[i].append(frqH) 182 self.frq_list[i].append(frqH + frqN) 183 184 # Frequencies squared. 185 self.frq_sqrd_list[i].append(0.0) 186 self.frq_sqrd_list[i].append(frqN**2) 187 self.frq_sqrd_list[i].append((frqH - frqN)**2) 188 self.frq_sqrd_list[i].append(frqH**2) 189 self.frq_sqrd_list[i].append((frqH + frqN)**2)
190 191
192 - def init_constants(self):
193 self.gh = 26.7522e7 194 self.gx = -2.7126e7 195 self.h = 6.6260755e-34 196 self.h_bar = self.h / ( 2.0*pi ) 197 self.mu0 = 4.0*pi * 1e-7
198 199
200 - def init_data(self):
201 "Initilise the data structures." 202 203 # The number of data points. 204 # eg 6 205 self.num_ri = 0 206 207 # The number of field strengths. 208 # eg 2 209 self.num_frq = 0 210 211 # Labels corresponding to the data type. 212 # eg ['R1', 'R2', 'NOE', 'R1', 'R2', 'NOE'] 213 self.data_types = [] 214 215 # The names of the files containing the relaxation data. 216 # eg ['R1.out', 'R2.out', 'NOE.out', 'R1.out', 'R2.out', 'NOE.out'] 217 self.data_files = [] 218 219 # A translation table to map relaxation data points to their frequencies. 220 # eg [0, 0, 0, 1, 1, 1] 221 self.remap_table = [] 222 223 # A translation table to direct the NOE data points to the R1 data points. Used to speed up 224 # calculations by avoiding the recalculation of R1 values. 225 # eg [None, None, 0, None, None, 3] 226 self.noe_r1_table = [] 227 228 # The NMR frequency labels. 229 # eg ['600', '500'] 230 self.frq_label = [] 231 232 # The NMR frequencies in Hz. 233 # eg [600.0 * 1e6, 500.0 * 1e6] 234 self.frq = [] 235 236 # The structure of self.relax_data is as follows: The first dimension corresponds to each 237 # relaxation data point. The fields point to 2D data structures containing the data from 238 # the relaxation file (missing the single header line), ie: 239 # [res][0] - Residue number 240 # [res][1] - Residue name 241 # [res][2] - Relaxation value 242 # [res][3] - Relaxation error 243 self.relax_data = []
244 245 # Don't know if these are used any more? 246 #self.runs = [] 247 #self.stage = '0' 248 #self.data = {} 249 #self.results = [] 250