Package test_suite :: Package system_tests :: Module relax_disp
[hide private]
[frames] | no frames]

Source Code for Module test_suite.system_tests.relax_disp

   1  ############################################################################### 
   2  #                                                                             # 
   3  # Copyright (C) 2006-2014 Edward d'Auvergne                                   # 
   4  # Copyright (C) 2009 Sebastien Morin                                          # 
   5  # Copyright (C) 2013-2014 Troels E. Linnet                                    # 
   6  #                                                                             # 
   7  # This file is part of the program relax (http://www.nmr-relax.com).          # 
   8  #                                                                             # 
   9  # This program is free software: you can redistribute it and/or modify        # 
  10  # it under the terms of the GNU General Public License as published by        # 
  11  # the Free Software Foundation, either version 3 of the License, or           # 
  12  # (at your option) any later version.                                         # 
  13  #                                                                             # 
  14  # This program is distributed in the hope that it will be useful,             # 
  15  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
  16  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
  17  # GNU General Public License for more details.                                # 
  18  #                                                                             # 
  19  # You should have received a copy of the GNU General Public License           # 
  20  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
  21  #                                                                             # 
  22  ############################################################################### 
  23   
  24  # Python module imports. 
  25  from os import F_OK, access, sep 
  26  from tempfile import mkdtemp 
  27   
  28  # relax module imports. 
  29  from auto_analyses import relax_disp 
  30  from data_store import Relax_data_store; ds = Relax_data_store() 
  31  import dep_check 
  32  from pipe_control.mol_res_spin import return_spin, spin_loop 
  33  from specific_analyses.relax_disp.disp_data import generate_r20_key, get_curve_type 
  34  from specific_analyses.relax_disp.variables import EXP_TYPE_CPMG_DQ, EXP_TYPE_CPMG_MQ, EXP_TYPE_CPMG_PROTON_MQ, EXP_TYPE_CPMG_PROTON_SQ, EXP_TYPE_CPMG_SQ, EXP_TYPE_CPMG_ZQ, EXP_TYPE_R1RHO, MODEL_CR72, MODEL_CR72_FULL, MODEL_IT99, MODEL_LIST_CPMG, MODEL_LM63, MODEL_M61B, MODEL_NOREX, MODEL_NS_CPMG_2SITE_EXPANDED, MODEL_R2EFF 
  35  from status import Status; status = Status() 
  36  from test_suite.clean_up import deletion 
  37  from test_suite.system_tests.base_classes import SystemTestCase 
  38   
  39   
40 -class Relax_disp(SystemTestCase):
41 """Class for testing various aspects specific to relaxation dispersion curve-fitting.""" 42
43 - def __init__(self, methodName='runTest'):
44 """Skip certain tests if the C modules are non-functional. 45 46 @keyword methodName: The name of the test. 47 @type methodName: str 48 """ 49 50 # Execute the base class method. 51 super(Relax_disp, self).__init__(methodName) 52 53 # Missing module. 54 if not dep_check.C_module_exp_fn: 55 # The list of tests to skip. 56 to_skip = [ 57 "test_exp_fit", 58 "test_m61_exp_data_to_m61" 59 ] 60 61 # Store in the status object. 62 if methodName in to_skip: 63 status.skipped_tests.append([methodName, 'Relax curve-fitting C module', self._skip_type])
64 65
66 - def setUp(self):
67 """Set up for all the functional tests.""" 68 69 # Create the data pipe. 70 self.interpreter.pipe.create('relax_disp', 'relax_disp') 71 72 # Create a temporary directory for dumping files. 73 ds.tmpdir = mkdtemp() 74 self.tmpdir = ds.tmpdir
75 76
77 - def setup_hansen_cpmg_data(self, model=None):
78 """Set up the data for the test_hansen_cpmg_data_*() system tests. 79 80 @keyword model: The name of the model which will be tested. 81 @type model: str 82 """ 83 84 # Create the data pipe and load the base data. 85 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Hansen' 86 self.interpreter.pipe.create(pipe_name='base pipe', pipe_type='relax_disp') 87 self.interpreter.results.read(data_path+sep+'base_pipe') 88 self.interpreter.deselect.spin(':4') 89 90 # Set the nuclear isotope data. 91 self.interpreter.spin.isotope('15N') 92 93 # Create the R2eff data pipe and load the results. 94 self.interpreter.pipe.create(pipe_name='R2eff - relax_disp', pipe_type='relax_disp') 95 self.interpreter.pipe.switch(pipe_name='R2eff - relax_disp') 96 self.interpreter.results.read(data_path+sep+'r2eff_pipe') 97 self.interpreter.deselect.spin(':4') 98 99 # The model data pipe. 100 pipe_name = "%s - relax_disp" % model 101 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to=pipe_name, bundle_to='relax_disp') 102 self.interpreter.pipe.switch(pipe_name=pipe_name) 103 104 # Set the model. 105 self.interpreter.relax_disp.select_model(model=model) 106 107 # Copy the data. 108 self.interpreter.value.copy(pipe_from='R2eff - relax_disp', pipe_to=pipe_name, param='r2eff')
109 110
111 - def setup_kteilum_fmpoulsen_makke_cpmg_data(self, model=None, expfolder=None):
112 """Set up the data for the test_kteilum_fmpoulsen_makke_cpmg_data_*() system tests. 113 114 @keyword model: The name of the model which will be tested. 115 @type model: str 116 """ 117 118 # Create the data pipe and load the base data. 119 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'KTeilum_FMPoulsen_MAkke_2006'+sep+expfolder 120 self.interpreter.pipe.create(pipe_name='base pipe', pipe_type='relax_disp') 121 self.interpreter.results.read(data_path+sep+'ini_setup_trunc') 122 123 # Create the R2eff data pipe and load the results. 124 self.interpreter.pipe.create(pipe_name='R2eff', pipe_type='relax_disp') 125 self.interpreter.pipe.switch(pipe_name='R2eff') 126 self.interpreter.results.read(data_path+sep+'r2eff_pipe_trunc') 127 128 # The model data pipe. 129 pipe_name = "%s - relax_disp" % model 130 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to=pipe_name, bundle_to='relax_disp') 131 self.interpreter.pipe.switch(pipe_name=pipe_name) 132 133 # Set the model. 134 self.interpreter.relax_disp.select_model(model=model) 135 136 # Copy the data. 137 self.interpreter.value.copy(pipe_from='R2eff', pipe_to=pipe_name, param='r2eff')
138 139
140 - def setup_korzhnev_2005_data(self, data_list=[]):
141 """Set up the data for the test_korzhnev_2005_data_*() system tests using the 'NS MMQ 2-site' model. 142 143 This loads the proton-heteronuclear SQ, ZQ, DQ, and MQ (MMQ) data from: 144 145 - Dmitry M. Korzhnev, Philipp Neudecker, Anthony Mittermaier, Vladislav Yu. Orekhov, and Lewis E. Kay (2005) Multiple-site exchange in proteins studied with a suite of six NMR relaxation dispersion experiments: An application to the folding of a Fyn SH3 domain mutant. 127, 15602-15611 (U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}). 146 147 It consists of the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant. 148 149 150 @keyword data_list: The list of data to load. It can contain 'SQ', '1H SQ', 'ZQ', 'DQ', 'MQ', and '1H MQ'. 151 @type data_list: list of str 152 """ 153 154 # Create the data pipe and load the base data. 155 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Korzhnev_et_al_2005' 156 self.interpreter.pipe.create(pipe_name='Korzhnev et al., 2005', pipe_type='relax_disp') 157 158 # Create the spin system. 159 self.interpreter.spin.create(res_name='Asp', res_num=9, spin_name='H') 160 self.interpreter.spin.create(res_name='Asp', res_num=9, spin_name='N') 161 self.interpreter.spin.element('H', spin_id='@H') 162 self.interpreter.spin.element('N', spin_id='@N') 163 self.interpreter.spin.isotope('1H', spin_id='@H') 164 self.interpreter.spin.isotope('15N', spin_id='@N') 165 166 # Define the magnetic dipole-dipole relaxation interaction. 167 self.interpreter.interatom.define(spin_id1=':9@N', spin_id2=':9@H', direct_bond=True) 168 169 # The spectral data - experiment ID, R2eff file name, experiment type, spin ID string, spectrometer frequency in Hertz, relaxation time. 170 data = [ 171 ['1H SQ', '1H_SQ_CPMG_500_MHz', 'hs_500.res', EXP_TYPE_CPMG_PROTON_SQ, ':9@H', 500e6, 0.03], 172 ['1H SQ', '1H_SQ_CPMG_600_MHz', 'hs_600.res', EXP_TYPE_CPMG_PROTON_SQ, ':9@H', 600e6, 0.03], 173 ['1H SQ', '1H_SQ_CPMG_800_MHz', 'hs_800.res', EXP_TYPE_CPMG_PROTON_SQ, ':9@H', 800e6, 0.03], 174 ['SQ', '15N_SQ_CPMG_500_MHz', 'ns_500.res', EXP_TYPE_CPMG_SQ, ':9@N', 500e6, 0.04], 175 ['SQ', '15N_SQ_CPMG_600_MHz', 'ns_600.res', EXP_TYPE_CPMG_SQ, ':9@N', 600e6, 0.04], 176 ['SQ', '15N_SQ_CPMG_800_MHz', 'ns_800.res', EXP_TYPE_CPMG_SQ, ':9@N', 800e6, 0.04], 177 ['DQ', '15N_DQ_CPMG_500_MHz', 'dq_500.res', EXP_TYPE_CPMG_DQ, ':9@N', 500e6, 0.03], 178 ['DQ', '15N_DQ_CPMG_600_MHz', 'dq_600.res', EXP_TYPE_CPMG_DQ, ':9@N', 600e6, 0.03], 179 ['DQ', '15N_DQ_CPMG_800_MHz', 'dq_800.res', EXP_TYPE_CPMG_DQ, ':9@N', 800e6, 0.03], 180 ['ZQ', '15N_ZQ_CPMG_500_MHz', 'zq_500.res', EXP_TYPE_CPMG_ZQ, ':9@N', 500e6, 0.03], 181 ['ZQ', '15N_ZQ_CPMG_600_MHz', 'zq_600.res', EXP_TYPE_CPMG_ZQ, ':9@N', 600e6, 0.03], 182 ['ZQ', '15N_ZQ_CPMG_800_MHz', 'zq_800.res', EXP_TYPE_CPMG_ZQ, ':9@N', 800e6, 0.03], 183 ['1H MQ', '1H_MQ_CPMG_500_MHz', 'hm_500.res', EXP_TYPE_CPMG_PROTON_MQ, ':9@H', 500e6, 0.02], 184 ['1H MQ', '1H_MQ_CPMG_600_MHz', 'hm_600.res', EXP_TYPE_CPMG_PROTON_MQ, ':9@H', 600e6, 0.02], 185 ['1H MQ', '1H_MQ_CPMG_800_MHz', 'hm_800.res', EXP_TYPE_CPMG_PROTON_MQ, ':9@H', 800e6, 0.02], 186 ['MQ', '15N_MQ_CPMG_500_MHz', 'nm_500.res', EXP_TYPE_CPMG_MQ, ':9@N', 500e6, 0.02], 187 ['MQ', '15N_MQ_CPMG_600_MHz', 'nm_600.res', EXP_TYPE_CPMG_MQ, ':9@N', 600e6, 0.02], 188 ['MQ', '15N_MQ_CPMG_800_MHz', 'nm_800.res', EXP_TYPE_CPMG_MQ, ':9@N', 800e6, 0.02] 189 ] 190 cpmg_frqs_1h_sq = [67.0, 133.0, 267.0, 400.0, 533.0, 667.0, 800.0, 933.0, 1067.0, 1600.0, 2133.0, 2667.0] 191 cpmg_frqs_sq = [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 450.0, 500.0, 600.0, 700.0, 800.0, 900.0, 1000.0] 192 cpmg_frqs_dq = [33.0, 67.0, 133.0, 200.0, 267.0, 333.0, 400.0, 467.0, 533.0, 667.0, 800.0, 933.0, 1067.0] 193 cpmg_frqs_zq = [33.0, 67.0, 133.0, 200.0, 267.0, 333.0, 400.0, 467.0, 533.0, 667.0, 800.0, 933.0, 1067.0] 194 cpmg_frqs_1h_mq = [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 1000.0, 1500.0, 2000.0, 2500.0] 195 cpmg_frqs_mq = [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0, 1000.0] 196 197 # Loop over the files, reading in the data. 198 for data_type, id, file, exp_type, spin_id, H_frq, relax_time in data: 199 # Skip undesired data. 200 if data_type not in data_list: 201 continue 202 203 # Alias the CPMG frequencies. 204 if data_type == 'SQ': 205 cpmg_frqs = cpmg_frqs_sq 206 elif data_type == '1H SQ': 207 cpmg_frqs = cpmg_frqs_1h_sq 208 elif data_type == 'DQ': 209 cpmg_frqs = cpmg_frqs_dq 210 elif data_type == 'ZQ': 211 cpmg_frqs = cpmg_frqs_zq 212 elif data_type == '1H MQ': 213 cpmg_frqs = cpmg_frqs_1h_mq 214 elif data_type == 'MQ': 215 cpmg_frqs = cpmg_frqs_mq 216 217 # Loop over each CPMG frequency. 218 for cpmg_frq in cpmg_frqs: 219 # The id. 220 new_id = "%s_%s" % (id, cpmg_frq) 221 222 # Set the NMR field strength. 223 self.interpreter.spectrometer.frequency(id=new_id, frq=H_frq) 224 225 # Set the relaxation dispersion experiment type. 226 self.interpreter.relax_disp.exp_type(spectrum_id=new_id, exp_type=exp_type) 227 228 # Relaxation dispersion CPMG constant time delay T (in s). 229 self.interpreter.relax_disp.relax_time(spectrum_id=new_id, time=relax_time) 230 231 # Set the CPMG frequency. 232 self.interpreter.relax_disp.cpmg_frq(spectrum_id=new_id, cpmg_frq=cpmg_frq) 233 234 # Read the R2eff data. 235 self.interpreter.relax_disp.r2eff_read_spin(id=id, file=file, dir=data_path, spin_id=spin_id, disp_point_col=1, data_col=2, error_col=3) 236 237 # Change the model. 238 self.interpreter.relax_disp.select_model('NS MMQ 2-site')
239 240
242 """U{Bug #21081<https://web.archive.org/web/https://gna.org/bugs/?21081>} catch, the failure of a cluster analysis when spins are deselected.""" 243 244 # Clear the data store. 245 self.interpreter.reset() 246 247 # Load the state. 248 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states'+sep+'bug_21081_disp_cluster_fail.bz2' 249 self.interpreter.state.load(state, force=True) 250 251 # Model selection - to catch the failure. 252 self.interpreter.model_selection(method='AIC', modsel_pipe='final', bundle='relax_disp', pipes=['No Rex', 'CR72'])
253 254
256 """U{Bug #21460<https://web.archive.org/web/https://gna.org/bugs/?21460>} catch, the failure due to a spectrometer frequency having no relaxation data.""" 257 258 # Clear the data store. 259 self.interpreter.reset() 260 261 # Load the state. 262 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states'+sep+'bug_21460_bad_fields.bz2' 263 self.interpreter.state.load(state, force=True) 264 265 # Execute the auto-analysis (fast). 266 relax_disp.Relax_disp.opt_func_tol = 1e-5 267 relax_disp.Relax_disp.opt_max_iterations = 1000 268 relax_disp.Relax_disp(pipe_name="origin - relax_disp (Thu Jan 2 13:46:44 2014)", pipe_bundle="relax_disp (Thu Jan 2 13:46:44 2014)", results_dir=self.tmpdir, models=['R2eff', 'No Rex', 'CR72', 'NS CPMG 2-site expanded'], grid_inc=3, mc_sim_num=5, modsel='AIC', pre_run_dir=None, insignificance=1.0, numeric_only=False, mc_sim_all_models=False, eliminate=True)
269 270
272 """U{Bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21344>} catch, the failure of an analysis of a sparse acquired R1rho dataset with missing combinations of time and spin-lock field strengths using auto_analysis.""" 273 274 # Clear the data store. 275 self.interpreter.reset() 276 277 # Load the state. 278 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2' 279 self.interpreter.state.load(state, force=True) 280 281 # Execute the auto-analysis (fast). 282 relax_disp.Relax_disp.opt_func_tol = 1e-5 283 relax_disp.Relax_disp.opt_max_iterations = 1000 284 relax_disp.Relax_disp(pipe_name='base pipe', pipe_bundle='relax_disp', results_dir=self.tmpdir, models=['R2eff'], grid_inc=3, mc_sim_num=5, modsel='AIC', pre_run_dir=None, insignificance=1.0, numeric_only=False, mc_sim_all_models=False, eliminate=True)
285 286
288 """U{Bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>} catch, the failure due to a a CPMG analysis recorded at two fields at two delay times, using calc().""" 289 290 # Clear the data store. 291 self.interpreter.reset() 292 293 # Load the state. 294 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2' 295 self.interpreter.state.load(state, force=True) 296 297 # Run the calculation. 298 self.interpreter.calc(verbosity=1)
299 300
302 """U{Bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>} catch, the failure due to a a CPMG analysis recorded at two fields at two delay times using auto_analysis.""" 303 304 # Clear the data store. 305 self.interpreter.reset() 306 307 # Load the state. 308 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2' 309 self.interpreter.state.load(state, force=True) 310 311 # Execute the auto-analysis (fast). 312 relax_disp.Relax_disp.opt_func_tol = 1e-5 313 relax_disp.Relax_disp.opt_max_iterations = 1000 314 relax_disp.Relax_disp(pipe_name="compare_128_FT_R2eff", pipe_bundle="cpmg_disp_sod1d90a", results_dir=self.tmpdir, models=['R2eff'], grid_inc=3, mc_sim_num=5, modsel='AIC', pre_run_dir=None, insignificance=1.0, numeric_only=False, mc_sim_all_models=False, eliminate=True)
315 316
318 """Catch U{bug #21715<https://web.archive.org/web/https://gna.org/bugs/?21715>}, the failure of a clustered auto-analysis due to an IndexError.""" 319 320 # Clear the data store. 321 self.interpreter.reset() 322 323 # Load the state. 324 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21715_clustered_indexerror'+sep+'state.bz2' 325 self.interpreter.state.load(state, force=True) 326 327 # Execute the auto-analysis (fast). 328 pre_run_dir = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21715_clustered_indexerror'+sep+'non_clustered' 329 relax_disp.Relax_disp.opt_func_tol = 1e-5 330 relax_disp.Relax_disp.opt_max_iterations = 1000 331 relax_disp.Relax_disp(pipe_name='origin - relax_disp (Sun Feb 23 19:36:51 2014)', pipe_bundle='relax_disp (Sun Feb 23 19:36:51 2014)', results_dir=self.tmpdir, models=['R2eff', 'No Rex'], grid_inc=11, mc_sim_num=2, modsel='AIC', pre_run_dir=pre_run_dir, insignificance=1.0, numeric_only=True, mc_sim_all_models=False, eliminate=True)
332 333
335 """Test the curve type detection using the Dr. Flemming Hansen's CPMG fixed time test data.""" 336 337 # Reset. 338 self.interpreter.reset() 339 340 # Load the base data. 341 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Hansen' 342 self.interpreter.state.load(data_path+sep+'r2eff_values') 343 344 # The type. 345 curve_type = get_curve_type(id='500_133.33.in') 346 self.assertEqual(curve_type, 'fixed time')
347 348
349 - def test_curve_type_r1rho_exponential(self, model=None):
350 """Test the curve type detection using the 'M61' exponential test data.""" 351 352 # Reset. 353 self.interpreter.reset() 354 355 # Load the base data. 356 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r1rho_on_res_m61' 357 self.interpreter.state.load(data_path+sep+'r2eff_values') 358 359 # The type. 360 curve_type = get_curve_type(id='nu_2000_ncyc9') 361 self.assertEqual(curve_type, 'exponential')
362 363
364 - def test_curve_type_r1rho_fixed_time(self, model=None):
365 """Test the curve type detection using the 'TP02' fixed time test data.""" 366 367 # Reset. 368 self.interpreter.reset() 369 370 # Load the base data. 371 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r1rho_off_res_tp02' 372 self.interpreter.state.load(data_path+sep+'r2eff_values') 373 374 # The type. 375 curve_type = get_curve_type(id='nu_1000.0_500MHz') 376 self.assertEqual(curve_type, 'fixed time')
377 378
379 - def test_dpl94_data_to_dpl94(self):
380 """Test the relaxation dispersion 'DPL94' model curve fitting to fixed time synthetic data.""" 381 382 # Fixed time variable. 383 ds.fixed = True 384 385 # Execute the script. 386 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_on_res_dpl94.py') 387 388 # The original parameters. 389 i0 = [100000.0, 20000.0] 390 r1rho_prime = [2.25, 24.0] 391 pA = 0.7 392 kex = 1000.0 393 delta_omega = [1.0, 2.0] 394 phi_ex = [] 395 for i in range(2): 396 phi_ex.append(pA * (1.0 - pA) * delta_omega[i]**2) 397 398 # Switch to the 'DPL94' model data pipe, then check for each spin. 399 self.interpreter.pipe.switch('DPL94 - relax_disp') 400 spin_index = 0 401 for spin, spin_id in spin_loop(return_id=True): 402 # Printout. 403 print("\nSpin %s." % spin_id) 404 405 # Check the fitted parameters. 406 self.assertAlmostEqual(spin.r2['R1rho - 800.00000000 MHz']/10, r1rho_prime[spin_index]/10, 2) 407 self.assertAlmostEqual(spin.phi_ex, phi_ex[spin_index], 2) 408 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 2) 409 410 # Increment the spin index. 411 spin_index += 1
412 413
414 - def test_exp_fit(self):
415 """Test the relaxation dispersion 'exp_fit' model curve fitting.""" 416 417 # Execute the script. 418 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'exp_fit.py') 419 420 # The original exponential curve parameters. 421 res_data = [ 422 [15., 10., 20000., 25000.], 423 [12., 11., 50000., 51000.], 424 [17., 9., 100000., 96000.] 425 ] 426 427 # List of parameters which do not belong to the model. 428 blacklist = ['cpmg_frqs', 'r2', 'rex', 'kex', 'r2a', 'k_AB', 'dw'] 429 430 # Checks for each residue. 431 for i in range(len(res_data)): 432 # Printout. 433 print("\nResidue number %s." % (i+1)) 434 435 # Check the fitted parameters. 436 self.assertAlmostEqual(cdp.mol[0].res[i].spin[0].r2eff['r1rho_1200.00000000_0.000_1000.000'], res_data[i][0], places=2) 437 self.assertAlmostEqual(cdp.mol[0].res[i].spin[0].r2eff['r1rho_1200.00000000_0.000_2000.000'], res_data[i][1], places=2) 438 self.assertAlmostEqual(cdp.mol[0].res[i].spin[0].i0['r1rho_1200.00000000_0.000_1000.000']/10000, res_data[i][2]/10000, places=3) 439 self.assertAlmostEqual(cdp.mol[0].res[i].spin[0].i0['r1rho_1200.00000000_0.000_2000.000']/10000, res_data[i][3]/10000, places=3) 440 441 # Check the simulation errors. 442 self.assert_(cdp.mol[0].res[i].spin[0].r2eff_err['r1rho_1200.00000000_0.000_1000.000'] < 5.0) 443 self.assert_(cdp.mol[0].res[i].spin[0].r2eff_err['r1rho_1200.00000000_0.000_2000.000'] < 5.0) 444 self.assert_(cdp.mol[0].res[i].spin[0].i0_err['r1rho_1200.00000000_0.000_1000.000']/10000 < 5.0) 445 self.assert_(cdp.mol[0].res[i].spin[0].i0_err['r1rho_1200.00000000_0.000_2000.000']/10000 < 5.0) 446 447 # Check that certain parameters are not present. 448 for param in blacklist: 449 print("\tChecking for the absence of the '%s' parameter." % param) 450 self.assert_(not hasattr(cdp.mol[0].res[i].spin[0], param)) 451 452 # Check the clustering information. 453 self.assert_(hasattr(cdp, 'clustering')) 454 keys = ['free spins', 'cluster'] 455 for key in keys: 456 self.assert_(key in cdp.clustering) 457 self.assert_('test' not in cdp.clustering) 458 self.assertEqual(cdp.clustering['free spins'], [':2@N']) 459 self.assertEqual(cdp.clustering['cluster'], [':1@N', ':3@N'])
460 461
462 - def test_hansen_catia_input(self):
463 """Conversion of Dr. Flemming Hansen's CPMG R2eff values into input files for CATIA. 464 465 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period. 466 """ 467 468 # Load the R2eff results file. 469 file_name = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Hansen'+sep+'r2eff_pipe' 470 self.interpreter.results.read(file_name) 471 self.interpreter.deselect.spin(':4') 472 473 # The spin isotopes. 474 self.interpreter.spin.isotope("15N") 475 476 # Generate the input files. 477 self.interpreter.relax_disp.catia_input(dir=ds.tmpdir, force=True) 478 479 # Check the r2eff set files. 480 print("\nChecking the R2eff input set files.") 481 files = ['data_set_500.inp', 'data_set_500.inp'] 482 for file in files: 483 self.assert_(access(ds.tmpdir+sep+file, F_OK)) 484 data_set_500 = [ 485 "ID=500\n", 486 "Sfrq = 500\n", 487 "Temperature = 0.0\n", 488 "Nucleus = N15\n", 489 "Couplednucleus = H1\n", 490 "Time_equil = 0.0\n", 491 "Pwx_cp = 0.0\n", 492 "Taub = 0.0\n", 493 "Time_T2 = 0.03\n", 494 "Xcar = 0.0\n", 495 "Seqfil = CW_CPMG\n", 496 "Minerror = (2.%;0.5/s)\n", 497 "Basis = (Iph_7)\n", 498 "Format = (0;1;2)\n", 499 "DataDirectory = /tmp/tmpNjOGNG/input_r2eff\n", 500 "Data = (\n", 501 " [70N;spin_70_N_500.cpmg];\n", 502 " [71N;spin_71_N_500.cpmg];\n", 503 ")\n", 504 ] 505 file = open(ds.tmpdir+sep+files[0]) 506 lines = file.readlines() 507 file.close() 508 for i in range(len(data_set_500)): 509 # Skip the data directory, as this is a random file name. 510 if i == 14: 511 continue 512 513 self.assertEqual(data_set_500[i], lines[i]) 514 515 # Check the r2eff files. 516 print("\nChecking the R2eff input files.") 517 files = ['spin_70_N_500.cpmg', 'spin_70_N_800.cpmg', 'spin_71_N_500.cpmg', 'spin_71_N_800.cpmg'] 518 for file in files: 519 self.assert_(access(ds.tmpdir+sep+'input_r2eff'+sep+file, F_OK)) 520 spin_70_N_500 = [ 521 "# nu_cpmg(Hz) R2(1/s) Esd(R2)\n", 522 " 66.666600000000003 16.045540885533605 0.310924686180635\n", 523 " 133.333300000000008 14.877924861181727 0.303217270671013\n", 524 " 200.000000000000000 14.357820247260586 0.299894424543361\n", 525 " 266.666600000000017 12.664494620416516 0.289532060485796\n", 526 " 333.333300000000008 12.363204802467891 0.287759631749322\n", 527 " 400.000000000000000 11.092532381134513 0.280514035409862\n", 528 " 466.666600000000017 10.566090057649893 0.277618625949722\n", 529 " 533.333300000000008 9.805806894657803 0.273544382200754\n", 530 " 600.000000000000000 9.564300692201730 0.272276309984954\n", 531 " 666.666600000000017 9.015633750407980 0.269441511838159\n", 532 " 733.333300000000008 8.607764958055581 0.267375134391053\n", 533 " 800.000000000000000 8.279997179221338 0.265739551961997\n", 534 " 866.666600000000017 8.474535940963516 0.266707642726566\n", 535 " 933.333300000000008 8.158972897365194 0.265141210539941\n", 536 "1000.000000000000000 7.988630509501972 0.264304105548559\n", 537 ] 538 file = open(ds.tmpdir+sep+'input_r2eff'+sep+files[0]) 539 lines = file.readlines() 540 file.close() 541 for i in range(len(lines)): 542 print("%s\"%s\\n\"," % (" "*12, lines[i][:-1])) 543 for i in range(len(spin_70_N_500)): 544 self.assertEqual(spin_70_N_500[i], lines[i]) 545 546 # Check the main file. 547 print("\nChecking the main CATIA execution file.") 548 main_file = [ 549 "ReadDataset(data_set_500.inp)\n", 550 "ReadDataset(data_set_800.inp)\n", 551 "ReadParam_Global(ParamGlobal.inp)\n", 552 "ReadParam_Local(ParamSet1.inp)\n", 553 "\n", 554 "FreeLocalParam(all;Omega;false)\n", 555 "FreeLocalParam(all;R1iph_500;false)\n", 556 "FreeLocalParam(all;R1iph_800;false)\n", 557 "\n", 558 "Minimize(print=y;tol=1e-25;maxiter=10000000)\n", 559 "\n", 560 "PrintParam(output/GlobalParam.fit;global)\n", 561 "PrintParam(output/DeltaOmega.fit;DeltaO)\n", 562 "PrintData(output/)\n", 563 "\n", 564 "ChiSq(all;all)\n", 565 "exit(0)\n" 566 ] 567 file = open("%s%sFit.catia" % (ds.tmpdir, sep)) 568 lines = file.readlines() 569 file.close() 570 for i in range(len(main_file)): 571 self.assertEqual(main_file[i], lines[i])
572 573
575 """Test of the dispersion auto-analysis using Dr. Flemming Hansen's CPMG data. 576 577 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period. 578 """ 579 580 # Set the model. 581 ds.models = [ 582 MODEL_NOREX, 583 MODEL_LM63, 584 MODEL_CR72, 585 MODEL_IT99 586 ] 587 588 # Execute the script. 589 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'hansen_data.py') 590 self.interpreter.state.save('analysis_heights', dir=ds.tmpdir, force=True) 591 592 # The R20 keys. 593 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) 594 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) 595 596 # The 'No Rex' model checks. 597 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp') 598 spin70 = return_spin(":70") 599 spin71 = return_spin(":71") 600 print("\n\nOptimised parameters:\n") 601 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 602 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1])) 603 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2])) 604 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 605 self.assertAlmostEqual(spin70.r2[r20_key1], 10.5340593984683, 3) 606 self.assertAlmostEqual(spin70.r2[r20_key2], 16.1112170102734, 3) 607 self.assertAlmostEqual(spin70.chi2, 8973.84810025761, 3) 608 self.assertAlmostEqual(spin71.r2[r20_key1], 5.83139953954648, 3) 609 self.assertAlmostEqual(spin71.r2[r20_key2], 8.90856319376098, 3) 610 self.assertAlmostEqual(spin71.chi2, 3908.00127830003, 3) 611 612 # The 'LM63' model checks. 613 self.interpreter.pipe.switch(pipe_name='LM63 - relax_disp') 614 spin70 = return_spin(":70") 615 spin71 = return_spin(":71") 616 print("\n\nOptimised parameters:\n") 617 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 618 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1])) 619 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2])) 620 print("%-20s %20.15g %20.15g" % ("phi_ex", spin70.phi_ex, spin71.phi_ex)) 621 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex)) 622 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 623 self.assertAlmostEqual(spin70.r2[r20_key1], 6.74326615264889, 3) 624 self.assertAlmostEqual(spin70.r2[r20_key2], 6.57331164382438, 2) 625 self.assertAlmostEqual(spin70.phi_ex, 0.312767653822936, 3) 626 self.assertAlmostEqual(spin70.kex/10000, 4723.44390412119/10000, 3) 627 self.assertAlmostEqual(spin70.chi2, 363.534049046805, 3) 628 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00778024769786, 3) 629 self.assertAlmostEqual(spin71.r2[r20_key2], 6.83343630016037, 3) 630 self.assertAlmostEqual(spin71.phi_ex, 0.0553791362097596, 3) 631 self.assertAlmostEqual(spin71.kex/10000, 2781.67925957068/10000, 3) 632 self.assertAlmostEqual(spin71.chi2, 17.0776426190574, 3) 633 634 # The 'CR72' model checks. 635 self.interpreter.pipe.switch(pipe_name='CR72 - relax_disp') 636 spin70 = return_spin(":70") 637 spin71 = return_spin(":71") 638 print("\n\nOptimised parameters:\n") 639 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 640 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1])) 641 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2])) 642 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA)) 643 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw)) 644 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex)) 645 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 646 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97233943292193, 3) 647 self.assertAlmostEqual(spin70.r2[r20_key2], 9.409506394526, 3) 648 self.assertAlmostEqual(spin70.pA, 0.989856804525044, 3) 649 self.assertAlmostEqual(spin70.dw, 5.60889078920945, 3) 650 self.assertAlmostEqual(spin70.kex/10000, 1753.01607073019/10000, 3) 651 self.assertAlmostEqual(spin70.chi2, 53.8382158551706, 3) 652 self.assertAlmostEqual(spin71.r2[r20_key1], 5.003171547206, 3) 653 self.assertAlmostEqual(spin71.r2[r20_key2], 6.90210797727492, 3) 654 self.assertAlmostEqual(spin71.pA, 0.985922406455826, 3) 655 self.assertAlmostEqual(spin71.dw, 2.00500965892672, 3) 656 self.assertAlmostEqual(spin71.kex/10000, 2481.10839579617/10000, 3) 657 self.assertAlmostEqual(spin71.chi2, 15.6595374286822, 3)
658 659
661 """Test of the numeric model only dispersion auto-analysis using Dr. Flemming Hansen's CPMG data. 662 663 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period. 664 """ 665 666 # Set the model and numeric flag. 667 ds.models = [ 668 MODEL_NOREX, 669 MODEL_CR72, 670 MODEL_NS_CPMG_2SITE_EXPANDED 671 ] 672 ds.numeric_only = True 673 674 # Execute the script. 675 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'hansen_data.py') 676 677 # The R20 keys. 678 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) 679 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) 680 681 # The 'No Rex' model checks. 682 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp') 683 spin70 = return_spin(":70") 684 spin71 = return_spin(":71") 685 print("\n\nOptimised parameters:\n") 686 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 687 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1])) 688 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2])) 689 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 690 self.assertAlmostEqual(spin70.r2[r20_key1], 10.5340593984683, 3) 691 self.assertAlmostEqual(spin70.r2[r20_key2], 16.1112170102734, 3) 692 self.assertAlmostEqual(spin70.chi2/10000, 8973.84810025761/10000, 3) 693 self.assertAlmostEqual(spin71.r2[r20_key1], 5.83139953954648, 3) 694 self.assertAlmostEqual(spin71.r2[r20_key2], 8.90856319376098, 3) 695 self.assertAlmostEqual(spin71.chi2/10000, 3908.00127830003/10000, 3) 696 697 # The 'CR72' model checks. 698 self.interpreter.pipe.switch(pipe_name='CR72 - relax_disp') 699 spin70 = return_spin(":70") 700 spin71 = return_spin(":71") 701 print("\n\nOptimised parameters:\n") 702 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 703 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1])) 704 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2])) 705 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA)) 706 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw)) 707 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex)) 708 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 709 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97233943292193, 3) 710 self.assertAlmostEqual(spin70.r2[r20_key2], 9.409506394526, 3) 711 self.assertAlmostEqual(spin70.pA, 0.989856804525044, 3) 712 self.assertAlmostEqual(spin70.dw, 5.60889078920945, 3) 713 self.assertAlmostEqual(spin70.kex/10000, 1753.01607073019/10000, 3) 714 self.assertAlmostEqual(spin70.chi2, 53.8382158551706, 3) 715 self.assertAlmostEqual(spin71.r2[r20_key1], 5.003171547206, 3) 716 self.assertAlmostEqual(spin71.r2[r20_key2], 6.90210797727492, 3) 717 self.assertAlmostEqual(spin71.pA, 0.985922406455826, 3) 718 self.assertAlmostEqual(spin71.dw, 2.00500965892672, 3) 719 self.assertAlmostEqual(spin71.kex/10000, 2481.10839579617/10000, 3) 720 self.assertAlmostEqual(spin71.chi2, 15.6595374286822, 3) 721 722 # The 'NS CPMG 2-site expanded' model checks. 723 self.interpreter.pipe.switch(pipe_name='NS CPMG 2-site expanded - relax_disp') 724 spin70 = return_spin(":70") 725 spin71 = return_spin(":71") 726 print("\n\nOptimised parameters:\n") 727 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 728 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1])) 729 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2])) 730 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA)) 731 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw)) 732 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex)) 733 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 734 self.assertAlmostEqual(spin70.r2[r20_key1], 6.95812089063457, 3) 735 self.assertAlmostEqual(spin70.r2[r20_key2], 9.39651467124235, 3) 736 self.assertAlmostEqual(spin70.pA, 0.989700942551209, 3) 737 self.assertAlmostEqual(spin70.dw, 5.67324269421426, 3) 738 self.assertAlmostEqual(spin70.kex/10000, 1713.59762249271/10000, 3) 739 self.assertAlmostEqual(spin70.chi2, 52.5106889105996, 3) 740 self.assertAlmostEqual(spin71.r2[r20_key1], 4.99897355555516, 3) 741 self.assertAlmostEqual(spin71.r2[r20_key2], 6.89823239900183, 3) 742 self.assertAlmostEqual(spin71.pA, 0.986704447530285, 3) 743 self.assertAlmostEqual(spin71.dw, 2.09198758585969, 3) 744 self.assertAlmostEqual(spin71.kex/10000, 2438.29751770245/10000, 3) 745 self.assertAlmostEqual(spin71.chi2, 15.1644904768219, 3) 746 747 # The final data pipe checks. 748 self.interpreter.pipe.switch(pipe_name='final - relax_disp') 749 spin70 = return_spin(":70") 750 spin71 = return_spin(":71") 751 self.assertEqual(spin70.model, 'NS CPMG 2-site expanded') 752 self.assertEqual(spin71.model, 'NS CPMG 2-site expanded')
753 754
756 """Test of the dispersion auto-analysis using Dr. Flemming Hansen's CPMG data (using the R2eff data directly instead of peak intensities). 757 758 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period. 759 """ 760 761 # Set the model. 762 ds.models = [ 763 MODEL_NOREX, 764 MODEL_LM63, 765 MODEL_CR72, 766 MODEL_IT99 767 ] 768 769 # Execute the script. 770 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'hansen_r2eff_data.py') 771 self.interpreter.state.save('analysis_r2eff', dir=ds.tmpdir, force=True) 772 773 # The R20 keys. 774 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) 775 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) 776 777 # The 'No Rex' model checks. 778 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp') 779 spin70 = return_spin(":70") 780 spin71 = return_spin(":71") 781 print("\n\nOptimised parameters:\n") 782 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 783 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1])) 784 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2])) 785 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 786 self.assertAlmostEqual(spin70.r2[r20_key1], 10.5340593984683, 3) 787 self.assertAlmostEqual(spin70.r2[r20_key2], 16.1112170102734, 3) 788 self.assertAlmostEqual(spin70.chi2, 8973.84810025761, 3) 789 self.assertAlmostEqual(spin71.r2[r20_key1], 5.83139953954648, 3) 790 self.assertAlmostEqual(spin71.r2[r20_key2], 8.90856319376098, 3) 791 self.assertAlmostEqual(spin71.chi2, 3908.00127830003, 3) 792 793 # The 'LM63' model checks. 794 self.interpreter.pipe.switch(pipe_name='LM63 - relax_disp') 795 spin70 = return_spin(":70") 796 spin71 = return_spin(":71") 797 print("\n\nOptimised parameters:\n") 798 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 799 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1])) 800 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2])) 801 print("%-20s %20.15g %20.15g" % ("phi_ex", spin70.phi_ex, spin71.phi_ex)) 802 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex)) 803 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 804 self.assertAlmostEqual(spin70.r2[r20_key1], 6.74326615264889, 3) 805 self.assertAlmostEqual(spin70.r2[r20_key2], 6.57331164382438, 2) 806 self.assertAlmostEqual(spin70.phi_ex, 0.312767653822936, 3) 807 self.assertAlmostEqual(spin70.kex/10000, 4723.44390412119/10000, 3) 808 self.assertAlmostEqual(spin70.chi2, 363.534049046805, 3) 809 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00778024769786, 3) 810 self.assertAlmostEqual(spin71.r2[r20_key2], 6.83343630016037, 3) 811 self.assertAlmostEqual(spin71.phi_ex, 0.0553791362097596, 3) 812 self.assertAlmostEqual(spin71.kex/10000, 2781.67925957068/10000, 3) 813 self.assertAlmostEqual(spin71.chi2, 17.0776426190574, 3) 814 815 # The 'CR72' model checks. 816 self.interpreter.pipe.switch(pipe_name='CR72 - relax_disp') 817 spin70 = return_spin(":70") 818 spin71 = return_spin(":71") 819 print("\n\nOptimised parameters:\n") 820 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 821 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1])) 822 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2])) 823 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA)) 824 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw)) 825 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex)) 826 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 827 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97233943292193, 3) 828 self.assertAlmostEqual(spin70.r2[r20_key2], 9.409506394526, 3) 829 self.assertAlmostEqual(spin70.pA, 0.989856804525044, 3) 830 self.assertAlmostEqual(spin70.dw, 5.60889078920945, 3) 831 self.assertAlmostEqual(spin70.kex/10000, 1753.01607073019/10000, 3) 832 self.assertAlmostEqual(spin70.chi2, 53.8382158551706, 3) 833 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00317154730225, 3) 834 self.assertAlmostEqual(spin71.r2[r20_key2], 6.90210797713541, 3) 835 self.assertAlmostEqual(spin71.pA, 0.985922406429147, 3) 836 self.assertAlmostEqual(spin71.dw, 2.00500965887772, 3) 837 self.assertAlmostEqual(spin71.kex/10000, 2481.10839579804/10000, 3) 838 self.assertAlmostEqual(spin71.chi2, 15.6595374288635, 3)
839 840
842 """Test of the dispersion auto-analysis using Dr. Flemming Hansen's CPMG data with parts missing. 843 844 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period. 845 """ 846 847 # Set the model. 848 ds.models = [ 849 MODEL_R2EFF, 850 MODEL_NOREX, 851 MODEL_CR72, 852 MODEL_NS_CPMG_2SITE_EXPANDED 853 ] 854 855 # Execute the script. 856 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'hansen_data_missing.py') 857 self.interpreter.state.save('analysis_heights', dir=ds.tmpdir, force=True) 858 859 # The R20 keys. 860 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) 861 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) 862 863 # The 'No Rex' model checks. 864 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp') 865 spin4 = return_spin(":4") 866 spin70 = return_spin(":70") 867 spin71 = return_spin(":71") 868 print("\n\nOptimised parameters:\n") 869 print("%-20s %-20s %-20s %-20s" % ("Parameter", "Value (:4)", "Value (:70)", "Value (:71)")) 870 print("%-20s %20.15g %20.15g %20.15g" % ("R2 (500 MHz)", spin4.r2[r20_key1], spin70.r2[r20_key1], spin71.r2[r20_key1])) 871 print("%-20s %20.15g %20.15g %20.15g" % ("R2 (800 MHz)", spin4.r2[r20_key2], spin70.r2[r20_key2], spin71.r2[r20_key2])) 872 print("%-20s %20.15g %20.15g %20.15g\n" % ("chi2", spin4.chi2, spin70.chi2, spin71.chi2)) 873 self.assertAlmostEqual(spin4.r2[r20_key1], 1.60463084515171, 3) 874 self.assertAlmostEqual(spin4.r2[r20_key2], 1.63220784651911, 3) 875 self.assertAlmostEqual(spin4.chi2, 29.2929926382771, 3) 876 self.assertAlmostEqual(spin70.r2[r20_key1], 10.534285641325, 3) 877 self.assertAlmostEqual(spin70.r2[r20_key2], 16.1112794857068, 3) 878 self.assertAlmostEqual(spin70.chi2, 9634.52343363306, 3) 879 self.assertAlmostEqual(spin71.r2[r20_key1], 5.83136858890037, 3) 880 self.assertAlmostEqual(spin71.chi2, 127.636629246204, 3) 881 882 # The 'CR72' model checks. 883 self.interpreter.pipe.switch(pipe_name='CR72 - relax_disp') 884 spin4 = return_spin(":4") 885 spin70 = return_spin(":70") 886 spin71 = return_spin(":71") 887 print("\n\nOptimised parameters:\n") 888 print("%-20s %-20s %-20s %-20s" % ("Parameter", "Value (:4)", "Value (:70)", "Value (:71)")) 889 print("%-20s %20.15g %20.15g %20.15g" % ("R2 (500 MHz)", spin4.r2[r20_key1], spin70.r2[r20_key1], spin71.r2[r20_key1])) 890 print("%-20s %20.15g %20.15g %20.15g" % ("R2 (800 MHz)", spin4.r2[r20_key2], spin70.r2[r20_key2], spin71.r2[r20_key2])) 891 print("%-20s %20.15g %20.15g %20.15g" % ("pA", spin4.pA, spin70.pA, spin71.pA)) 892 print("%-20s %20.15g %20.15g %20.15g" % ("dw", spin4.dw, spin70.dw, spin71.dw)) 893 print("%-20s %20.15g %20.15g %20.15g" % ("kex", spin4.kex, spin70.kex, spin71.kex)) 894 print("%-20s %20.15g %20.15g %20.15g\n" % ("chi2", spin4.chi2, spin70.chi2, spin71.chi2)) 895 self.assertAlmostEqual(spin4.r2[r20_key1], 1.57151065615839, 2) 896 self.assertAlmostEqual(spin4.r2[r20_key2], 1.58059682984398, 3) 897 self.assertAlmostEqual(spin4.pA, 0.500019733844535, 3) 898 self.assertAlmostEqual(spin4.dw, 6.57514296850066, 3) 899 self.assertAlmostEqual(spin4.kex/10000, 0.209808727621065/10000, 3) 900 self.assertAlmostEqual(spin4.chi2, 19.2950428365527, 3) 901 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97326447937972, 3) 902 self.assertAlmostEqual(spin70.r2[r20_key2], 9.3417810084784, 3) 903 self.assertAlmostEqual(spin70.pA, 0.98993823805518, 3) 904 self.assertAlmostEqual(spin70.dw, 5.5907147782533, 3) 905 self.assertAlmostEqual(spin70.kex/10000, 1828.31716745568/10000, 3) 906 self.assertAlmostEqual(spin70.chi2, 55.2887487843661, 3) 907 self.assertAlmostEqual(spin71.r2[r20_key1], 4.92979173044978, 3) 908 self.assertAlmostEqual(spin71.pA, 0.528883026272818, 3) 909 self.assertAlmostEqual(spin71.dw, 0.488914314879541, 3) 910 self.assertAlmostEqual(spin71.kex/10000, 2568.1215115528/10000, 3) 911 self.assertAlmostEqual(spin71.chi2, 4.01287787463568, 3)
912 913
915 """Optimisation of Dr. Flemming Hansen's CPMG data to the CR72 dispersion model. 916 917 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period. 918 """ 919 920 # Base data setup. 921 self.setup_hansen_cpmg_data(model='CR72') 922 923 # Alias the spins. 924 spin70 = return_spin(":70") 925 spin71 = return_spin(":71") 926 927 # The R20 keys. 928 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) 929 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) 930 931 # Set the initial parameter values. 932 spin70.r2 = {r20_key1: 7.0, r20_key2: 9.0} 933 spin70.pA = 0.9 934 spin70.dw = 6.0 935 spin70.kex = 1500.0 936 spin71.r2 = {r20_key1: 5, r20_key2: 9.0} 937 spin71.pA = 0.9 938 spin71.dw = 4.0 939 spin71.kex = 1900.0 940 941 # Low precision optimisation. 942 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1) 943 944 # Printout. 945 print("\n\nOptimised parameters:\n") 946 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 947 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1])) 948 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2])) 949 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA)) 950 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw)) 951 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex)) 952 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 953 954 # Checks for residue :70. 955 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97260604007474, 4) 956 self.assertAlmostEqual(spin70.r2[r20_key2], 9.41009302654463, 2) 957 self.assertAlmostEqual(spin70.pA, 0.989856764756131, 4) 958 self.assertAlmostEqual(spin70.dw, 5.60887354423638, 3) 959 self.assertAlmostEqual(spin70.kex/1000, 1752.75852303464/1000, 3) 960 self.assertAlmostEqual(spin70.chi2, 53.8382124791236, 4) 961 962 # Checks for residue :71. 963 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00310788169096, 4) 964 self.assertAlmostEqual(spin71.pA, 0.985946406482083, 4) 965 self.assertAlmostEqual(spin71.dw, 2.00673221077749, 4) 966 self.assertAlmostEqual(spin71.kex/1000, 2480.52477627298/1000, 4) 967 self.assertAlmostEqual(spin71.chi2, 15.6595392846911, 4) 968 969 # Test the conversion to k_AB from kex and pA. 970 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA)) 971 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA)) 972 973 # Test the conversion to k_BA from kex and pA. 974 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA) 975 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
976 977
979 """Optimisation of Dr. Flemming Hansen's CPMG data to the CR72 full dispersion model. 980 981 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period. 982 """ 983 984 # Base data setup. 985 self.setup_hansen_cpmg_data(model='CR72 full') 986 987 # Alias the spins. 988 spin70 = return_spin(":70") 989 spin71 = return_spin(":71") 990 991 # The R20 keys. 992 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) 993 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) 994 995 # Set the initial parameter values. 996 spin70.r2a = {r20_key1: 7.0, r20_key2: 9.0} 997 spin70.r2b = {r20_key1: 7.0, r20_key2: 9.0} 998 spin70.pA = 0.9 999 spin70.dw = 6.0 1000 spin70.kex = 1500.0 1001 spin71.r2a = {r20_key1: 5.0, r20_key2: 9.0} 1002 spin71.r2b = {r20_key1: 5.0, r20_key2: 9.0} 1003 spin71.pA = 0.9 1004 spin71.dw = 4.0 1005 spin71.kex = 1900.0 1006 1007 # Low precision optimisation. 1008 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1) 1009 1010 # Printout. 1011 print("\n\nOptimised parameters:\n") 1012 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 1013 print("%-20s %20.15g %20.15g" % ("R2A (500 MHz)", spin70.r2a[r20_key1], spin71.r2a[r20_key1])) 1014 print("%-20s %20.15g %20.15g" % ("R2B (500 MHz)", spin70.r2b[r20_key1], spin71.r2b[r20_key1])) 1015 print("%-20s %20.15g %20.15g" % ("R2A (800 MHz)", spin70.r2a[r20_key2], spin71.r2a[r20_key2])) 1016 print("%-20s %20.15g %20.15g" % ("R2B (800 MHz)", spin70.r2b[r20_key2], spin71.r2b[r20_key2])) 1017 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA)) 1018 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw)) 1019 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex)) 1020 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 1021 1022 # Checks for residue :70. 1023 self.assertAlmostEqual(spin70.r2a[r20_key1], 6.69755822995605, 4) 1024 self.assertAlmostEqual(spin70.r2b[r20_key1], 2.75294308690228, 4) 1025 self.assertAlmostEqual(spin70.r2a[r20_key2], 8.18393516578432, 4) 1026 self.assertAlmostEqual(spin70.r2b[r20_key2], 97.3047470071814, 4) 1027 self.assertAlmostEqual(spin70.pA, 0.988929729034413, 4) 1028 self.assertAlmostEqual(spin70.dw, 5.51938354518713, 4) 1029 self.assertAlmostEqual(spin70.kex/1000, 1892.82682092974/1000, 4) 1030 self.assertAlmostEqual(spin70.chi2, 48.5815698897158, 4) 1031 1032 # Checks for residue :71. 1033 self.assertAlmostEqual(spin71.r2a[r20_key1], 4.79839795614044, 4) 1034 self.assertAlmostEqual(spin71.r2b[r20_key1], 12.8793124032989, 4) 1035 self.assertAlmostEqual(spin71.pA, 0.978971448838756, 4) 1036 self.assertAlmostEqual(spin71.dw, 1.67873004594096, 4) 1037 self.assertAlmostEqual(spin71.kex/1000, 2527.80893069607/1000, 4) 1038 self.assertAlmostEqual(spin71.chi2, 14.3394771268074, 4) 1039 1040 # Test the conversion to k_AB from kex and pA. 1041 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA)) 1042 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA)) 1043 1044 # Test the conversion to k_BA from kex and pA. 1045 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA) 1046 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
1047 1048
1050 """Optimisation of Dr. Flemming Hansen's CPMG data to the IT99 dispersion model. 1051 1052 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period. 1053 """ 1054 1055 # Base data setup. 1056 self.setup_hansen_cpmg_data(model='IT99') 1057 1058 # Alias the spins. 1059 spin70 = return_spin(":70") 1060 spin71 = return_spin(":71") 1061 1062 # The R20 keys. 1063 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) 1064 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) 1065 1066 # Set the initial parameter values. 1067 spin70.r2 = {r20_key1: 8.8, r20_key2: 16.6} 1068 spin70.dw = 10.0 1069 spin70.pA = 0.5 1070 spin70.tex = 1000.09 1071 spin71.r2 = {r20_key1: 1.0, r20_key2: 1.0} 1072 spin71.dw = 10.0 1073 spin71.pA = 0.95 1074 spin71.tex = 0.1 1075 1076 # Low precision optimisation. 1077 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-10, grad_tol=None, max_iter=10000, constraints=True, scaling=True, verbosity=1) 1078 1079 # Printout. 1080 print("\n\nOptimised parameters:\n") 1081 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 1082 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1])) 1083 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2])) 1084 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw)) 1085 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA)) 1086 print("%-20s %20.15g %20.15g" % ("tex", spin70.tex, spin71.tex)) 1087 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 1088 1089 # Checks for residue :70. 1090 self.assertAlmostEqual(spin70.r2[r20_key1], 7.24471197811838, 4) 1091 self.assertAlmostEqual(spin70.r2[r20_key2], 10.0571040704729, 4) 1092 self.assertAlmostEqual(spin70.dw, 5.2116923222744, 4) 1093 self.assertAlmostEqual(spin70.pA, 0.990253627907212, 4) 1094 self.assertAlmostEqual(spin70.tex*1000, 0.000638394793480444*1000, 4) 1095 self.assertAlmostEqual(spin70.chi2, 93.5135798618747, 4) 1096 1097 # Checks for residue :71. 1098 self.assertAlmostEqual(spin71.r2[r20_key1], 5.05971235970214, 4) 1099 self.assertAlmostEqual(spin71.r2[r20_key2], 6.96641194493447, 4) 1100 self.assertAlmostEqual(spin71.dw, 0.435389946897141, 4) 1101 self.assertAlmostEqual(spin71.pA, 0.500000000213519, 3) 1102 self.assertAlmostEqual(spin71.tex*1000, 0.000372436400585538*1000, 4) 1103 self.assertAlmostEqual(spin71.chi2, 23.7895798801404, 4)
1104 1105
1107 """Optimisation of Dr. Flemming Hansen's CPMG data to the LM63 dispersion model. 1108 1109 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period. 1110 """ 1111 1112 # Base data setup. 1113 self.setup_hansen_cpmg_data(model='LM63') 1114 1115 # Alias the spins. 1116 spin70 = return_spin(":70") 1117 spin71 = return_spin(":71") 1118 1119 # The R20 keys. 1120 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) 1121 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) 1122 1123 # Set the initial parameter values. 1124 spin70.r2 = {r20_key1: 7.0, r20_key2: 7.0} 1125 spin70.phi_ex = 0.3 1126 spin70.kex = 5000.0 1127 spin71.r2 = {r20_key1: 5.0, r20_key2: 9.0} 1128 spin71.phi_ex = 0.1 1129 spin71.kex = 2500.0 1130 1131 # Low precision optimisation. 1132 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-25, grad_tol=None, max_iter=10000000, constraints=True, scaling=True, verbosity=1) 1133 1134 # Printout. 1135 print("\n\nOptimised parameters:\n") 1136 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 1137 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1])) 1138 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2])) 1139 print("%-20s %20.15g %20.15g" % ("phi_ex", spin70.phi_ex, spin71.phi_ex)) 1140 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex)) 1141 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 1142 1143 # Checks for residue :70. 1144 self.assertAlmostEqual(spin70.r2[r20_key1], 6.74362294539099) 1145 self.assertAlmostEqual(spin70.r2[r20_key2], 6.57406797067481) 1146 self.assertAlmostEqual(spin70.phi_ex, 0.312733013751449) 1147 self.assertAlmostEqual(spin70.kex/1000, 4723.09897146338/1000) 1148 self.assertAlmostEqual(spin70.chi2, 363.534044873483) 1149 1150 # Checks for residue :71. 1151 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00776657712558) 1152 self.assertAlmostEqual(spin71.phi_ex, 0.0553787828347638) 1153 self.assertAlmostEqual(spin71.kex/1000, 2781.72293906248/1000) 1154 self.assertAlmostEqual(spin71.chi2, 17.0776399916287)
1155 1156
1158 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site 3D' dispersion model. 1159 1160 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period. 1161 """ 1162 1163 # Base data setup. 1164 self.setup_hansen_cpmg_data(model='NS CPMG 2-site 3D') 1165 1166 # Alias the spins. 1167 spin70 = return_spin(":70") 1168 spin71 = return_spin(":71") 1169 1170 # The R20 keys. 1171 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) 1172 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) 1173 1174 # Set the initial parameter values. 1175 spin70.r2 = {r20_key1: 6.994165925, r20_key2: 9.428129427} 1176 spin70.pA = 0.9897754407 1177 spin70.dw = 5.642418428 1178 spin70.kex = 1743.666375 1179 spin71.r2 = {r20_key1: 4.978654237, r20_key2: 9.276918959} 1180 spin71.pA = 0.9968032899 1181 spin71.dw = 4.577891393 1182 spin71.kex = 1830.044597 1183 1184 # Low precision optimisation. 1185 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=False, scaling=True, verbosity=1) 1186 1187 # Printout. 1188 print("\n\nOptimised parameters:\n") 1189 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 1190 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1])) 1191 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2])) 1192 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA)) 1193 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw)) 1194 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex)) 1195 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 1196 1197 # Checks for residue :70. 1198 self.assertAlmostEqual(spin70.r2[r20_key1], 6.95797760459016, 4) 1199 self.assertAlmostEqual(spin70.r2[r20_key2], 9.39628959312699, 4) 1200 self.assertAlmostEqual(spin70.pA, 0.989700985380975, 4) 1201 self.assertAlmostEqual(spin70.dw, 5.6733714171086, 4) 1202 self.assertAlmostEqual(spin70.kex/1000, 1713.63101361545/1000, 4) 1203 self.assertAlmostEqual(spin70.chi2, 52.5106928523775, 4) 1204 1205 # Checks for residue :71. 1206 self.assertAlmostEqual(spin71.r2[r20_key1], 4.99893565849977, 4) 1207 self.assertAlmostEqual(spin71.r2[r20_key2], 6.89825625944034, 4) 1208 self.assertAlmostEqual(spin71.pA, 0.986716058519642, 4) 1209 self.assertAlmostEqual(spin71.dw, 2.09292495350993, 4) 1210 self.assertAlmostEqual(spin71.kex/1000, 2438.04423541463/1000, 4) 1211 self.assertAlmostEqual(spin71.chi2, 15.164490242352, 4) 1212 1213 # Test the conversion to k_AB from kex and pA. 1214 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA)) 1215 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA)) 1216 1217 # Test the conversion to k_BA from kex and pA. 1218 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA) 1219 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
1220 1221
1223 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site 3D full' dispersion model. 1224 1225 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period. 1226 """ 1227 1228 # Base data setup. 1229 self.setup_hansen_cpmg_data(model='NS CPMG 2-site 3D full') 1230 1231 # Alias the spins. 1232 spin70 = return_spin(":70") 1233 spin71 = return_spin(":71") 1234 1235 # The R20 keys. 1236 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) 1237 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) 1238 1239 # Set the initial parameter values. 1240 spin70.r2a = {r20_key1: 6.644753428, r20_key2: 7.891776687} 1241 spin70.r2b = {r20_key1: 7.163478485, r20_key2: 138.5170395} 1242 spin70.pA = 0.9884781357 1243 spin70.dw = 5.456507396 1244 spin70.kex = 1906.521189 1245 spin71.r2a = {r20_key1: 4.99893524108981, r20_key2: 100.0} 1246 spin71.r2b = {r20_key1: 8.27456243639973, r20_key2: 100.0} 1247 spin71.pA = 0.986709616684097 1248 spin71.dw = 2.09245158280905 1249 spin71.kex = 2438.2766211401 1250 1251 # Low precision optimisation. 1252 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=False, scaling=True, verbosity=1) 1253 1254 # Printout. 1255 print("\n\nOptimised parameters:\n") 1256 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 1257 print("%-20s %20.15g %20.15g" % ("R2A (500 MHz)", spin70.r2a[r20_key1], spin71.r2a[r20_key1])) 1258 print("%-20s %20.15g %20.15g" % ("R2B (500 MHz)", spin70.r2b[r20_key1], spin71.r2b[r20_key1])) 1259 print("%-20s %20.15g %20.15g" % ("R2A (800 MHz)", spin70.r2a[r20_key2], spin71.r2a[r20_key2])) 1260 print("%-20s %20.15g %20.15g" % ("R2B (800 MHz)", spin70.r2b[r20_key2], spin71.r2b[r20_key2])) 1261 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA)) 1262 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw)) 1263 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex)) 1264 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 1265 1266 # Checks for residue :70. 1267 self.assertAlmostEqual(spin70.r2a[r20_key1], 6.61176004043484, 4) 1268 self.assertAlmostEqual(spin70.r2b[r20_key1], 7.4869316381241, 4) 1269 self.assertAlmostEqual(spin70.r2a[r20_key2], 7.78200386067591, 4) 1270 self.assertAlmostEqual(spin70.r2b[r20_key2], 141.703593742468, 4) 1271 self.assertAlmostEqual(spin70.pA, 0.988404987055969, 4) 1272 self.assertAlmostEqual(spin70.dw, 5.4497360203213, 4) 1273 self.assertAlmostEqual(spin70.kex/1000, 1934.09304607082/1000, 4) 1274 self.assertAlmostEqual(spin70.chi2, 44.6793752187925, 4) 1275 1276 # Checks for residue :71. 1277 self.assertAlmostEqual(spin71.r2a[r20_key1], 4.6013095731966, 4) 1278 self.assertAlmostEqual(spin71.r2b[r20_key1], 13.3245678276332, 4) 1279 self.assertAlmostEqual(spin71.r2a[r20_key2], 2.08243621257779, 4) 1280 self.assertAlmostEqual(spin71.r2b[r20_key2], 153.355765094575, 4) 1281 self.assertAlmostEqual(spin71.pA, 0.9665748685124, 4) 1282 self.assertAlmostEqual(spin71.dw, 1.41898001408953, 4) 1283 self.assertAlmostEqual(spin71.kex/1000, 2580.65795560688/1000, 4) 1284 self.assertAlmostEqual(spin71.chi2, 13.4937006732165, 4) 1285 1286 # Test the conversion to k_AB from kex and pA. 1287 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA)) 1288 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA)) 1289 1290 # Test the conversion to k_BA from kex and pA. 1291 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA) 1292 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
1293 1294
1296 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site expanded' dispersion model. 1297 1298 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period. 1299 """ 1300 1301 # Base data setup. 1302 self.setup_hansen_cpmg_data(model='NS CPMG 2-site expanded') 1303 1304 # Alias the spins. 1305 spin70 = return_spin(":70") 1306 spin71 = return_spin(":71") 1307 1308 # The R20 keys. 1309 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) 1310 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) 1311 1312 # Set the initial parameter values. 1313 spin70.r2 = {r20_key1: 7.0, r20_key2: 9.0} 1314 spin70.pA = 0.9 1315 spin70.dw = 6.0 1316 spin70.kex = 1500.0 1317 spin71.r2 = {r20_key1: 5.0, r20_key2: 9.0} 1318 spin71.pA = 0.9 1319 spin71.dw = 4.0 1320 spin71.kex = 1900.0 1321 1322 # Low precision optimisation. 1323 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1) 1324 1325 # Printout. 1326 print("\n\nOptimised parameters:\n") 1327 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 1328 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1])) 1329 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2])) 1330 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA)) 1331 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw)) 1332 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex)) 1333 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 1334 1335 # Checks for residue :70. 1336 self.assertAlmostEqual(spin70.r2[r20_key1], 6.9580924599737, 4) 1337 self.assertAlmostEqual(spin70.r2[r20_key2], 9.39653925942454, 4) 1338 self.assertAlmostEqual(spin70.pA, 0.989701162762885, 4) 1339 self.assertAlmostEqual(spin70.dw, 5.67331932250604, 4) 1340 self.assertAlmostEqual(spin70.kex/1000, 1713.56202177775/1000, 4) 1341 self.assertAlmostEqual(spin70.chi2, 52.510685225092, 4) 1342 1343 # Checks for residue :71. 1344 self.assertAlmostEqual(spin71.r2[r20_key1], 4.99888477245306, 4) 1345 self.assertAlmostEqual(spin71.r2[r20_key2], 6.89804393936759, 4) 1346 self.assertAlmostEqual(spin71.pA, 0.986705757536079, 4) 1347 self.assertAlmostEqual(spin71.dw, 2.09219403018313, 4) 1348 self.assertAlmostEqual(spin71.kex/1000, 2438.48401194464/1000, 4) 1349 self.assertAlmostEqual(spin71.chi2, 15.1644881118593, 4) 1350 1351 # Test the conversion to k_AB from kex and pA. 1352 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA)) 1353 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA)) 1354 1355 # Test the conversion to k_BA from kex and pA. 1356 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA) 1357 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
1358 1359
1361 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site star' dispersion model. 1362 1363 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period. 1364 """ 1365 1366 # Base data setup. 1367 self.setup_hansen_cpmg_data(model='NS CPMG 2-site star') 1368 1369 # Alias the spins. 1370 spin70 = return_spin(":70") 1371 spin71 = return_spin(":71") 1372 1373 # The R20 keys. 1374 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) 1375 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) 1376 1377 # Set the initial parameter values. 1378 spin70.r2 = {r20_key1: 6.996327746, r20_key2: 9.452051268} 1379 spin70.pA = 0.9897519798 1380 spin70.dw = 5.644862195 1381 spin70.kex = 1723.820567 1382 spin71.r2 = {r20_key1: 4.978654237, r20_key2: 9.276918959} 1383 spin71.pA = 0.9968032899 1384 spin71.dw = 4.577891393 1385 spin71.kex = 1830.044597 1386 1387 # Low precision optimisation. 1388 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=False, scaling=True, verbosity=1) 1389 1390 # Printout. 1391 print("\n\nOptimised parameters:\n") 1392 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)")) 1393 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1])) 1394 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2])) 1395 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA)) 1396 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw)) 1397 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex)) 1398 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2)) 1399 1400 # Checks for residue :70. 1401 self.assertAlmostEqual(spin70.r2[r20_key1], 6.95543947938561, 1) 1402 self.assertAlmostEqual(spin70.r2[r20_key2], 9.38991914134929, 1) 1403 self.assertAlmostEqual(spin70.pA, 0.989702750971153, 3) 1404 self.assertAlmostEqual(spin70.dw, 5.67527122494516, 1) 1405 self.assertAlmostEqual(spin70.kex/1000, 1715.72032391817/1000, 1) 1406 self.assertAlmostEqual(spin70.chi2, 52.5011991483842, 1) 1407 1408 # Checks for residue :71. 1409 self.assertAlmostEqual(spin71.r2[r20_key1], 4.992594256544, 1) 1410 self.assertAlmostEqual(spin71.pA, 0.992258541625787, 2) 1411 self.assertAlmostEqual(spin71.dw/100, 2.75140650899058/100, 2) 1412 self.assertAlmostEqual(spin71.kex/100000, 2106.60885247431/100000, 2) 1413 self.assertAlmostEqual(spin71.chi2/100, 17.3293856656588/100, 1) 1414 1415 # Test the conversion to k_AB from kex and pA. 1416 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA)) 1417 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA)) 1418 1419 # Test the conversion to k_BA from kex and pA. 1420 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA) 1421 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
1422 1423
1425 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site star full' dispersion model. 1426 1427 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period. 1428 """ 1429 1430 # Base data setup. 1431 self.setup_hansen_cpmg_data(model='NS CPMG 2-site star full') 1432 1433 # Alias the spins. 1434 spin70 = return_spin(":70") 1435 spin71 = return_spin(":71") 1436 1437 # The R20 keys. 1438 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) 1439 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) 1440 1441 # Set the initial parameter values. 1442 spin70.r2a = {r20_key1: 6.44836878645126, r20_key2: 7.00382877393494} 1443 spin70.r2b = {r20_key1: 12.2083127421994, r20_key2: 199.862962628402} 1444 spin70.pA = 0.987648082613451 1445 spin70.dw = 5.30679853807572 1446 spin70.kex = 2033.25380420666 1447 spin71.r2a = {r20_key1: 4.992594256544, r20_key2: 6.98674718938435} 1448 spin71.r2b = {r20_key1: 4.992594256544, r20_key2: 6.98674718938435} 1449 spin71.pA = 0.992258541625787 1450 spin71.dw = 2.75140650899058 1451 spin71.kex = 2106.60885247431 1452 1453 # Low precision optimisation. 1454 self.interpreter.calc() 1455 1456 # Checks for residue :70. 1457 self.assertAlmostEqual(spin70.chi2/10, 45.773987568491123/10, 2) 1458 self.assertAlmostEqual(spin71.chi2/10, 17.329385665659192/10, 2)
1459 1460
1461 - def test_hansen_cpmgfit_input(self):
1462 """Conversion of Dr. Flemming Hansen's CPMG R2eff values into input files for CPMGFit. 1463 1464 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period. 1465 """ 1466 1467 # Load the R2eff results file. 1468 file_name = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Hansen'+sep+'r2eff_pipe' 1469 self.interpreter.results.read(file_name) 1470 self.interpreter.deselect.spin(':4') 1471 1472 # Set up the model. 1473 self.interpreter.relax_disp.select_model('LM63') 1474 1475 # Generate the input files. 1476 self.interpreter.relax_disp.cpmgfit_input(force=True, dir=ds.tmpdir) 1477 1478 # What the files should contain. 1479 batch_file = ['#! /bin/sh\n', '\n', 'cpmgfit -grid -xmgr -f spin_70_N.in | tee spin_70_N.out\n', 'cpmgfit -grid -xmgr -f spin_71_N.in | tee spin_71_N.out\n'] 1480 spin1 = [ 1481 "title :70@N\n", 1482 "fields 2 11.7432964915 18.7892743865\n", 1483 "function CPMG\n", 1484 "R2 1 10 20\n", 1485 "Rex 0 100.0 100\n", 1486 "Tau 0 10.0 100\n", 1487 "xmgr\n", 1488 "@ xaxis label \"1/tcp (1/ms)\"\n", 1489 "@ yaxis label \"R2(tcp) (rad/s)\"\n", 1490 "@ xaxis ticklabel format decimal\n", 1491 "@ yaxis ticklabel format decimal\n", 1492 "@ xaxis ticklabel char size 0.8\n", 1493 "@ yaxis ticklabel char size 0.8\n", 1494 "@ world xmin 0.0\n", 1495 "data\n", 1496 "0.133333 16.045541 0.310925 11.743296 \n", 1497 "0.266667 14.877925 0.303217 11.743296 \n", 1498 "0.400000 14.357820 0.299894 11.743296 \n", 1499 "0.533333 12.664495 0.289532 11.743296 \n", 1500 "0.666667 12.363205 0.287760 11.743296 \n", 1501 "0.800000 11.092532 0.280514 11.743296 \n", 1502 "0.933333 10.566090 0.277619 11.743296 \n", 1503 "1.066667 9.805807 0.273544 11.743296 \n", 1504 "1.200000 9.564301 0.272276 11.743296 \n", 1505 "1.333333 9.015634 0.269442 11.743296 \n", 1506 "1.466667 8.607765 0.267375 11.743296 \n", 1507 "1.600000 8.279997 0.265740 11.743296 \n", 1508 "1.733333 8.474536 0.266708 11.743296 \n", 1509 "1.866667 8.158973 0.265141 11.743296 \n", 1510 "2.000000 7.988631 0.264304 11.743296 \n", 1511 "0.133333 22.224914 0.166231 18.789274 \n", 1512 "0.266667 21.230874 0.162377 18.789274 \n", 1513 "0.400000 20.603704 0.160017 18.789274 \n", 1514 "0.533333 20.327797 0.158996 18.789274 \n", 1515 "0.666667 18.855377 0.153719 18.789274 \n", 1516 "0.800000 18.537531 0.152617 18.789274 \n", 1517 "0.933333 17.508069 0.149138 18.789274 \n", 1518 "1.066667 16.035604 0.144391 18.789274 \n", 1519 "1.200000 15.168192 0.141717 18.789274 \n", 1520 "1.333333 14.431802 0.139516 18.789274 \n", 1521 "1.466667 14.034137 0.138354 18.789274 \n", 1522 "1.600000 12.920148 0.135192 18.789274 \n", 1523 "1.733333 12.653673 0.134456 18.789274 \n", 1524 "1.866667 12.610864 0.134338 18.789274 \n", 1525 "2.000000 11.969303 0.132601 18.789274 \n" 1526 ] 1527 spin2 = [ 1528 "title :71@N\n", 1529 "fields 2 11.7432964915 18.7892743865\n", 1530 "function CPMG\n", 1531 "R2 1 10 20\n", 1532 "Rex 0 100.0 100\n", 1533 "Tau 0 10.0 100\n", 1534 "xmgr\n", 1535 "@ xaxis label \"1/tcp (1/ms)\"\n", 1536 "@ yaxis label \"R2(tcp) (rad/s)\"\n", 1537 "@ xaxis ticklabel format decimal\n", 1538 "@ yaxis ticklabel format decimal\n", 1539 "@ xaxis ticklabel char size 0.8\n", 1540 "@ yaxis ticklabel char size 0.8\n", 1541 "@ world xmin 0.0\n", 1542 "data\n", 1543 "0.133333 7.044342 0.170035 11.743296 \n", 1544 "0.266667 6.781033 0.169228 11.743296 \n", 1545 "0.400000 6.467623 0.168279 11.743296 \n", 1546 "0.533333 6.333340 0.167876 11.743296 \n", 1547 "0.666667 6.323238 0.167846 11.743296 \n", 1548 "0.800000 6.005245 0.166902 11.743296 \n", 1549 "0.933333 5.767052 0.166203 11.743296 \n", 1550 "1.066667 5.476968 0.165361 11.743296 \n", 1551 "1.200000 5.469949 0.165341 11.743296 \n", 1552 "1.333333 5.295113 0.164838 11.743296 \n", 1553 "1.466667 5.435648 0.165242 11.743296 \n", 1554 "1.600000 5.410400 0.165169 11.743296 \n", 1555 "1.733333 5.437554 0.165247 11.743296 \n", 1556 "1.866667 5.176844 0.164501 11.743296 \n", 1557 "2.000000 5.227232 0.164644 11.743296 \n", 1558 "0.133333 11.530903 0.081928 18.789274 \n", 1559 "0.266667 10.983094 0.081041 18.789274 \n", 1560 "0.400000 10.512403 0.080294 18.789274 \n", 1561 "0.533333 9.984805 0.079473 18.789274 \n", 1562 "0.666667 9.573163 0.078845 18.789274 \n", 1563 "0.800000 9.178810 0.078253 18.789274 \n", 1564 "0.933333 8.935719 0.077893 18.789274 \n", 1565 "1.066667 8.610147 0.077416 18.789274 \n", 1566 "1.200000 8.353778 0.077045 18.789274 \n", 1567 "1.333333 8.173729 0.076787 18.789274 \n", 1568 "1.466667 8.091607 0.076670 18.789274 \n", 1569 "1.600000 7.706420 0.076126 18.789274 \n", 1570 "1.733333 7.709125 0.076129 18.789274 \n", 1571 "1.866667 7.610856 0.075992 18.789274 \n", 1572 "2.000000 7.552584 0.075911 18.789274 \n", 1573 ] 1574 1575 # Check the batch file. 1576 print("\nChecking the batch file.") 1577 file = open("%s%sbatch_run.sh" % (ds.tmpdir, sep)) 1578 lines = file.readlines() 1579 file.close() 1580 for i in range(len(lines)): 1581 self.assertEqual(batch_file[i], lines[i]) 1582 1583 # Check spin :70@N. 1584 print("\nChecking the spin :70@N input file.") 1585 file = open("%s%sspin%s.in" % (ds.tmpdir, sep, '_70_N')) 1586 lines = file.readlines() 1587 file.close() 1588 for i in range(len(lines)): 1589 print("%s\"%s\\n\"," % (" "*12, lines[i][:-1])) 1590 for i in range(len(lines)): 1591 self.assertEqual(spin1[i], lines[i]) 1592 1593 # Check spin :71@N. 1594 print("\nChecking the spin :71@N input file.") 1595 file = open("%s%sspin%s.in" % (ds.tmpdir, sep, '_71_N')) 1596 lines = file.readlines() 1597 file.close() 1598 for i in range(len(lines)): 1599 print("%s\"%s\\n\"," % (" "*12, lines[i][:-1])) 1600 for i in range(len(lines)): 1601 self.assertEqual(spin2[i], lines[i])
1602 1603
1605 """Optimisation of the Korzhnev et al., 2005 15N DQ CPMG data using the 'NS MMQ 2-site' model. 1606 1607 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant. 1608 1609 Here only the 15N DQ data will be optimised. The values found by cpmg_fit using just this data are: 1610 1611 - r2 = {'500': 9.487269007171426, '600': 11.718267257562591, '800': 13.624551743116887}, 1612 - pA = 0.965402506690231, 1613 - dw = 0.805197170133360, 1614 - dwH = -0.595536627771890, 1615 - kex = 569.003663067619868, 1616 - chi2 = 9.297671357952812. 1617 """ 1618 1619 # Base data setup. 1620 self.setup_korzhnev_2005_data(data_list=['DQ']) 1621 1622 # Alias the spin. 1623 spin = return_spin(":9@N") 1624 1625 # The R20 keys. 1626 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=500e6) 1627 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=600e6) 1628 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=800e6) 1629 1630 # Set the initial parameter values. 1631 spin.r2 = {r20_key1: 9.48527908326952, r20_key2: 11.7135951595536, r20_key3: 13.6153887849344} 1632 spin.pA = 0.965638501551899 1633 spin.dw = 2.8537583461577 1634 spin.dwH = -0.387633062766635 1635 spin.kex = 573.704033851592 1636 1637 # Low precision optimisation. 1638 self.interpreter.minimise(min_algor='simplex', func_tol=1e-05, max_iter=1000) 1639 1640 # Monte Carlo simulations. 1641 self.interpreter.monte_carlo.setup(number=2) 1642 self.interpreter.monte_carlo.create_data(method='back_calc') 1643 self.interpreter.monte_carlo.initial_values() 1644 self.interpreter.minimise(min_algor='simplex', max_iter=10) 1645 self.interpreter.monte_carlo.error_analysis() 1646 1647 # Plot the dispersion curves. 1648 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True) 1649 1650 # Save the results. 1651 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True) 1652 1653 # Printout. 1654 print("\n\nOptimised parameters:\n") 1655 print("%-20s %-20s" % ("Parameter", "Value (:9)")) 1656 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1])) 1657 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2])) 1658 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3])) 1659 print("%-20s %20.15g" % ("pA", spin.pA)) 1660 print("%-20s %20.15g" % ("dw", spin.dw)) 1661 print("%-20s %20.15g" % ("dwH", spin.dwH)) 1662 print("%-20s %20.15g" % ("kex", spin.kex)) 1663 print("%-20s %20.15g\n" % ("chi2", spin.chi2)) 1664 1665 # Checks for residue :9. 1666 self.assertAlmostEqual(spin.r2[r20_key1], 9.48527908326952, 2) 1667 self.assertAlmostEqual(spin.r2[r20_key2], 11.7135951595536, 2) 1668 self.assertAlmostEqual(spin.r2[r20_key3], 13.6153887849344, 2) 1669 self.assertAlmostEqual(spin.pA, 0.965638501551899, 4) 1670 self.assertAlmostEqual(spin.dw, 2.8537583461577, 1) 1671 self.assertAlmostEqual(spin.dwH, -0.387633062766635, 2) 1672 self.assertAlmostEqual(spin.kex/1000, 573.704033851592/1000, 3) 1673 self.assertAlmostEqual(spin.chi2, 9.29563496654824, 2)
1674 1675
1677 """Optimisation of the Korzhnev et al., 2005 15N MQ CPMG data using the 'NS MMQ 2-site' model. 1678 1679 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant. 1680 1681 Here only the 15N MQ data will be optimised. The values found by cpmg_fit using just this data are: 1682 1683 - r2 = {'500': 5.993083514798655, '600': 6.622184438384841, '800': 8.640765919352019}, 1684 - pA = 0.930027999814003, 1685 - dw = 4.338620619954370, 1686 - dwH = -0.274250775560818, 1687 - kex = 344.613362916544475, 1688 - chi2 = 10.367733168217050. 1689 """ 1690 1691 # Base data setup. 1692 self.setup_korzhnev_2005_data(data_list=['MQ']) 1693 1694 # Alias the spin. 1695 spin = return_spin(":9@N") 1696 1697 # The R20 keys. 1698 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=500e6) 1699 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=600e6) 1700 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6) 1701 1702 # Set the initial parameter values. 1703 spin.r2 = {r20_key1: 6.02016436619016, r20_key2: 6.65421500772308, r20_key3: 8.6729591487622} 1704 spin.pA = 0.930083249288083 1705 spin.dw = 4.33890689462363 1706 spin.dwH = -0.274316585638047 1707 spin.kex = 344.329651956132 1708 1709 # Low precision optimisation. 1710 self.interpreter.minimise(min_algor='simplex', func_tol=1e-05, max_iter=1000) 1711 1712 # Monte Carlo simulations. 1713 self.interpreter.monte_carlo.setup(number=2) 1714 self.interpreter.monte_carlo.create_data(method='back_calc') 1715 self.interpreter.monte_carlo.initial_values() 1716 self.interpreter.minimise(min_algor='simplex', max_iter=10) 1717 self.interpreter.monte_carlo.error_analysis() 1718 1719 # Plot the dispersion curves. 1720 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True) 1721 1722 # Save the results. 1723 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True) 1724 1725 # Printout. 1726 print("\n\nOptimised parameters:\n") 1727 print("%-20s %-20s" % ("Parameter", "Value (:9)")) 1728 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1])) 1729 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2])) 1730 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3])) 1731 print("%-20s %20.15g" % ("pA", spin.pA)) 1732 print("%-20s %20.15g" % ("dw", spin.dw)) 1733 print("%-20s %20.15g" % ("dwH", spin.dwH)) 1734 print("%-20s %20.15g" % ("kex", spin.kex)) 1735 print("%-20s %20.15g\n" % ("chi2", spin.chi2)) 1736 1737 # Checks for residue :9. 1738 self.assertAlmostEqual(spin.r2[r20_key1], 6.02016436619016, 1) 1739 self.assertAlmostEqual(spin.r2[r20_key2], 6.65421500772308, 1) 1740 self.assertAlmostEqual(spin.r2[r20_key3], 8.6729591487622, 1) 1741 self.assertAlmostEqual(spin.pA, 0.930083249288083, 3) 1742 self.assertAlmostEqual(spin.dw, 4.33890689462363, 2) 1743 self.assertAlmostEqual(spin.dwH, -0.274316585638047, 3) 1744 self.assertAlmostEqual(spin.kex/1000, 344.329651956132/1000, 3) 1745 self.assertAlmostEqual(spin.chi2, 10.3654315659173, 2)
1746 1747
1749 """Optimisation of the Korzhnev et al., 2005 15N SQ CPMG data using the 'NS MMQ 2-site' model. 1750 1751 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant. 1752 1753 Here only the 15N SQ data will be optimised. The values found by cpmg_fit using just this data are: 1754 1755 - r2 = {'500': 8.335037972570017, '600': 8.761366016417508, '800': 10.225001019091822}, 1756 - pA = 0.950003458294991, 1757 - dw = 4.358402855315123, 1758 - kex = 429.906473361926999, 1759 - chi2 = 17.393331915567252. 1760 """ 1761 1762 # Base data setup. 1763 self.setup_korzhnev_2005_data(data_list=['SQ']) 1764 1765 # Alias the spin. 1766 spin = return_spin(":9@N") 1767 1768 # The R20 keys. 1769 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) 1770 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6) 1771 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) 1772 1773 # Set the initial parameter values. 1774 spin.r2 = {r20_key1: 8.334232330326190, r20_key2: 8.756773997879968, r20_key3: 10.219320492033058} 1775 spin.pA = 0.950310172115387 1776 spin.dw = 4.356737157889636 1777 spin.kex = 433.176323890829849 1778 1779 # Low precision optimisation. 1780 self.interpreter.minimise(min_algor='simplex', func_tol=1e-05, max_iter=1000) 1781 1782 # Monte Carlo simulations. 1783 self.interpreter.monte_carlo.setup(number=2) 1784 self.interpreter.monte_carlo.create_data(method='back_calc') 1785 self.interpreter.monte_carlo.initial_values() 1786 self.interpreter.minimise(min_algor='simplex', max_iter=10) 1787 self.interpreter.monte_carlo.error_analysis() 1788 1789 # Plot the dispersion curves. 1790 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True) 1791 1792 # Save the results. 1793 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True) 1794 1795 # Printout. 1796 print("\n\nOptimised parameters:\n") 1797 print("%-20s %-20s" % ("Parameter", "Value (:9)")) 1798 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1])) 1799 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2])) 1800 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3])) 1801 print("%-20s %20.15g" % ("pA", spin.pA)) 1802 print("%-20s %20.15g" % ("dw", spin.dw)) 1803 print("%-20s %20.15g" % ("kex", spin.kex)) 1804 print("%-20s %20.15g\n" % ("chi2", spin.chi2)) 1805 1806 # Checks for residue :9. 1807 self.assertAlmostEqual(spin.r2[r20_key1], 8.334232330326190, 2) 1808 self.assertAlmostEqual(spin.r2[r20_key2], 8.756773997879968, 2) 1809 self.assertAlmostEqual(spin.r2[r20_key3], 10.219320492033058, 1) 1810 self.assertAlmostEqual(spin.pA, 0.950310172115387, 3) 1811 self.assertAlmostEqual(spin.dw, 4.356737157889636, 3) 1812 self.assertAlmostEqual(spin.kex/1000, 433.176323890829849/1000, 3) 1813 self.assertAlmostEqual(spin.chi2, 17.37460582872912, 1)
1814 1815
1817 """Optimisation of the Korzhnev et al., 2005 15N ZQ CPMG data using the 'NS MMQ 2-site' model. 1818 1819 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant. 1820 1821 Here only the 15N ZQ data will be optimised. The values found by cpmg_fit using just this data are: 1822 1823 - r2 = {'500': 5.909812628572937, '600': 6.663690132557320, '800': 6.787171647689906}, 1824 - pA = 0.942452612380140, 1825 - dw = 0.858972784230892, 1826 - dwH = 0.087155962730608, 1827 - kex = 373.219151384798920, 1828 - chi2 = 23.863208106025152. 1829 """ 1830 1831 # Base data setup. 1832 self.setup_korzhnev_2005_data(data_list=['ZQ']) 1833 1834 # Alias the spin. 1835 spin = return_spin(":9@N") 1836 1837 # The R20 keys. 1838 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=500e6) 1839 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=600e6) 1840 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=800e6) 1841 1842 # Set the initial parameter values. 1843 spin.r2 = {r20_key1: 5.91033272691614, r20_key2: 6.66368695342258, r20_key3: 6.78922219135537} 1844 spin.pA = 0.942457332074014 1845 spin.dw = 0.850592422908884 1846 spin.dwH = 0.0881272284455416 1847 spin.kex = 372.745483351305 1848 1849 # Low precision optimisation. 1850 self.interpreter.minimise(min_algor='simplex', func_tol=1e-05, max_iter=1000) 1851 1852 # Monte Carlo simulations. 1853 self.interpreter.monte_carlo.setup(number=2) 1854 self.interpreter.monte_carlo.create_data(method='back_calc') 1855 self.interpreter.monte_carlo.initial_values() 1856 self.interpreter.minimise(min_algor='simplex', max_iter=10) 1857 self.interpreter.monte_carlo.error_analysis() 1858 1859 # Plot the dispersion curves. 1860 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True) 1861 1862 # Save the results. 1863 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True) 1864 1865 # Printout. 1866 print("\n\nOptimised parameters:\n") 1867 print("%-20s %-20s" % ("Parameter", "Value (:9)")) 1868 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1])) 1869 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2])) 1870 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3])) 1871 print("%-20s %20.15g" % ("pA", spin.pA)) 1872 print("%-20s %20.15g" % ("dw", spin.dw)) 1873 print("%-20s %20.15g" % ("dwH", spin.dwH)) 1874 print("%-20s %20.15g" % ("kex", spin.kex)) 1875 print("%-20s %20.15g\n" % ("chi2", spin.chi2)) 1876 1877 # Checks for residue :9. 1878 self.assertAlmostEqual(spin.r2[r20_key1], 5.91033272691614, 2) 1879 self.assertAlmostEqual(spin.r2[r20_key2], 6.66368695342258, 2) 1880 self.assertAlmostEqual(spin.r2[r20_key3], 6.78922219135537, 2) 1881 self.assertAlmostEqual(spin.pA, 0.942457332074014, 4) 1882 self.assertAlmostEqual(spin.dw, 0.850592422908884, 1) 1883 self.assertAlmostEqual(spin.dwH, 0.0881272284455416, 2) 1884 self.assertAlmostEqual(spin.kex/1000, 372.745483351305/1000, 3) 1885 self.assertAlmostEqual(spin.chi2, 23.8464637019392, 1)
1886 1887
1889 """Optimisation of the Korzhnev et al., 2005 1H MQ CPMG data using the 'NS MMQ 2-site' model. 1890 1891 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant. 1892 1893 Here only the 1H MQ data will be optimised. The values found by cpmg_fit using just this data are: 1894 1895 - r2 = {'500': -0.000016676911302, '600': 0.036594127620440, '800': 2.131014839635728}, 1896 - pA = 0.936911090448340, 1897 - dw = 4.325314846914845, 1898 - dwH = -0.213870168665628, 1899 - kex = 487.361914835074117, 1900 - chi2 = 14.870371897291138. 1901 """ 1902 1903 # Base data setup. 1904 self.setup_korzhnev_2005_data(data_list=['1H MQ']) 1905 1906 # Alias the spin. 1907 spin = return_spin(":9@N") 1908 1909 # The R20 keys. 1910 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=500e6) 1911 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=600e6) 1912 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=800e6) 1913 1914 # Set the initial parameter values. 1915 spin.r2 = {r20_key1: 0.000022585022901, r20_key2: 0.039223196112941, r20_key3: 2.136576686700357} 1916 spin.pA = 0.936884348941701 1917 spin.dw = 4.326454531583964 1918 spin.dwH = -0.214026093221782 1919 spin.kex = 487.043592705469223 1920 1921 # Low precision optimisation. 1922 self.interpreter.minimise(min_algor='simplex', func_tol=1e-05, max_iter=100) 1923 1924 # Monte Carlo simulations. 1925 self.interpreter.monte_carlo.setup(number=2) 1926 self.interpreter.monte_carlo.create_data(method='back_calc') 1927 self.interpreter.monte_carlo.initial_values() 1928 self.interpreter.minimise(min_algor='simplex', max_iter=10) 1929 self.interpreter.monte_carlo.error_analysis() 1930 1931 # Plot the dispersion curves. 1932 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True) 1933 1934 # Save the results. 1935 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True) 1936 1937 # Printout. 1938 print("\n\nOptimised parameters:\n") 1939 print("%-20s %-20s" % ("Parameter", "Value (:9)")) 1940 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1])) 1941 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2])) 1942 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3])) 1943 print("%-20s %20.15g" % ("pA", spin.pA)) 1944 print("%-20s %20.15g" % ("dw", spin.dw)) 1945 print("%-20s %20.15g" % ("dwH", spin.dwH)) 1946 print("%-20s %20.15g" % ("kex", spin.kex)) 1947 print("%-20s %20.15g\n" % ("chi2", spin.chi2)) 1948 1949 # Checks for residue :9. 1950 self.assertAlmostEqual(spin.r2[r20_key1], 0.000023714274046, 4) 1951 self.assertAlmostEqual(spin.r2[r20_key2], 0.039223196112941, 2) 1952 self.assertAlmostEqual(spin.r2[r20_key3], 2.13657668670036, 2) 1953 self.assertAlmostEqual(spin.pA, 0.936884348941701, 4) 1954 self.assertAlmostEqual(spin.dw, 4.32645453158396, 2) 1955 self.assertAlmostEqual(spin.dwH, -0.214026093221782, 2) 1956 self.assertAlmostEqual(spin.kex/1000, 487.043592705469/1000, 4) 1957 self.assertAlmostEqual(spin.chi2, 14.8642315375301, 2)
1958 1959
1961 """Optimisation of the Korzhnev et al., 2005 1H SQ CPMG data using the 'NS MMQ 2-site' model. 1962 1963 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant. 1964 1965 Here only the 1H SQ data will be optimised. The values found by cpmg_fit using just this data are: 1966 1967 - r2 = {'500': 6.691697587650816, '600': 6.998915158708793, '800': 5.519267837559072}, 1968 - pA = 0.946949480545876, 1969 - dwH = -0.265279672133308, 1970 - kex = 406.548178869750700, 1971 - chi2 = 50.400680290545026. 1972 """ 1973 1974 # Base data setup. 1975 self.setup_korzhnev_2005_data(data_list=['1H SQ']) 1976 1977 # Alias the spin. 1978 spin = return_spin(":9@N") 1979 1980 # The R20 keys. 1981 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=500e6) 1982 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6) 1983 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6) 1984 1985 # Set the initial parameter values. 1986 spin.r2 = {r20_key1: 6.69107911078939, r20_key2: 6.99888898689085, r20_key3: 5.52012880268077} 1987 spin.pA = 0.946990967372467 1988 spin.dwH = -0.265308128403529 1989 spin.kex = 406.843250675648 1990 1991 # Low precision optimisation. 1992 self.interpreter.minimise(min_algor='simplex', func_tol=1e-05, max_iter=1000) 1993 1994 # Monte Carlo simulations. 1995 self.interpreter.monte_carlo.setup(number=2) 1996 self.interpreter.monte_carlo.create_data(method='back_calc') 1997 self.interpreter.monte_carlo.initial_values() 1998 self.interpreter.minimise(min_algor='simplex', max_iter=10) 1999 self.interpreter.monte_carlo.error_analysis() 2000 2001 # Plot the dispersion curves. 2002 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True) 2003 2004 # Save the results. 2005 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True) 2006 2007 # Printout. 2008 print("\n\nOptimised parameters:\n") 2009 print("%-20s %-20s" % ("Parameter", "Value (:9)")) 2010 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1])) 2011 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2])) 2012 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3])) 2013 print("%-20s %20.15g" % ("pA", spin.pA)) 2014 print("%-20s %20.15g" % ("dwH", spin.dwH)) 2015 print("%-20s %20.15g" % ("kex", spin.kex)) 2016 print("%-20s %20.15g\n" % ("chi2", spin.chi2)) 2017 2018 # Checks for residue :9. 2019 self.assertAlmostEqual(spin.r2[r20_key1], 6.69107911078939, 2) 2020 self.assertAlmostEqual(spin.r2[r20_key2], 6.99888898689085, 2) 2021 self.assertAlmostEqual(spin.r2[r20_key3], 5.52012880268077, 2) 2022 self.assertAlmostEqual(spin.pA, 0.946990967372467, 4) 2023 self.assertAlmostEqual(spin.dwH, -0.265308128403529, 4) 2024 self.assertAlmostEqual(spin.kex/1000, 406.843250675648/1000, 2) 2025 self.assertAlmostEqual(spin.chi2, 50.3431330819767, 1)
2026 2027
2029 """Optimisation of all the Korzhnev et al., 2005 CPMG data using the 'NS MMQ 2-site' model. 2030 2031 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant. 2032 2033 Here all data will be optimised. The values found by cpmg_fit using just this data are: 2034 2035 - r2 = {'H-S 500': 6.671649051677150, 'H-S 600': 6.988634195648529, 'H-S 800': 5.527971316790596, 2036 'N-S 500': 8.394988400015988, 'N-S 600': 8.891359568401835, 'N-S 800': 10.405356669006709, 2037 'NHZ 500': 5.936446687394352, 'NHZ 600': 6.717058062814535, 'NHZ 800': 6.838733853403030, 2038 'NHD 500': 8.593136215779710, 'NHD 600': 10.651511259239674, 'NHD 800': 12.567902357560627, 2039 'HNM 500': 7.851325614877817, 'HNM 600': 8.408803624020202, 'HNM 800': 11.227489645758979, 2040 'NHM 500': 9.189159145380575, 'NHM 600': 9.856814478405868, 'NHM 800': 11.967910041807118}, 2041 - pA = 0.943125351763911, 2042 - dw = 4.421827493809807, 2043 - dwH = -0.272637034755752, 2044 - kex = 360.609744568697238, 2045 - chi2 = 162.589570340050813. 2046 """ 2047 2048 # Base data setup. 2049 self.setup_korzhnev_2005_data(data_list=['SQ', '1H SQ', 'DQ', 'ZQ', 'MQ', '1H MQ']) 2050 2051 # Alias the spin. 2052 spin = return_spin(":9@N") 2053 2054 # The R20 keys. 2055 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=500e6) 2056 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6) 2057 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6) 2058 r20_key4 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) 2059 r20_key5 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6) 2060 r20_key6 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) 2061 r20_key7 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=500e6) 2062 r20_key8 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=600e6) 2063 r20_key9 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=800e6) 2064 r20_key10 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=500e6) 2065 r20_key11 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=600e6) 2066 r20_key12 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=800e6) 2067 r20_key13 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=500e6) 2068 r20_key14 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=600e6) 2069 r20_key15 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=800e6) 2070 r20_key16 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=500e6) 2071 r20_key17 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=600e6) 2072 r20_key18 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6) 2073 2074 # Set the initial parameter values. 2075 spin.r2 = { 2076 r20_key1: 6.67288025927458, r20_key2: 6.98951408255098, r20_key3: 5.52959273852704, 2077 r20_key4: 8.39471048876782, r20_key5: 8.89290699178799, r20_key6: 10.40770687236930, 2078 r20_key7: 5.93611174376373, r20_key8: 6.71735669582514, r20_key9: 6.83835225518265, 2079 r20_key10: 8.59615074668922, r20_key11: 10.65121378892910, r20_key12: 12.57108229191090, 2080 r20_key13: 7.85956711501608, r20_key14: 8.41891642907918, r20_key15: 11.23620892230380, 2081 r20_key16: 9.19654863789350, r20_key17: 9.86031627358462, r20_key18: 11.97523755925750 2082 } 2083 spin.pA = 0.943129019477673 2084 spin.dw = 4.42209952545181 2085 spin.dwH = -0.27258970590969 2086 spin.kex = 360.516132791038 2087 2088 # Low precision optimisation. 2089 self.interpreter.minimise(min_algor='simplex', func_tol=1e-05, max_iter=10) 2090 2091 # Monte Carlo simulations. 2092 self.interpreter.monte_carlo.setup(number=2) 2093 self.interpreter.monte_carlo.create_data(method='back_calc') 2094 self.interpreter.monte_carlo.initial_values() 2095 self.interpreter.minimise(min_algor='simplex', max_iter=10) 2096 self.interpreter.monte_carlo.error_analysis() 2097 2098 # Plot the dispersion curves. 2099 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True) 2100 2101 # Save the results. 2102 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True) 2103 2104 # Printout. 2105 print("\n\nOptimised parameters:\n") 2106 print("%-20s %-20s" % ("Parameter", "Value (:9)")) 2107 print("%-20s %20.15g" % ("R2 (1H SQ - 500 MHz)", spin.r2[r20_key1])) 2108 print("%-20s %20.15g" % ("R2 (1H SQ - 600 MHz)", spin.r2[r20_key2])) 2109 print("%-20s %20.15g" % ("R2 (1H SQ - 800 MHz)", spin.r2[r20_key3])) 2110 print("%-20s %20.15g" % ("R2 (SQ - 500 MHz)", spin.r2[r20_key4])) 2111 print("%-20s %20.15g" % ("R2 (SQ - 600 MHz)", spin.r2[r20_key5])) 2112 print("%-20s %20.15g" % ("R2 (SQ - 800 MHz)", spin.r2[r20_key6])) 2113 print("%-20s %20.15g" % ("R2 (ZQ - 500 MHz)", spin.r2[r20_key7])) 2114 print("%-20s %20.15g" % ("R2 (ZQ - 600 MHz)", spin.r2[r20_key8])) 2115 print("%-20s %20.15g" % ("R2 (ZQ - 800 MHz)", spin.r2[r20_key9])) 2116 print("%-20s %20.15g" % ("R2 (DQ - 500 MHz)", spin.r2[r20_key10])) 2117 print("%-20s %20.15g" % ("R2 (DQ - 600 MHz)", spin.r2[r20_key11])) 2118 print("%-20s %20.15g" % ("R2 (DQ - 800 MHz)", spin.r2[r20_key12])) 2119 print("%-20s %20.15g" % ("R2 (1H MQ - 500 MHz)", spin.r2[r20_key13])) 2120 print("%-20s %20.15g" % ("R2 (1H MQ - 600 MHz)", spin.r2[r20_key14])) 2121 print("%-20s %20.15g" % ("R2 (1H MQ - 800 MHz)", spin.r2[r20_key15])) 2122 print("%-20s %20.15g" % ("R2 (MQ - 500 MHz)", spin.r2[r20_key16])) 2123 print("%-20s %20.15g" % ("R2 (MQ - 600 MHz)", spin.r2[r20_key17])) 2124 print("%-20s %20.15g" % ("R2 (MQ - 800 MHz)", spin.r2[r20_key18])) 2125 print("%-20s %20.15g" % ("pA", spin.pA)) 2126 print("%-20s %20.15g" % ("dw", spin.dw)) 2127 print("%-20s %20.15g" % ("dwH", spin.dwH)) 2128 print("%-20s %20.15g" % ("kex", spin.kex)) 2129 print("%-20s %20.15g\n" % ("chi2", spin.chi2)) 2130 2131 # Checks for residue :9. 2132 self.assertAlmostEqual(spin.r2[r20_key1], 6.67288025927458, 4) 2133 self.assertAlmostEqual(spin.r2[r20_key2], 6.98951408255098, 4) 2134 self.assertAlmostEqual(spin.r2[r20_key3], 5.52959273852704, 4) 2135 self.assertAlmostEqual(spin.r2[r20_key4], 8.39471048876782, 4) 2136 self.assertAlmostEqual(spin.r2[r20_key5], 8.89290699178799, 4) 2137 self.assertAlmostEqual(spin.r2[r20_key6], 10.4077068723693, 4) 2138 self.assertAlmostEqual(spin.r2[r20_key7], 5.93611174376373, 4) 2139 self.assertAlmostEqual(spin.r2[r20_key8], 6.71735669582514, 4) 2140 self.assertAlmostEqual(spin.r2[r20_key9], 6.83835225518265, 4) 2141 self.assertAlmostEqual(spin.r2[r20_key10], 8.59615074668922, 4) 2142 self.assertAlmostEqual(spin.r2[r20_key11], 10.6512137889291, 4) 2143 self.assertAlmostEqual(spin.r2[r20_key12], 12.5710822919109, 4) 2144 self.assertAlmostEqual(spin.r2[r20_key13], 7.85956711501608, 4) 2145 self.assertAlmostEqual(spin.r2[r20_key14], 8.41891642907918, 4) 2146 self.assertAlmostEqual(spin.r2[r20_key15], 11.2362089223038, 4) 2147 self.assertAlmostEqual(spin.r2[r20_key16], 9.1965486378935, 4) 2148 self.assertAlmostEqual(spin.r2[r20_key17], 9.86031627358462, 4) 2149 self.assertAlmostEqual(spin.r2[r20_key18], 11.9752375592575, 4) 2150 self.assertAlmostEqual(spin.pA, 0.943129019477673, 4) 2151 self.assertAlmostEqual(spin.dw, 4.42209952545181, 4) 2152 self.assertAlmostEqual(spin.dwH, -0.27258970590969, 4) 2153 self.assertAlmostEqual(spin.kex/1000, 360.516132791038/1000, 4) 2154 self.assertAlmostEqual(spin.chi2/1000, 162.511988511609/1000, 3)
2155 2156
2158 """Optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model. 2159 2160 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 0.48 M GuHCl (guanidine hydrochloride). 2161 """ 2162 2163 # Base data setup. 2164 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model='CR72', expfolder="acbp_cpmg_disp_048MGuHCl_40C_041223") 2165 2166 # Alias the spins. 2167 res61L = cdp.mol[0].res[0].spin[0] 2168 2169 # The R20 keys. 2170 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086220e6) 2171 2172 # Set the initial parameter values. 2173 res61L.r2 = {r20_key1: 8.0} 2174 res61L.pA = 0.9 2175 res61L.dw = 6.0 2176 res61L.kex = 600.0 2177 2178 # Low precision optimisation. 2179 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1) 2180 2181 # Printout. 2182 print("\n\nOptimised parameters:\n") 2183 print("%-20s %-20s" % ("Parameter", "Value (:61)")) 2184 print("%-20s %20.15g" % ("R2 (600 MHz)", res61L.r2[r20_key1])) 2185 print("%-20s %20.15g" % ("pA", res61L.pA)) 2186 print("%-20s %20.15g" % ("dw", res61L.dw)) 2187 print("%-20s %20.15g" % ("kex", res61L.kex)) 2188 print("%-20s %20.15g\n" % ("chi2", res61L.chi2)) 2189 2190 # Checks for residue :61. Calculated for 500 Monte Carlo simulations. 2191 self.assertAlmostEqual(res61L.r2[r20_key1], 8.69277980194016, 4) 2192 self.assertAlmostEqual(res61L.pA, 0.9943781590842946, 5) 2193 self.assertAlmostEqual(res61L.dw, 6.389453131263374, 3) 2194 self.assertAlmostEqual(res61L.kex, 609.262167216419, 0) 2195 self.assertAlmostEqual(res61L.chi2, 65.99987828889657, 5) 2196 2197 # Test the conversion to k_AB from kex and pA. 2198 self.assertEqual(res61L.k_AB, res61L.kex * (1.0 - res61L.pA)) 2199 2200 # Test the conversion to k_BA from kex and pA. 2201 self.assertEqual(res61L.k_BA, res61L.kex * res61L.pA)
2202 2203
2205 """Optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model. 2206 2207 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 0.48 M GuHCl (guanidine hydrochloride). 2208 """ 2209 2210 # Base data setup. 2211 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model='CR72 full', expfolder="acbp_cpmg_disp_048MGuHCl_40C_041223") 2212 2213 # Alias the spins. 2214 res61L = cdp.mol[0].res[0].spin[0] 2215 2216 # The R20 keys. 2217 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086220e6) 2218 2219 # Set the initial parameter values. 2220 res61L.r2a = {r20_key1: 8.0} 2221 res61L.r2b = {r20_key1: 105.0} 2222 res61L.pA = 0.9 2223 res61L.dw = 6.0 2224 res61L.kex = 500.0 2225 2226 # Low precision optimisation. 2227 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1) 2228 2229 # Printout. 2230 print("\n\nOptimised parameters:\n") 2231 print("%-20s %-20s" % ("Parameter", "Value (:61)")) 2232 print("%-20s %20.15g" % ("R2A (600 MHz)", res61L.r2a[r20_key1])) 2233 print("%-20s %20.15g" % ("R2B (600 MHz)", res61L.r2b[r20_key1])) 2234 print("%-20s %20.15g" % ("pA", res61L.pA)) 2235 print("%-20s %20.15g" % ("dw", res61L.dw)) 2236 print("%-20s %20.15g" % ("kex", res61L.kex)) 2237 print("%-20s %20.15g\n" % ("chi2", res61L.chi2)) 2238 2239 # Checks for residue :61. Calculated for 500 Monte Carlo simulations. 2240 self.assertAlmostEqual(res61L.r2a[r20_key1], 8.044428899438309, 0) 2241 self.assertAlmostEqual(res61L.r2b[r20_key1], 105.11894506392449, -2) 2242 self.assertAlmostEqual(res61L.pA, 0.992066883657578, 2) 2243 self.assertAlmostEqual(res61L.dw, 6.389453586338883, 3) 2244 self.assertAlmostEqual(res61L.kex, 513.483608742063, -2) 2245 self.assertAlmostEqual(res61L.chi2, 65.99987828890289, 5)
2246 2247
2249 """Optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model. 2250 2251 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 0.48 M GuHCl (guanidine hydrochloride). 2252 2253 Figure 3 shows the ln( k_a [s^-1]) for different concentrations of GuHCl. The precise values are: 2254 2255 - [GuHCL][M] ln(k_a[s^-1]) k_a[s^-1] 2256 - 0.483 0.89623903 2.4503699912708878 2257 - 0.545 1.1694838 2258 - 0.545 1.1761503 2259 - 0.622 1.294 2260 - 0.669 1.5176493 2261 - 0.722 1.6238791 2262 - 0.813 1.9395758 2263 - 1.011 2.3558415 10.547000429321157 2264 """ 2265 2266 # Base data setup. 2267 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model='TSMFK01', expfolder="acbp_cpmg_disp_048MGuHCl_40C_041223") 2268 2269 # Alias the spins. 2270 res61L = cdp.mol[0].res[0].spin[0] 2271 2272 # The R20 keys. 2273 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086220e6) 2274 2275 # Set the initial parameter values. 2276 res61L.r2a = {r20_key1: 8.0} 2277 res61L.dw = 6.5 2278 res61L.k_AB = 2.5 2279 2280 # Low precision optimisation. 2281 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1) 2282 2283 # Printout. 2284 print("\n\nOptimised parameters:\n") 2285 print("%-20s %-20s" % ("Parameter", "Value (:61)")) 2286 print("%-20s %20.15g" % ("R2A (600 MHz)", res61L.r2a[r20_key1])) 2287 print("%-20s %20.15g" % ("dw", res61L.dw)) 2288 print("%-20s %20.15g" % ("k_AB", res61L.k_AB)) 2289 print("%-20s %20.15g\n" % ("chi2", res61L.chi2)) 2290 2291 # Checks for residue :61. Reference values from paper 2292 2293 self.assertAlmostEqual(res61L.k_AB, 2.45, 1)
2294 2295
2297 """Optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model. 2298 2299 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 1.01 M GuHCl (guanidine hydrochloride). 2300 2301 The comparison is to Figure 2, which is for dataset with 1 M GuHCl. The reported results are expected to be in rad.s^-1. Conversion into relax stored values is preferably. 2302 2303 Representative 15N CPMG relaxation dispersion curve measured on the cross peaks from residue L61 in folded ACBP at pH 5.3, 1 M GuHCl, and 40C: 2304 2305 1. The dotted line represents a residue-specific fit of all parameters in Eq. 1: 2306 - k_AB = 11.3 +/- 0.7 s^-1, 2307 - dw = (2.45 +/- 0.09) * 10^3 s^-1, 2308 - R2 = 8.0 +/- 0.5 s^-1. 2309 2310 2. The solid line represents a global fit of k_AB to all protein residues and a residue-specific fit of dw and R2.: 2311 - k_AB = 10.55 +/- 0.08 s^-1, 2312 - dw = (2.44 +/- 0.08) * 10^3 s^-1, 2313 - R2 = 8.4 +/- 0.3 s^-1. 2314 2315 Conversion of paper results to relax results is performed by: 2316 2317 - dw(ppm) = dw(rad.s^-1) * 10^6 * 1/(2*pi) * (gyro1H/(gyro15N*spectrometer_freq)) = 2.45E3 * 1E6 / (2 * math.pi) * (26.7522212E7/(-2.7126E7 * 599.8908622E6)) = -6.41 ppm. 2318 2319 Figure 3 shows the ln( k_a [s^-1]) for different concentrations of GuHCl. The precise values are: 2320 2321 - [GuHCL][M] ln(k_a[s^-1]) k_a[s^-1] 2322 - 0.483 0.89623903 2.4503699912708878 2323 - 0.545 1.1694838 2324 - 0.545 1.1761503 2325 - 0.622 1.294 2326 - 0.669 1.5176493 2327 - 0.722 1.6238791 2328 - 0.813 1.9395758 2329 - 1.011 2.3558415 10.547000429321157 2330 """ 2331 2332 # Base data setup. 2333 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model='TSMFK01', expfolder="acbp_cpmg_disp_101MGuHCl_40C_041223") 2334 2335 # Alias the spins. 2336 res61L = cdp.mol[0].res[0].spin[0] 2337 2338 # The R20 keys. 2339 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086270e6) 2340 2341 # Set the initial parameter values. 2342 res61L.r2a = {r20_key1: 8.0} 2343 res61L.dw = 6.5 2344 res61L.k_AB = 11.0 2345 2346 # Low precision optimisation. 2347 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1) 2348 2349 # Printout. 2350 print("\n\nOptimised parameters:\n") 2351 print("%-20s %-20s" % ("Parameter", "Value (:61)")) 2352 print("%-20s %20.15g" % ("R2A (600 MHz)", res61L.r2a[r20_key1])) 2353 print("%-20s %20.15g" % ("dw", res61L.dw)) 2354 print("%-20s %20.15g" % ("k_AB", res61L.k_AB)) 2355 print("%-20s %20.15g\n" % ("chi2", res61L.chi2)) 2356 2357 # Checks for residue :61. Reference values from paper 2358 2359 self.assertAlmostEqual(res61L.r2a[r20_key1], 8.4, 0) 2360 self.assertAlmostEqual(res61L.dw, 6.41, 0) 2361 self.assertAlmostEqual(res61L.k_AB, 10.55, 0)
2362 2363
2364 - def test_m61_data_to_m61(self):
2365 """Test the relaxation dispersion 'M61' model curve fitting to fixed time synthetic data.""" 2366 2367 # Fixed time variable. 2368 ds.fixed = True 2369 2370 # Execute the script. 2371 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_on_res_m61.py') 2372 2373 # The original parameters. 2374 i0 = [100000.0, 20000.0] 2375 r1rho_prime = [2.25, 24.0] 2376 pA = 0.7 2377 kex = 1000.0 2378 delta_omega = [1.0, 2.0] 2379 keys = ['r1rho_800.00000000_0.000_1000.000', 'r1rho_800.00000000_0.000_1500.000', 'r1rho_800.00000000_0.000_2000.000', 'r1rho_800.00000000_0.000_2500.000', 'r1rho_800.00000000_0.000_3000.000', 'r1rho_800.00000000_0.000_3500.000', 'r1rho_800.00000000_0.000_4000.000', 'r1rho_800.00000000_0.000_4500.000', 'r1rho_800.00000000_0.000_5000.000', 'r1rho_800.00000000_0.000_5500.000', 'r1rho_800.00000000_0.000_6000.000'] 2380 phi_ex = [] 2381 for i in range(2): 2382 phi_ex.append(pA * (1.0 - pA) * delta_omega[i]**2) 2383 rates = [[3.59768160399, 2.85730469783, 2.59328084312, 2.47019857325, 2.40310451058, 2.36256876552, 2.33622716364, 2.31815271355, 2.30521680479, 2.29564174079, 2.28835686631], [29.390726416, 26.4292187913, 25.3731233725, 24.880794293, 24.6124180423, 24.4502750621, 24.3449086546, 24.2726108542, 24.2208672192, 24.1825669632, 24.1534274652]] 2384 2385 # Switch to the 'R2eff' model data pipe, then check for each spin. 2386 self.interpreter.pipe.switch('R2eff - relax_disp') 2387 spin_index = 0 2388 for spin, spin_id in spin_loop(return_id=True): 2389 # Printout. 2390 print("\nSpin %s." % spin_id) 2391 2392 # Check the fitted parameters. 2393 for i in range(len(keys)): 2394 self.assertAlmostEqual(spin.r2eff[keys[i]]/10.0, rates[spin_index][i]/10.0, 2) 2395 2396 # Increment the spin index. 2397 spin_index += 1 2398 2399 # The R20 keys. 2400 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6) 2401 2402 # Switch to the 'M61' model data pipe, then check for each spin. 2403 self.interpreter.pipe.switch('M61 - relax_disp') 2404 spin_index = 0 2405 for spin, spin_id in spin_loop(return_id=True): 2406 # Printout. 2407 print("\nSpin %s." % spin_id) 2408 2409 # Check the fitted parameters. 2410 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index]/10, 2) 2411 self.assertAlmostEqual(spin.phi_ex, phi_ex[spin_index], 2) 2412 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 2) 2413 2414 # Increment the spin index. 2415 spin_index += 1
2416 2417
2418 - def test_m61_exp_data_to_m61(self):
2419 """Test the relaxation dispersion 'M61' model curve fitting to the full exponential synthetic data.""" 2420 2421 # Fixed time variable. 2422 ds.fixed = False 2423 2424 # Execute the script. 2425 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_on_res_m61.py') 2426 2427 # The original parameters. 2428 i0 = [100000.0, 20000.0] 2429 r1rho_prime = [2.25, 24.0] 2430 pA = 0.7 2431 kex = 1000.0 2432 delta_omega = [1.0, 2.0] 2433 keys = ['r1rho_800.00000000_0.000_1000.000', 'r1rho_800.00000000_0.000_1500.000', 'r1rho_800.00000000_0.000_2000.000', 'r1rho_800.00000000_0.000_2500.000', 'r1rho_800.00000000_0.000_3000.000', 'r1rho_800.00000000_0.000_3500.000', 'r1rho_800.00000000_0.000_4000.000', 'r1rho_800.00000000_0.000_4500.000', 'r1rho_800.00000000_0.000_5000.000', 'r1rho_800.00000000_0.000_5500.000', 'r1rho_800.00000000_0.000_6000.000'] 2434 phi_ex = [] 2435 for i in range(2): 2436 phi_ex.append(pA * (1.0 - pA) * delta_omega[i]**2) 2437 rates = [[3.59768160399, 2.85730469783, 2.59328084312, 2.47019857325, 2.40310451058, 2.36256876552, 2.33622716364, 2.31815271355, 2.30521680479, 2.29564174079, 2.28835686631], [29.390726416, 26.4292187913, 25.3731233725, 24.880794293, 24.6124180423, 24.4502750621, 24.3449086546, 24.2726108542, 24.2208672192, 24.1825669632, 24.1534274652]] 2438 2439 # Switch to the 'R2eff' model data pipe, then check for each spin. 2440 self.interpreter.pipe.switch('R2eff - relax_disp') 2441 spin_index = 0 2442 for spin, spin_id in spin_loop(return_id=True): 2443 # Printout. 2444 print("\nSpin %s." % spin_id) 2445 2446 # Check the fitted parameters. 2447 for i in range(len(keys)): 2448 self.assertAlmostEqual(spin.r2eff[keys[i]]/10.0, rates[spin_index][i]/10.0, 2) 2449 2450 # Increment the spin index. 2451 spin_index += 1 2452 2453 # The R20 keys. 2454 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6) 2455 2456 # Switch to the 'M61' model data pipe, then check for each spin. 2457 self.interpreter.pipe.switch('M61 - relax_disp') 2458 spin_index = 0 2459 for spin, spin_id in spin_loop(return_id=True): 2460 # Printout. 2461 print("\nSpin %s." % spin_id) 2462 2463 # Check the fitted parameters. 2464 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index]/10, 2) 2465 self.assertAlmostEqual(spin.phi_ex, phi_ex[spin_index], 2) 2466 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 2) 2467 2468 # Increment the spin index. 2469 spin_index += 1
2470 2471
2472 - def xxx_test_m61b_data_to_m61b(self):
2473 """Test the relaxation dispersion 'M61 skew' model curve fitting to fixed time synthetic data.""" 2474 2475 # Execute the script. 2476 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_on_res_m61b.py') 2477 2478 # The original parameters. 2479 i0 = [100000.0, 20000.0] 2480 r1rho_prime = [10.0, 24.0] 2481 pA = 0.95 2482 kex = 2000.0 2483 delta_omega = [1.0, 2.0] 2484 2485 # The R20 keys. 2486 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6) 2487 2488 # Switch to the 'M61 skew' model data pipe, then check for each spin. 2489 self.interpreter.pipe.switch("%s - relax_disp" % MODEL_M61B) 2490 spin_index = 0 2491 for spin, spin_id in spin_loop(return_id=True): 2492 # Printout. 2493 print("\nSpin %s." % spin_id) 2494 2495 # Check the fitted parameters. 2496 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index]/10, 2) 2497 self.assertAlmostEqual(spin.pA, pA, 2) 2498 self.assertAlmostEqual(spin.dw, dw[spin_index], 2) 2499 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 2) 2500 2501 # Increment the spin index. 2502 spin_index += 1
2503 2504
2505 - def test_ns_mmq_3site(self):
2506 """Compare the 'NS MMQ 3-site' dispersion model to synthetic data from cpmg_fit.""" 2507 2508 # Execute the script. 2509 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'ns_mmq_3site.py') 2510 2511 # Check the chi-squared value. 2512 self.assertAlmostEqual(cdp.mol[0].res[0].spin[1].chi2, 0.0, 3)
2513 2514
2515 - def test_ns_mmq_3site_linear(self):
2516 """Compare the 'NS MMQ 3-site linear' dispersion model to synthetic data from cpmg_fit.""" 2517 2518 # Execute the script. 2519 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'ns_mmq_3site_linear.py') 2520 2521 # Check the chi-squared value. 2522 self.assertAlmostEqual(cdp.mol[0].res[0].spin[1].chi2, 0.0, 3)
2523 2524
2525 - def test_ns_r1rho_3site(self):
2526 """Compare the 'NS R1rho 3-site' dispersion model to synthetic data from cpmg_fit.""" 2527 2528 # Execute the script. 2529 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'ns_r1rho_3site.py') 2530 2531 # Check the chi-squared value. 2532 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].chi2, 136.13141468674999, 3)
2533 2534
2535 - def test_ns_r1rho_3site_linear(self):
2536 """Compare the 'NS R1rho 3-site linear' dispersion model to synthetic data from cpmg_fit.""" 2537 2538 # Execute the script. 2539 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'ns_r1rho_3site_linear.py') 2540 2541 # Check the chi-squared value. 2542 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].chi2, 0.030959849811015544, 3)
2543 2544
2545 - def test_r1rho_kjaergaard(self):
2546 """Optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'DPL' model. 2547 2548 This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}. 2549 2550 """ 2551 2552 # The path to the data files. 2553 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013' 2554 2555 # Set pipe name, bundle and type. 2556 pipe_name = 'base pipe' 2557 pipe_bundle = 'relax_disp' 2558 pipe_type= 'relax_disp' 2559 2560 # Create the data pipe. 2561 self.interpreter.pipe.create(pipe_name=pipe_name, bundle=pipe_bundle, pipe_type=pipe_type) 2562 2563 # Read the spins. 2564 self.interpreter.spectrum.read_spins(file='1_0_46_0_max_standard.ser', dir=data_path+sep+'peak_lists') 2565 2566 # Test some of the sequence. 2567 self.assertEqual(len(cdp.mol), 1) 2568 self.assertEqual(cdp.mol[0].name, None) 2569 self.assertEqual(len(cdp.mol[0].res), 48) 2570 2571 # Name the isotope for field strength scaling. 2572 self.interpreter.spin.isotope(isotope='15N') 2573 2574 # Set number of experiments to be used. 2575 NR_exp = 70 2576 2577 # Load the experiments settings file. 2578 expfile = open(data_path+sep+'exp_parameters_sort.txt','r') 2579 expfileslines = expfile.readlines()[:NR_exp] 2580 expfile.close() 2581 2582 # In MHz 2583 yOBS = 81.050 2584 # In ppm 2585 yCAR = 118.078 2586 centerPPM_N15 = yCAR 2587 2588 ## Read the chemical shift data. 2589 self.interpreter.chemical_shift.read(file='1_0_46_0_max_standard.ser', dir=data_path+sep+'peak_lists') 2590 2591 # Test the chemical shift data. 2592 cs = [122.223, 122.162, 114.250, 125.852, 118.626, 117.449, 119.999, 122.610, 118.602, 118.291, 115.393, 2593 121.288, 117.448, 116.378, 116.316, 117.263, 122.211, 118.748, 118.103, 119.421, 119.317, 119.386, 117.279, 2594 122.103, 120.038, 116.698, 111.811, 118.639, 118.285, 121.318, 117.770, 119.948, 119.759, 118.314, 118.160, 2595 121.442, 118.714, 113.080, 125.706, 119.183, 120.966, 122.361, 126.675, 117.069, 120.875, 109.372, 119.811, 126.048] 2596 2597 i = 0 2598 for spin, spin_id in spin_loop(return_id=True): 2599 # Check the chemical shift. 2600 self.assertEqual(spin.chemical_shift, cs[i]) 2601 2602 # Increment the index. 2603 i += 1 2604 2605 # The lock power to field, has been found in an calibration experiment. 2606 spin_lock_field_strengths_Hz = {'35': 431.0, '39': 651.2, '41': 800.5, '43': 984.0, '46': 1341.11, '48': 1648.5} 2607 2608 # Apply spectra settings. 2609 # Count settings 2610 j = 0 2611 for i in range(len(expfileslines)): 2612 line=expfileslines[i] 2613 if line[0] == "#": 2614 continue 2615 else: 2616 # DIRN I deltadof2 dpwr2slock ncyc trim ss sfrq 2617 DIRN = line.split()[0] 2618 I = int(line.split()[1]) 2619 deltadof2 = line.split()[2] 2620 dpwr2slock = line.split()[3] 2621 ncyc = int(line.split()[4]) 2622 trim = float(line.split()[5]) 2623 ss = int(line.split()[6]) 2624 set_sfrq = float(line.split()[7]) 2625 apod_rmsd = float(line.split()[8]) 2626 spin_lock_field_strength = spin_lock_field_strengths_Hz[dpwr2slock] 2627 2628 # Calculate spin_lock time 2629 time_sl = 2*ncyc*trim 2630 2631 # Define file name for peak list. 2632 FNAME = "%s_%s_%s_%s_max_standard.ser"%(I, deltadof2, dpwr2slock, ncyc) 2633 sp_id = "%s_%s_%s_%s"%(I, deltadof2, dpwr2slock, ncyc) 2634 2635 # Load the peak intensities. 2636 self.interpreter.spectrum.read_intensities(file=FNAME, dir=data_path+sep+'peak_lists', spectrum_id=sp_id, int_method='height') 2637 2638 # Set the peak intensity errors, as defined as the baseplane RMSD. 2639 self.interpreter.spectrum.baseplane_rmsd(error=apod_rmsd, spectrum_id=sp_id) 2640 2641 # Set the relaxation dispersion experiment type. 2642 self.interpreter.relax_disp.exp_type(spectrum_id=sp_id, exp_type='R1rho') 2643 2644 # Set The spin-lock field strength, nu1, in Hz 2645 self.interpreter.relax_disp.spin_lock_field(spectrum_id=sp_id, field=spin_lock_field_strength) 2646 2647 # Calculating the spin-lock offset in ppm, from offsets values provided in Hz. 2648 frq_N15_Hz = yOBS * 1E6 2649 offset_ppm_N15 = float(deltadof2) / frq_N15_Hz * 1E6 2650 omega_rf_ppm = centerPPM_N15 + offset_ppm_N15 2651 2652 # Set The spin-lock offset, omega_rf, in ppm. 2653 self.interpreter.relax_disp.spin_lock_offset(spectrum_id=sp_id, offset=omega_rf_ppm) 2654 2655 # Set the relaxation times (in s). 2656 self.interpreter.relax_disp.relax_time(spectrum_id=sp_id, time=time_sl) 2657 2658 # Set the spectrometer frequency. 2659 self.interpreter.spectrometer.frequency(id=sp_id, frq=set_sfrq, units='MHz') 2660 2661 # Add to counter 2662 j += 1 2663 2664 # Read the R1 data 2665 self.interpreter.relax_data.read(ri_id='R1', ri_type='R1', frq=cdp.spectrometer_frq_list[0], file='R1_fitted_values.txt', dir=data_path, mol_name_col=1, res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7) 2666 2667 print("Testing the number of settings") 2668 print("Number of settings iterations is: %s. Number of cdp.exp_type.keys() is: %s"%(i, len(cdp.exp_type.keys() ) ) ) 2669 self.assertEqual(70, len(expfileslines)) 2670 self.assertEqual(69, j) 2671 self.assertEqual(69, len(cdp.exp_type.keys()) ) 2672 2673 # Cluster residues 2674 cluster_ids = [ 2675 ":13@N", 2676 ":15@N", 2677 ":16@N", 2678 ":25@N", 2679 ":26@N", 2680 ":28@N", 2681 ":39@N", 2682 ":40@N", 2683 ":41@N", 2684 ":43@N", 2685 ":44@N", 2686 ":45@N", 2687 ":49@N", 2688 ":52@N", 2689 ":53@N"] 2690 2691 # Cluster spins 2692 for curspin in cluster_ids: 2693 print("Adding spin %s to cluster"%curspin) 2694 self.interpreter.relax_disp.cluster('model_cluster', curspin) 2695 2696 # De-select for analysis those spins who have not been clustered 2697 for free_spin in cdp.clustering['free spins']: 2698 print("Deselecting free spin %s"%free_spin) 2699 self.interpreter.deselect.spin(spin_id=free_spin, change_all=False) 2700 2701 # Initialize counter 2702 i = 0 2703 j = 0 2704 # Count instances of select/deselect 2705 for curspin, mol_name, res_num, res_name, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=False): 2706 if curspin.select == True: 2707 i += 1 2708 if curspin.select == False: 2709 j += 1 2710 2711 # Test number of selected/deselected spins. 2712 self.assertEqual(i, len(cluster_ids)) 2713 self.assertEqual(j, 48-len(cluster_ids)) 2714 2715 # Paper reference values 2716 # Resi Resn R1 R1err R2 R2err kEX kEXerr phi phierr 2717 ref = dict() 2718 ref[':13@N'] = [13, 'L13N-HN', 1.32394, 0.14687, 8.16007, 1.01237, 13193.82986, 2307.09152, 58703.06446, 22413.09854] 2719 ref[':15@N'] = [15, 'R15N-HN', 1.34428, 0.14056, 7.83256, 0.67559, 13193.82986, 2307.09152, 28688.33492, 13480.72253] 2720 ref[':16@N'] = [16, 'T16N-HN', 1.71514, 0.13651, 17.44216, 0.98583, 13193.82986, 2307.09152, 57356.77617, 21892.44205] 2721 ref[':25@N'] = [25, 'Q25N-HN', 1.82412, 0.15809, 9.09447, 2.09215, 13193.82986, 2307.09152, 143111.13431, 49535.80302] 2722 ref[':26@N'] = [26, 'Q26N-HN', 1.45746, 0.14127, 10.22801, 0.67116, 13193.82986, 2307.09152, 28187.06876, 13359.01615] 2723 ref[':28@N'] = [28, 'Q28N-HN', 1.48095, 0.14231, 10.33552, 0.691, 13193.82986, 2307.09152, 30088.0686, 13920.25654] 2724 ref[':39@N'] = [39, 'L39N-HN', 1.46094, 0.14514, 8.02194, 0.84649, 13193.82986, 2307.09152, 44130.18538, 18104.55064] 2725 ref[':40@N'] = [40, 'M40N-HN', 1.21381, 0.14035, 12.19112, 0.81418, 13193.82986, 2307.09152, 41834.90493, 17319.92156] 2726 ref[':41@N'] = [41, 'A41N-HN', 1.29296, 0.14286, 9.29941, 0.66246, 13193.82986, 2307.09152, 26694.8921, 13080.66782] 2727 ref[':43@N'] = [43, 'F43N-HN', 1.33626, 0.14352, 12.73816, 1.17386, 13193.82986, 2307.09152, 70347.63797, 26648.30524] 2728 ref[':44@N'] = [44, 'I44N-HN', 1.28487, 0.1462, 12.70158, 1.52079, 13193.82986, 2307.09152, 95616.20461, 35307.79817] 2729 ref[':45@N'] = [45, 'K45N-HN', 1.59227, 0.14591, 9.54457, 0.95596, 13193.82986, 2307.09152, 53849.7826, 21009.89973] 2730 ref[':49@N'] = [49, 'A49N-HN', 1.38521, 0.14148, 4.44842, 0.88647, 13193.82986, 2307.09152, 40686.65286, 18501.20774] 2731 ref[':52@N'] = [52, 'V52N-HN', 1.57531, 0.15042, 6.51945, 1.43418, 13193.82986, 2307.09152, 93499.92172, 33233.23039] 2732 ref[':53@N'] = [53, 'A53N-HN', 1.27214, 0.13823, 4.0705, 0.85485, 13193.82986, 2307.09152, 34856.18636, 17505.02393] 2733 2734 guess = dict() 2735 guess[':13@N'] = [13, 'L13N-HN', 1.0, 0.1, 8.00, 1.0, 10000.0, 2000.0, 50000.00, 20000.0] 2736 guess[':15@N'] = [15, 'R15N-HN', 1.0, 0.1, 8.00, 0.6, 10000.0, 2000.0, 20000.00, 10000.0] 2737 guess[':16@N'] = [16, 'T16N-HN', 1.0, 0.1, 17.0, 0.9, 10000.0, 2000.0, 50000.00, 20000.0] 2738 guess[':25@N'] = [25, 'Q25N-HN', 1.0, 0.1, 9.00, 2.0, 10000.0, 2000.0, 140000.0, 40000.0] 2739 guess[':26@N'] = [26, 'Q26N-HN', 1.0, 0.1, 10.0, 0.6, 10000.0, 2000.0, 20000.00, 10000.0] 2740 guess[':28@N'] = [28, 'Q28N-HN', 1.0, 0.1, 10.0, 0.6, 10000.0, 2000.0, 30000.00, 10000.0] 2741 guess[':39@N'] = [39, 'L39N-HN', 1.0, 0.1, 8.00, 0.8, 10000.0, 2000.0, 40000.00, 10000.0] 2742 guess[':40@N'] = [40, 'M40N-HN', 1.0, 0.1, 12.0, 0.8, 10000.0, 2000.0, 40000.00, 10000.0] 2743 guess[':41@N'] = [41, 'A41N-HN', 1.0, 0.1, 9.00, 0.6, 10000.0, 2000.0, 20000.00, 10000.0] 2744 guess[':43@N'] = [43, 'F43N-HN', 1.0, 0.1, 12.0, 1.1, 10000.0, 2000.0, 70000.00, 20000.0] 2745 guess[':44@N'] = [44, 'I44N-HN', 1.0, 0.1, 12.0, 1.5, 10000.0, 2000.0, 90000.00, 30000.0] 2746 guess[':45@N'] = [45, 'K45N-HN', 1.0, 0.1, 9.00, 0.9, 10000.0, 2000.0, 50000.00, 20000.0] 2747 guess[':49@N'] = [49, 'A49N-HN', 1.0, 0.1, 4.00, 0.8, 10000.0, 2000.0, 40000.00, 10000.0] 2748 guess[':52@N'] = [52, 'V52N-HN', 1.0, 0.1, 6.00, 1.4, 10000.0, 2000.0, 90000.00, 30000.0] 2749 guess[':53@N'] = [53, 'A53N-HN', 1.0, 0.1, 4.00, 0.8, 10000.0, 2000.0, 30000.00, 10000.0] 2750 2751 # Assign guess values. 2752 for spin, spin_id in spin_loop(return_id=True): 2753 if spin_id in cluster_ids: 2754 print("spin_id %s in cluster ids"%(spin_id)) 2755 2756 if spin_id == ':13@N': 2757 spin.kex = guess[spin_id][6] 2758 spin.phi_ex = guess[spin_id][8] 2759 elif spin_id == ':15@N': 2760 spin.kex = guess[spin_id][6] 2761 spin.phi_ex = guess[spin_id][8] 2762 elif spin_id == ':16@N': 2763 spin.kex = guess[spin_id][6] 2764 spin.phi_ex = guess[spin_id][8] 2765 elif spin_id == ':25@N': 2766 spin.kex = guess[spin_id][6] 2767 spin.phi_ex = guess[spin_id][8] 2768 elif spin_id == ':26@N': 2769 spin.kex = guess[spin_id][6] 2770 spin.phi_ex = guess[spin_id][8] 2771 elif spin_id == ':28@N': 2772 spin.kex = guess[spin_id][6] 2773 spin.phi_ex = guess[spin_id][8] 2774 elif spin_id == ':39@N': 2775 spin.kex = guess[spin_id][6] 2776 spin.phi_ex = guess[spin_id][8] 2777 elif spin_id == ':40@N': 2778 spin.kex = guess[spin_id][6] 2779 spin.phi_ex = guess[spin_id][8] 2780 elif spin_id == ':41@N': 2781 spin.kex = guess[spin_id][6] 2782 spin.phi_ex = guess[spin_id][8] 2783 elif spin_id == ':43@N': 2784 spin.kex = guess[spin_id][6] 2785 spin.phi_ex = guess[spin_id][8] 2786 elif spin_id == ':44@N': 2787 spin.kex = guess[spin_id][6] 2788 spin.phi_ex = guess[spin_id][8] 2789 elif spin_id == ':45@N': 2790 spin.kex = guess[spin_id][6] 2791 spin.phi_ex = guess[spin_id][8] 2792 elif spin_id == ':49@N': 2793 spin.kex = guess[spin_id][6] 2794 spin.phi_ex = guess[spin_id][8] 2795 elif spin_id == ':52@N': 2796 spin.kex = guess[spin_id][6] 2797 spin.phi_ex = guess[spin_id][8] 2798 elif spin_id == ':53@N': 2799 spin.kex = guess[spin_id][6] 2800 spin.phi_ex = guess[spin_id][8] 2801 else: 2802 print("spin_id %s NOT in cluster ids"%(spin_id)) 2803 2804 # Check the initial setup. 2805 self.assertEqual(cdp.mol[0].res[7].num, 13) 2806 self.assertEqual(cdp.mol[0].res[7].spin[0].kex, guess[':13@N'][6]) 2807 self.assert_(hasattr(cdp.mol[0].res[7].spin[0], 'ri_data')) 2808 self.assertEqual(cdp.mol[0].res[9].num, 15) 2809 self.assertEqual(cdp.mol[0].res[9].spin[0].kex, guess[':15@N'][6]) 2810 self.assert_(hasattr(cdp.mol[0].res[9].spin[0], 'ri_data')) 2811 self.assertEqual(cdp.mol[0].res[10].num, 16) 2812 self.assertEqual(cdp.mol[0].res[10].spin[0].kex, guess[':16@N'][6]) 2813 self.assert_(hasattr(cdp.mol[0].res[10].spin[0], 'ri_data')) 2814 self.assertEqual(cdp.mol[0].res[16].num, 25) 2815 self.assertEqual(cdp.mol[0].res[16].spin[0].kex, guess[':25@N'][6]) 2816 self.assert_(hasattr(cdp.mol[0].res[16].spin[0], 'ri_data')) 2817 self.assertEqual(cdp.mol[0].res[17].num, 26) 2818 self.assertEqual(cdp.mol[0].res[17].spin[0].kex, guess[':26@N'][6]) 2819 self.assert_(hasattr(cdp.mol[0].res[17].spin[0], 'ri_data')) 2820 self.assertEqual(cdp.mol[0].res[19].num, 28) 2821 self.assertEqual(cdp.mol[0].res[19].spin[0].kex, guess[':28@N'][6]) 2822 self.assert_(hasattr(cdp.mol[0].res[19].spin[0], 'ri_data')) 2823 self.assertEqual(cdp.mol[0].res[29].num, 39) 2824 self.assertEqual(cdp.mol[0].res[29].spin[0].kex, guess[':39@N'][6]) 2825 self.assert_(hasattr(cdp.mol[0].res[29].spin[0], 'ri_data')) 2826 self.assertEqual(cdp.mol[0].res[30].num, 40) 2827 self.assertEqual(cdp.mol[0].res[30].spin[0].kex, guess[':40@N'][6]) 2828 self.assert_(hasattr(cdp.mol[0].res[30].spin[0], 'ri_data')) 2829 self.assertEqual(cdp.mol[0].res[31].num, 41) 2830 self.assertEqual(cdp.mol[0].res[31].spin[0].kex, guess[':41@N'][6]) 2831 self.assert_(hasattr(cdp.mol[0].res[31].spin[0], 'ri_data')) 2832 self.assertEqual(cdp.mol[0].res[33].num, 43) 2833 self.assertEqual(cdp.mol[0].res[33].spin[0].kex, guess[':43@N'][6]) 2834 self.assert_(hasattr(cdp.mol[0].res[33].spin[0], 'ri_data')) 2835 self.assertEqual(cdp.mol[0].res[34].num, 44) 2836 self.assertEqual(cdp.mol[0].res[34].spin[0].kex, guess[':44@N'][6]) 2837 self.assert_(hasattr(cdp.mol[0].res[34].spin[0], 'ri_data')) 2838 self.assertEqual(cdp.mol[0].res[35].num, 45) 2839 self.assertEqual(cdp.mol[0].res[35].spin[0].kex, guess[':45@N'][6]) 2840 self.assert_(hasattr(cdp.mol[0].res[35].spin[0], 'ri_data')) 2841 self.assertEqual(cdp.mol[0].res[38].num, 49) 2842 self.assertEqual(cdp.mol[0].res[38].spin[0].kex, guess[':49@N'][6]) 2843 self.assert_(hasattr(cdp.mol[0].res[38].spin[0], 'ri_data')) 2844 self.assertEqual(cdp.mol[0].res[41].num, 52) 2845 self.assertEqual(cdp.mol[0].res[41].spin[0].kex, guess[':52@N'][6]) 2846 self.assert_(hasattr(cdp.mol[0].res[41].spin[0], 'ri_data')) 2847 self.assertEqual(cdp.mol[0].res[42].num, 53) 2848 self.assertEqual(cdp.mol[0].res[42].spin[0].kex, guess[':53@N'][6]) 2849 self.assert_(hasattr(cdp.mol[0].res[42].spin[0], 'ri_data')) 2850 2851 # The dispersion models. 2852 MODELS = ['R2eff', 'DPL94'] 2853 2854 # The grid search size (the number of increments per dimension). 2855 GRID_INC = 4 2856 2857 # The number of Monte Carlo simulations to be used for error analysis at the end of the analysis. 2858 MC_NUM = 3 2859 2860 # Model selection technique. 2861 MODSEL = 'AIC' 2862 2863 # Execute the auto-analysis (fast). 2864 # Standard parameters are: func_tol=1e-25, grad_tol=None, max_iter=10000000, 2865 OPT_FUNC_TOL = 1e-1 2866 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL 2867 OPT_MAX_ITERATIONS = 1000 2868 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS 2869 2870 analysis_mode = "man" 2871 2872 if analysis_mode == "auto": 2873 # Run the analysis. 2874 relax_disp.Relax_disp(pipe_name=pipe_name, pipe_bundle=pipe_bundle, results_dir=ds.tmpdir, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL) 2875 2876 ########### 2877 elif analysis_mode == "man": 2878 for curspin in cluster_ids: 2879 self.interpreter.relax_disp.cluster('free spins', curspin) 2880 2881 # Do the analysis manual 2882 self.interpreter.spectrum.error_analysis(subset=['46_0_35_0', '48_0_35_4', '47_0_35_10', '49_0_35_20', '36_0_39_0', '39_0_39_4', '37_0_39_10', '40_0_39_20', '38_0_39_40', '41_0_41_0', '44_0_41_4', '42_0_41_10', '45_0_41_20', '43_0_41_40', '31_0_43_0', '34_0_43_4', '32_0_43_10', '35_0_43_20', '33_0_43_40', '1_0_46_0', '4_0_46_4', '2_0_46_10', '5_0_46_20', '3_0_46_40', '60_0_48_0', '63_0_48_4', '61_0_48_10', '62_0_48_14', '64_0_48_20', '11_500_46_0', '14_500_46_4', '12_500_46_10', '15_500_46_20', '13_500_46_40', '50_1000_41_0', '53_1000_41_4', '51_1000_41_10', '54_1000_41_20', '52_1000_41_40', '21_1000_46_0', '24_1000_46_4', '22_1000_46_10', '25_1000_46_20', '23_1000_46_40', '65_1000_48_0', '68_1000_48_4', '66_1000_48_10', '67_1000_48_14', '69_1000_48_20', '55_2000_41_0', '58_2000_41_4', '56_2000_41_10', '59_2000_41_20', '57_2000_41_40', '6_2000_46_0', '9_2000_46_4', '7_2000_46_10', '10_2000_46_20', '8_2000_46_40', '16_5000_46_0', '19_5000_46_4', '17_5000_46_10', '20_5000_46_20', '18_5000_46_40', '26_10000_46_0', '29_10000_46_4', '27_10000_46_10', '30_10000_46_20', '28_10000_46_40']) 2883 2884 ##- The 'R2eff' model - 2885 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to='R2eff - relax_disp', bundle_to='relax_disp') 2886 self.interpreter.pipe.switch(pipe_name='R2eff - relax_disp') 2887 self.interpreter.relax_disp.select_model(model='R2eff') 2888 self.interpreter.grid_search(lower=None, upper=None, inc=GRID_INC, constraints=True, verbosity=1) 2889 2890 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=OPT_FUNC_TOL, grad_tol=None, max_iter=OPT_MAX_ITERATIONS, constraints=True, scaling=True, verbosity=1) 2891 self.interpreter.eliminate(function=None, args=None) 2892 self.interpreter.monte_carlo.setup(number=MC_NUM) 2893 self.interpreter.monte_carlo.create_data(method='back_calc') 2894 self.interpreter.monte_carlo.initial_values() 2895 2896 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=OPT_FUNC_TOL, grad_tol=None, max_iter=OPT_MAX_ITERATIONS, constraints=True, scaling=True, verbosity=1) 2897 self.interpreter.eliminate(function=None, args=None) 2898 self.interpreter.monte_carlo.error_analysis() 2899 2900 # Write results 2901 #self.interpreter.relax_disp.plot_exp_curves(file='intensities.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'R2eff', force=True, norm=False) 2902 #self.interpreter.relax_disp.plot_exp_curves(file='intensities_norm.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'R2eff', force=True, norm=True) 2903 #self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir+sep+'resultsR1'+sep+'R2eff', num_points=1000, extend=500.0, force=True) 2904 #self.interpreter.relax_disp.write_disp_curves(dir=ds.tmpdir+sep+'resultsR1'+sep+'R2eff', force=True) 2905 #self.interpreter.value.write(param='r2eff', file='r2eff.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'R2eff', scaling=1.0, comment=None, bc=False, force=True) 2906 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='r2eff', spin_id=None, plot_data='value', file='r2eff.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'R2eff', force=True, norm=False) 2907 #self.interpreter.value.write(param='i0', file='i0.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'R2eff', scaling=1.0, comment=None, bc=False, force=True) 2908 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='i0', spin_id=None, plot_data='value', file='i0.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'R2eff', force=True, norm=False) 2909 #self.interpreter.value.write(param='chi2', file='chi2.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'R2eff', scaling=1.0, comment=None, bc=False, force=True) 2910 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='chi2', spin_id=None, plot_data='value', file='chi2.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'R2eff', force=True, norm=False) 2911 2912 ## Save results as state 2913 #self.interpreter.results.write(file='results', dir=ds.tmpdir+sep+'resultsR1'+sep+'R2eff', compress_type=1, force=True) 2914 2915 ##- The 'No Rex' model - 2916 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to='No Rex - relax_disp', bundle_to='relax_disp') 2917 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp') 2918 self.interpreter.relax_disp.select_model(model='No Rex') 2919 self.interpreter.value.copy(pipe_from='R2eff - relax_disp', pipe_to='No Rex - relax_disp', param='r2eff') 2920 self.interpreter.grid_search(lower=None, upper=None, inc=GRID_INC, constraints=True, verbosity=1) 2921 2922 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=OPT_FUNC_TOL, grad_tol=None, max_iter=OPT_MAX_ITERATIONS, constraints=True, scaling=True, verbosity=1) 2923 self.interpreter.eliminate(function=None, args=None) 2924 2925 ## Write results 2926 #self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir+sep+'resultsR1'+sep+'No Rex', num_points=1000, extend=500.0, force=True) 2927 #self.interpreter.relax_disp.write_disp_curves(dir=ds.tmpdir+sep+'resultsR1'+sep+'No Rex', force=True) 2928 #self.interpreter.value.write(param='chi2', file='chi2.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'No Rex', scaling=1.0, comment=None, bc=False, force=True) 2929 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='chi2', spin_id=None, plot_data='value', file='chi2.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'No Rex', force=True, norm=False) 2930 2931 ## Save results as state 2932 self.interpreter.results.write(file='results', dir=ds.tmpdir+sep+'resultsR1'+sep+'No Rex', compress_type=1, force=True) 2933 2934 ##- The 'DPL94' model - 2935 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to='DPL94 - relax_disp', bundle_to='relax_disp') 2936 self.interpreter.pipe.switch(pipe_name='DPL94 - relax_disp') 2937 self.interpreter.relax_disp.select_model(model='DPL94') 2938 self.interpreter.value.copy(pipe_from='R2eff - relax_disp', pipe_to='DPL94 - relax_disp', param='r2eff') 2939 self.interpreter.relax_disp.insignificance(level=1.0) 2940 self.interpreter.grid_search(lower=None, upper=None, inc=GRID_INC, constraints=True, verbosity=1) 2941 2942 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=OPT_FUNC_TOL, grad_tol=None, max_iter=OPT_MAX_ITERATIONS, constraints=True, scaling=True, verbosity=1) 2943 self.interpreter.eliminate(function=None, args=None) 2944 2945 ## Write results 2946 #self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir+sep+'resultsR1'+sep+'DPL94', num_points=1000, extend=500.0, force=True) 2947 #self.interpreter.relax_disp.write_disp_curves(dir=ds.tmpdir+sep+'resultsR1'+sep+'DPL94', force=True) 2948 #self.interpreter.value.write(param='phi_ex', file='phi_ex.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'DPL94', scaling=1.0, comment=None, bc=False, force=True) 2949 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='phi_ex', spin_id=None, plot_data='value', file='phi_ex.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'DPL94', force=True, norm=False) 2950 #self.interpreter.value.write(param='k_AB', file='k_AB.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'DPL94', scaling=1.0, comment=None, bc=False, force=True) 2951 #self.interpreter.value.write(param='kex', file='kex.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'DPL94', scaling=1.0, comment=None, bc=False, force=True) 2952 #self.interpreter.value.write(param='tex', file='tex.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'DPL94', scaling=1.0, comment=None, bc=False, force=True) 2953 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='k_AB', spin_id=None, plot_data='value', file='k_AB.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'DPL94', force=True, norm=False) 2954 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='kex', spin_id=None, plot_data='value', file='kex.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'DPL94', force=True, norm=False) 2955 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='tex', spin_id=None, plot_data='value', file='tex.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'DPL94', force=True, norm=False) 2956 #self.interpreter.value.write(param='chi2', file='chi2.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'DPL94', scaling=1.0, comment=None, bc=False, force=True) 2957 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='chi2', spin_id=None, plot_data='value', file='chi2.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'DPL94', force=True, norm=False) 2958 2959 ## Save results as state 2960 #self.interpreter.results.write(file='results', dir=ds.tmpdir+sep+'resultsR1'+sep+'DPL94', compress_type=1, force=True) 2961 2962 ##- The 'final' model - 2963 self.interpreter.model_selection(method='AIC', modsel_pipe='final - relax_disp', bundle='relax_disp', pipes=['No Rex - relax_disp', 'DPL94 - relax_disp']) 2964 self.interpreter.monte_carlo.setup(number=MC_NUM) 2965 self.interpreter.monte_carlo.create_data(method='back_calc') 2966 self.interpreter.monte_carlo.initial_values() 2967 2968 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=OPT_FUNC_TOL, grad_tol=None, max_iter=OPT_MAX_ITERATIONS, constraints=True, scaling=True, verbosity=1) 2969 self.interpreter.eliminate(function=None, args=None) 2970 self.interpreter.monte_carlo.error_analysis() 2971 2972 ## Write results 2973 #self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir+sep+'resultsR1'+sep+'final', num_points=1000, extend=500.0, force=True) 2974 #self.interpreter.relax_disp.write_disp_curves(dir=ds.tmpdir+sep+'resultsR1'+sep+'final', force=True) 2975 #self.interpreter.value.write(param='model', file='model.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True) 2976 #self.interpreter.value.write(param='pA', file='pA.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True) 2977 #self.interpreter.value.write(param='pB', file='pB.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True) 2978 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='pA', spin_id=None, plot_data='value', file='pA.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', force=True, norm=False) 2979 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='pB', spin_id=None, plot_data='value', file='pB.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', force=True, norm=False) 2980 self.interpreter.value.write(param='phi_ex', file='phi_ex.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True) 2981 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='phi_ex', spin_id=None, plot_data='value', file='phi_ex.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', force=True, norm=False) 2982 #self.interpreter.value.write(param='phi_ex_B', file='phi_ex_B.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True) 2983 #self.interpreter.value.write(param='phi_ex_C', file='phi_ex_C.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True) 2984 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='phi_ex_B', spin_id=None, plot_data='value', file='phi_ex_B.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', force=True, norm=False) 2985 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='phi_ex_C', spin_id=None, plot_data='value', file='phi_ex_C.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', force=True, norm=False) 2986 #self.interpreter.value.write(param='dw', file='dw.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True) 2987 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='dw', spin_id=None, plot_data='value', file='dw.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', force=True, norm=False) 2988 #self.interpreter.value.write(param='dwH', file='dwH.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True) 2989 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='dwH', spin_id=None, plot_data='value', file='dwH.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', force=True, norm=False) 2990 #self.interpreter.value.write(param='k_AB', file='k_AB.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True) 2991 self.interpreter.value.write(param='kex', file='kex.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True) 2992 #self.interpreter.value.write(param='tex', file='tex.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True) 2993 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='k_AB', spin_id=None, plot_data='value', file='k_AB.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', force=True, norm=False) 2994 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='kex', spin_id=None, plot_data='value', file='kex.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', force=True, norm=False) 2995 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='tex', spin_id=None, plot_data='value', file='tex.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', force=True, norm=False) 2996 #self.interpreter.value.write(param='k_AB', file='k_AB.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True) 2997 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='k_AB', spin_id=None, plot_data='value', file='k_AB.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', force=True, norm=False) 2998 #self.interpreter.value.write(param='kB', file='kB.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True) 2999 #self.interpreter.value.write(param='kC', file='kC.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True) 3000 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='kB', spin_id=None, plot_data='value', file='kB.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', force=True, norm=False) 3001 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='kC', spin_id=None, plot_data='value', file='kC.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', force=True, norm=False) 3002 #self.interpreter.value.write(param='chi2', file='chi2.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True) 3003 #self.interpreter.grace.write(x_data_type='res_num', y_data_type='chi2', spin_id=None, plot_data='value', file='chi2.agr', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', force=True, norm=False) 3004 3005 # Test of new parameters to write out. 3006 self.interpreter.value.write(param='theta', file='theta.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True) 3007 #self.interpreter.value.write(param='theta', file='theta.out', dir='~', scaling=1.0, comment=None, bc=False, force=True) 3008 #self.assert_(hasattr(cdp.mol[0].res[7].spin[0], 'theta')) 3009 3010 ## Save results as state 3011 #self.interpreter.results.write(file='results', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', compress_type=1, force=True) 3012 ## Save all results in all pipes in state 3013 #self.interpreter.state.save(state='final_state', dir=ds.tmpdir+sep+'resultsR1', compress_type=1, force=True) 3014 3015 # Assert the file existence of the written value files 3016 self.assert_(access(ds.tmpdir+sep+'resultsR1'+sep+'final'+sep+'phi_ex.out', F_OK)) 3017 self.assert_(access(ds.tmpdir+sep+'resultsR1'+sep+'final'+sep+'kex.out', F_OK))
3018 3019
3020 - def test_r2eff_read(self):
3021 """Test the operation of the relax_disp.r2eff_read user function.""" 3022 3023 # The path to the data files. 3024 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Hansen'+sep+'800_MHz' 3025 3026 # Read the sequence data. 3027 self.interpreter.sequence.read(file='66.667.in', dir=data_path, res_num_col=1) 3028 3029 # The ID. 3030 id = 'test' 3031 3032 # Set up the metadata. 3033 self.interpreter.spectrometer.frequency(id=id, frq=800e6) 3034 self.interpreter.relax_disp.exp_type(spectrum_id=id, exp_type='SQ CPMG') 3035 3036 # Try reading the file. 3037 self.interpreter.relax_disp.r2eff_read(id=id, file='66.667.in', dir=data_path, disp_frq=66.667, res_num_col=1, data_col=2, error_col=3) 3038 3039 # Check the global data. 3040 data = [ 3041 ['cpmg_frqs', {'test': 66.667}], 3042 ['cpmg_frqs_list', [66.667]], 3043 ['dispersion_points', 1], 3044 ['exp_type', {'test': 'SQ CPMG'}], 3045 ['exp_type_list', ['SQ CPMG']], 3046 ['spectrometer_frq', {'test': 800000000.0}], 3047 ['spectrometer_frq_count', 1], 3048 ['spectrometer_frq_list', [800000000.0]], 3049 ['spectrum_ids', ['test']] 3050 ] 3051 for name, value in data: 3052 # Does it exist? 3053 self.assert_(hasattr(cdp, name)) 3054 3055 # Check the object. 3056 obj = getattr(cdp, name) 3057 self.assertEqual(obj, value) 3058 3059 # Check the spin data. 3060 data = [ 3061 [1, 2.3035747e+04, 8.5467725e+01], 3062 [2, 9.9629762e+04, 2.8322033e+02], 3063 [3, 9.5663137e+04, 2.8632929e+02], 3064 [4, 1.7089893e+05, 3.1089428e+02], 3065 [5, 4.7323876e+04, 1.0084269e+02], 3066 [6, 2.0199122e+04, 1.0135220e+02], 3067 [7, 1.6655488e+05, 3.1609061e+02], 3068 [8, 9.0061074e+04, 1.9176585e+02], 3069 [10, 8.4726204e+04, 2.8898155e+02], 3070 [11, 1.5050233e+05, 4.3138029e+02], 3071 [12, 9.2998531e+04, 3.0440191e+02], 3072 [13, 1.6343507e+05, 3.3144097e+02], 3073 [14, 1.0137301e+05, 3.7314642e+02], 3074 [15, 8.3407837e+04, 1.6546473e+02], 3075 [16, 1.3819126e+05, 3.3388517e+02], 3076 [17, 1.1010490e+05, 3.5639222e+02], 3077 [18, 9.4324035e+04, 3.2343585e+02], 3078 [19, 1.1135179e+05, 3.0706671e+02], 3079 [20, 7.6339410e+04, 1.7377460e+02], 3080 [21, 6.2008453e+04, 1.7327150e+02], 3081 [22, 1.0590404e+05, 2.4814635e+02], 3082 [23, 1.0630198e+05, 2.3601100e+02], 3083 [24, 7.2996320e+04, 1.4952465e+02], 3084 [25, 9.5486742e+04, 2.7080766e+02], 3085 [26, 5.8067989e+04, 1.6820462e+02], 3086 [27, -1.7168510e+04, 2.2519560e+02], 3087 [28, 1.6891473e+05, 2.3497525e+02], 3088 [29, 9.4038555e+04, 2.0357593e+02], 3089 [30, 2.1386951e+04, 2.2153532e+02], 3090 [31, 9.3982899e+04, 2.0937056e+02], 3091 [32, 8.6097484e+04, 2.3868467e+02], 3092 [33, 1.0194337e+05, 2.7370704e+02], 3093 [34, 8.5683111e+04, 2.0838076e+02], 3094 [35, 8.6985768e+04, 2.0889310e+02], 3095 [36, 8.6011237e+04, 1.7498390e+02], 3096 [37, 1.0984097e+05, 2.7622998e+02], 3097 [38, 8.7017879e+04, 2.6547994e+02], 3098 [39, 9.1682649e+04, 5.2777676e+02], 3099 [40, 7.6370440e+04, 1.9873214e+02], 3100 [41, 9.1393531e+04, 2.4483824e+02], 3101 [42, 1.1017111e+05, 2.8020699e+02], 3102 [43, 9.4552366e+04, 3.4394150e+02], 3103 [44, 1.2858281e+05, 6.8449252e+02], 3104 [45, 7.4583525e+04, 1.9544210e+02], 3105 [46, 9.2087490e+04, 2.0491066e+02], 3106 [47, 9.7507255e+04, 2.5162839e+02], 3107 [48, 1.0033842e+05, 2.7566430e+02], 3108 [49, 1.3048305e+05, 2.6797466e+02], 3109 [50, 1.0546796e+05, 1.9304384e+02], 3110 [51, 9.3099697e+04, 2.0773311e+02], 3111 [52, 4.6863758e+04, 1.3169068e+02], 3112 [53, 6.1055806e+04, 1.5448477e+02], 3113 [55, 6.8629994e+04, 1.6868673e+02], 3114 [56, 1.1005552e+05, 2.1940465e+02], 3115 [57, 1.0572760e+05, 1.9768486e+02], 3116 [58, 1.1176950e+05, 3.0009610e+02], 3117 [59, 9.8758603e+04, 3.3803895e+02], 3118 [60, 9.9517201e+04, 3.5137994e+02], 3119 [61, 5.4357946e+04, 2.5896579e+02], 3120 [62, 1.0899978e+05, 2.8720371e+02], 3121 [63, 8.4549759e+04, 4.1401837e+02], 3122 [64, 5.5014550e+04, 2.1135781e+02], 3123 [65, 8.0569666e+04, 2.3249709e+02], 3124 [66, 1.2936610e+05, 3.5218725e+02], 3125 [67, 3.6438010e+04, 8.7924003e+01], 3126 [70, 3.8763157e+04, 1.3325040e+02], 3127 [71, 8.5711411e+04, 2.9316183e+02], 3128 [72, 3.3211541e+04, 1.2182123e+02], 3129 [73, 3.2070576e+04, 1.2305430e+02] 3130 ] 3131 for res_num, value, error in data: 3132 # Get the spin. 3133 spin = return_spin(spin_id=":%s"%res_num) 3134 3135 # Check the values. 3136 self.assertEqual(spin.r2eff['sq_cpmg_800.00000000_0.000_66.667'], value) 3137 self.assertEqual(spin.r2eff_err['sq_cpmg_800.00000000_0.000_66.667'], error)
3138 3139
3140 - def test_r2eff_read_spin(self):
3141 """Test the operation of the relax_disp.r2eff_read_spin user function.""" 3142 3143 # The path to the data files. 3144 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Korzhnev_et_al_2005' 3145 3146 # Generate the sequence. 3147 self.interpreter.spin.create(res_name='Asp', res_num=9, spin_name='H') 3148 self.interpreter.spin.create(res_name='Asp', res_num=9, spin_name='N') 3149 self.interpreter.spin.isotope('1H', spin_id='@H') 3150 self.interpreter.spin.isotope('15N', spin_id='@N') 3151 3152 # Build the experiment IDs. 3153 H_disp_points = [67.0, 133.0, 267.0, 400.0, 533.0, 667.0, 800.0, 933.0, 1067.0, 1600.0, 2133.0, 2667.0] 3154 N_disp_points = [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0, 1000.0] 3155 ids = [] 3156 for value in H_disp_points: 3157 ids.append('1H_CPMG_%s' % value) 3158 for value in N_disp_points: 3159 ids.append('15N_CPMG_%s' % value) 3160 print("\n\nThe experiment IDs are %s." % ids) 3161 3162 # Set up the metadata for the experiments. 3163 for id in ids: 3164 self.interpreter.spectrometer.frequency(id=id, frq=500e6) 3165 self.interpreter.relax_disp.exp_type(spectrum_id=id, exp_type='SQ CPMG') 3166 for value in H_disp_points: 3167 self.interpreter.relax_disp.cpmg_frq(spectrum_id='1H_CPMG_%s' % value, cpmg_frq=value) 3168 for value in N_disp_points: 3169 self.interpreter.relax_disp.cpmg_frq(spectrum_id='15N_CPMG_%s' % value, cpmg_frq=value) 3170 3171 # Loop over the experiments. 3172 for id, file, spin_id in [['1H_CPMG', 'hs_500.res', ':9@H'], ['15N_CPMG', 'ns_500.res', ':9@N']]: 3173 # Try reading the file. 3174 self.interpreter.relax_disp.r2eff_read_spin(id=id, file=file, dir=data_path, spin_id=spin_id, disp_point_col=1, data_col=2, error_col=3) 3175 3176 # Check the global data. 3177 data = [ 3178 ['cpmg_frqs', {'1H_CPMG_667.0': 667.0, '1H_CPMG_1067.0': 1067.0, '15N_CPMG_350.0': 350.0, '1H_CPMG_933.0': 933.0, '15N_CPMG_50.0': 50.0, '15N_CPMG_100.0': 100.0, '1H_CPMG_400.0': 400.0, '1H_CPMG_533.0': 533.0, '1H_CPMG_800.0': 800.0, '15N_CPMG_900.0': 900.0, '15N_CPMG_150.0': 150.0, '15N_CPMG_800.0': 800.0, '1H_CPMG_267.0': 267.0, '1H_CPMG_2667.0': 2667.0, '15N_CPMG_300.0': 300.0, '1H_CPMG_133.0': 133.0, '15N_CPMG_700.0': 700.0, '1H_CPMG_67.0': 67.0, '15N_CPMG_400.0': 400.0, '15N_CPMG_250.0': 250.0, '1H_CPMG_2133.0': 2133.0, '1H_CPMG_1600.0': 1600.0, '15N_CPMG_200.0': 200.0, '15N_CPMG_1000.0': 1000.0, '15N_CPMG_500.0': 500.0, '15N_CPMG_600.0': 600.0}], 3179 ['cpmg_frqs_list', [50.0, 67.0, 100.0, 133.0, 150.0, 200.0, 250.0, 267.0, 300.0, 350.0, 400.0, 500.0, 533.0, 600.0, 667.0, 700.0, 800.0, 900.0, 933.0, 1000.0, 1067.0, 1600.0, 2133.0, 2667.0]], 3180 ['dispersion_points', 24], 3181 ['exp_type', {'1H_CPMG_667.0': 'SQ CPMG', '1H_CPMG_1067.0': 'SQ CPMG', '15N_CPMG_350.0': 'SQ CPMG', '1H_CPMG_933.0': 'SQ CPMG', '15N_CPMG_50.0': 'SQ CPMG', '15N_CPMG_100.0': 'SQ CPMG', '1H_CPMG_400.0': 'SQ CPMG', '1H_CPMG_533.0': 'SQ CPMG', '1H_CPMG_800.0': 'SQ CPMG', '15N_CPMG_900.0': 'SQ CPMG', '15N_CPMG_150.0': 'SQ CPMG', '15N_CPMG_800.0': 'SQ CPMG', '1H_CPMG_267.0': 'SQ CPMG', '1H_CPMG_2667.0': 'SQ CPMG', '15N_CPMG_300.0': 'SQ CPMG', '1H_CPMG_133.0': 'SQ CPMG', '15N_CPMG_700.0': 'SQ CPMG', '1H_CPMG_67.0': 'SQ CPMG', '15N_CPMG_400.0': 'SQ CPMG', '15N_CPMG_250.0': 'SQ CPMG', '1H_CPMG_2133.0': 'SQ CPMG', '1H_CPMG_1600.0': 'SQ CPMG', '15N_CPMG_200.0': 'SQ CPMG', '15N_CPMG_1000.0': 'SQ CPMG', '15N_CPMG_500.0': 'SQ CPMG', '15N_CPMG_600.0': 'SQ CPMG'}], 3182 ['exp_type_list', ['SQ CPMG']], 3183 ['spectrometer_frq', {'1H_CPMG_667.0': 500000000.0, '1H_CPMG_1067.0': 500000000.0, '15N_CPMG_350.0': 500000000.0, '1H_CPMG_933.0': 500000000.0, '15N_CPMG_50.0': 500000000.0, '15N_CPMG_100.0': 500000000.0, '1H_CPMG_400.0': 500000000.0, '1H_CPMG_533.0': 500000000.0, '1H_CPMG_800.0': 500000000.0, '15N_CPMG_900.0': 500000000.0, '15N_CPMG_150.0': 500000000.0, '15N_CPMG_800.0': 500000000.0, '1H_CPMG_267.0': 500000000.0, '1H_CPMG_2667.0': 500000000.0, '15N_CPMG_300.0': 500000000.0, '1H_CPMG_133.0': 500000000.0, '15N_CPMG_700.0': 500000000.0, '1H_CPMG_67.0': 500000000.0, '15N_CPMG_400.0': 500000000.0, '15N_CPMG_250.0': 500000000.0, '1H_CPMG_2133.0': 500000000.0, '1H_CPMG_1600.0': 500000000.0, '15N_CPMG_200.0': 500000000.0, '15N_CPMG_1000.0': 500000000.0, '15N_CPMG_500.0': 500000000.0, '15N_CPMG_600.0': 500000000.0}], 3184 ['spectrometer_frq_count', 1], 3185 ['spectrometer_frq_list', [500000000.0]], 3186 ['spectrum_ids', ['1H_CPMG_67.0', '1H_CPMG_133.0', '1H_CPMG_267.0', '1H_CPMG_400.0', '1H_CPMG_533.0', '1H_CPMG_667.0', '1H_CPMG_800.0', '1H_CPMG_933.0', '1H_CPMG_1067.0', '1H_CPMG_1600.0', '1H_CPMG_2133.0', '1H_CPMG_2667.0', '15N_CPMG_50.0', '15N_CPMG_100.0', '15N_CPMG_150.0', '15N_CPMG_200.0', '15N_CPMG_250.0', '15N_CPMG_300.0', '15N_CPMG_350.0', '15N_CPMG_400.0', '15N_CPMG_500.0', '15N_CPMG_600.0', '15N_CPMG_700.0', '15N_CPMG_800.0', '15N_CPMG_900.0', '15N_CPMG_1000.0']] 3187 ] 3188 for name, value in data: 3189 # Does it exist? 3190 self.assert_(hasattr(cdp, name)) 3191 3192 # Check the object. 3193 obj = getattr(cdp, name) 3194 if not isinstance(data, dict): 3195 self.assertEqual(obj, value) 3196 3197 # Check the global dictionary data. 3198 else: 3199 for id in ids: 3200 self.assertEqual(obj[id], value[id]) 3201 3202 # Check the spin data. 3203 h_data = [ 3204 [ 67.0, 21.47924, 0.42958], 3205 [ 133.0, 16.73898, 0.33478], 3206 [ 267.0, 9.97357, 0.19947], 3207 [ 400.0, 8.23877, 0.24737], 3208 [ 533.0, 7.59290, 0.24263], 3209 [ 667.0, 7.45843, 0.24165], 3210 [ 800.0, 7.11222, 0.23915], 3211 [ 933.0, 7.40880, 0.24129], 3212 [1067.0, 6.55191, 0.16629], 3213 [1600.0, 6.72177, 0.23637], 3214 [2133.0, 7.09629, 0.23904], 3215 [2667.0, 7.14675, 0.23940] 3216 ] 3217 for disp_point, value, error in h_data: 3218 id = 'sq_cpmg_500.00000000_0.000_%.3f' % disp_point 3219 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff[id], value) 3220 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff_err[id], error) 3221 n_data = [ 3222 [ 50.0, 27.15767, 0.54315], 3223 [ 100.0, 26.55781, 0.53116], 3224 [ 150.0, 24.73462, 0.49469], 3225 [ 200.0, 20.98617, 0.41972], 3226 [ 250.0, 17.82442, 0.35649], 3227 [ 300.0, 15.55352, 0.31107], 3228 [ 350.0, 13.78958, 0.27579], 3229 [ 400.0, 12.48334, 0.24967], 3230 [ 500.0, 11.55724, 0.23114], 3231 [ 600.0, 10.53874, 0.21077], 3232 [ 700.0, 10.07395, 0.20148], 3233 [ 800.0, 9.62952, 0.19259], 3234 [ 900.0, 9.49994, 0.19000], 3235 [1000.0, 8.71350, 0.17427] 3236 ] 3237 for disp_point, value, error in n_data: 3238 id = 'sq_cpmg_500.00000000_0.000_%.3f' % disp_point 3239 self.assertEqual(cdp.mol[0].res[0].spin[1].r2eff[id], value) 3240 self.assertEqual(cdp.mol[0].res[0].spin[1].r2eff_err[id], error)
3241 3242
3243 - def test_r2eff_fit_fixed_time(self):
3244 """Test the relaxation dispersion 'R2eff' model for fixed time data in the auto-analysis.""" 3245 3246 # Execute the script. 3247 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r2eff_calc.py')
3248 3249
3250 - def test_read_r2eff(self):
3251 """Test the reading of a file containing r2eff values.""" 3252 3253 # Create the sequence data, and name the spins. 3254 self.interpreter.residue.create(1, 'Gly') 3255 self.interpreter.residue.create(2, 'Gly') 3256 self.interpreter.residue.create(3, 'Gly') 3257 3258 # Read the file. 3259 self.interpreter.relax_data.read(ri_id='R2eff.600', ri_type='R2eff', frq=600*1e6, file='r2eff.out', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r2eff', res_num_col=1, res_name_col=2, data_col=3, error_col=4) 3260 3261 # Test the data. 3262 self.assertEqual(cdp.mol[0].res[0].spin[0].ri_data['R2eff.600'], 15.000) 3263 self.assertEqual(cdp.mol[0].res[1].spin[0].ri_data['R2eff.600'], 4.2003) 3264 self.assertEqual(cdp.mol[0].res[2].spin[0].ri_data['R2eff.600'], 7.2385)
3265 3266
3267 - def test_sprangers_data_to_mmq_cr72(self, model=None):
3268 """Test the 'MMQ CR72' model fitting against Remco Sprangers' ClpP data. 3269 3270 This uses the data from Remco Sprangers' paper at http://dx.doi.org/10.1073/pnas.0507370102. This is MMQ CPMG data with a fixed relaxation time period. 3271 """ 3272 3273 # Reset. 3274 self.interpreter.reset() 3275 3276 # Create the data pipe and load the base data. 3277 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Sprangers_ClpP' 3278 self.interpreter.state.load(data_path+sep+'r2eff_values') 3279 3280 # The model data pipe. 3281 model = 'MMQ CR72' 3282 pipe_name = "%s - relax_disp" % model 3283 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to=pipe_name, bundle_to='relax_disp') 3284 self.interpreter.pipe.switch(pipe_name=pipe_name) 3285 3286 # Set the model. 3287 self.interpreter.relax_disp.select_model(model=model) 3288 3289 # Cluster everything. 3290 self.interpreter.relax_disp.cluster(cluster_id='all', spin_id=":135-137") 3291 3292 # Copy the data. 3293 self.interpreter.value.copy(pipe_from='R2eff', pipe_to=pipe_name, param='r2eff') 3294 3295 # Alias the spins. 3296 spin135S = cdp.mol[0].res[0].spin[0] 3297 spin135F = cdp.mol[0].res[0].spin[1] 3298 spin137S = cdp.mol[0].res[1].spin[0] 3299 spin137F = cdp.mol[0].res[1].spin[1] 3300 3301 # The R20 keys. 3302 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=600e6) 3303 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6) 3304 3305 # Set the cluster specific parameters (only for the first spin). 3306 spin135S.pA = 0.836591763632 3307 spin135S.kex = 241.806525261 3308 3309 # Set the initial parameter values. 3310 spin135S.r2 = {r20_key1: 28.2493431552, r20_key2: 31.7517334715} 3311 spin135S.dw = 0.583003118785 3312 spin135S.dwH = 0.0361441944301 3313 3314 spin135F.r2 = {r20_key1: 42.7201839991, r20_key2: 57.3178617389} 3315 spin135F.dw = 0.805849745104 3316 spin135F.dwH = 0.0215791945715 3317 3318 spin137S.r2 = {r20_key1: 26.0134115256, r20_key2: 30.575806934} 3319 spin137S.dw = 0.688107568372 3320 spin137S.dwH = 0.0344463604043 3321 3322 spin137F.r2 = {r20_key1: 46.6969397337, r20_key2: 58.602384101} 3323 spin137F.dw = 0.94978299907 3324 spin137F.dwH = 1.4818877939e-07 3325 3326 # Low precision optimisation. 3327 self.interpreter.minimise(min_algor='simplex', func_tol=1e-10, max_iter=1000) 3328 3329 # Printout. 3330 print("\n\nOptimised parameters:\n") 3331 print("%-20s %-20s %-20s %-20s %-20s" % ("Parameter", "Value (:135@S)", "Value (:135@F)", "Value (:137@S)", "Value (:137@F)")) 3332 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("R2 (500 MHz)", spin135S.r2[r20_key1], spin135F.r2[r20_key1], spin137S.r2[r20_key1], spin137F.r2[r20_key1])) 3333 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("R2 (800 MHz)", spin135S.r2[r20_key2], spin135F.r2[r20_key2], spin137S.r2[r20_key2], spin137F.r2[r20_key2])) 3334 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("pA", spin135S.pA, spin135F.pA, spin137S.pA, spin137F.pA)) 3335 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("dw", spin135S.dw, spin135F.dw, spin137S.dw, spin137F.dw)) 3336 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("dwH", spin135S.dwH, spin135F.dwH, spin137S.dwH, spin137F.dwH)) 3337 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("kex", spin135S.kex, spin135F.kex, spin137S.kex, spin137F.kex)) 3338 print("%-20s %20.15g %20.15g %20.15g %20.15g\n" % ("chi2", spin135S.chi2, spin135F.chi2, spin137S.chi2, spin137F.chi2)) 3339 print("\n # Set the cluster specific parameters (only for the first spin).") 3340 print(" spin135S.pA = %s" % spin135S.pA) 3341 print(" spin135S.kex = %s" % spin135S.kex) 3342 print("\n # Set the initial parameter values.") 3343 print(" spin135S.r2 = {r20_key1: %s, r20_key2: %s}" % (spin135S.r2[r20_key1], spin135S.r2[r20_key2])) 3344 print(" spin135S.dw = %s" % spin135S.dw) 3345 print(" spin135S.dwH = %s" % spin135S.dwH) 3346 print("\n spin135F.r2 = {r20_key1: %s, r20_key2: %s}" % (spin135F.r2[r20_key1], spin135F.r2[r20_key2])) 3347 print(" spin135F.dw = %s" % spin135F.dw) 3348 print(" spin135F.dwH = %s" % spin135F.dwH) 3349 print("\n spin137S.r2 = {r20_key1: %s, r20_key2: %s}" % (spin137S.r2[r20_key1], spin137S.r2[r20_key2])) 3350 print(" spin137S.dw = %s" % spin137S.dw) 3351 print(" spin137S.dwH = %s" % spin137S.dwH) 3352 print("\n spin137F.r2 = {r20_key1: %s, r20_key2: %s}" % (spin137F.r2[r20_key1], spin137F.r2[r20_key2])) 3353 print(" spin137F.dw = %s" % spin137F.dw) 3354 print(" spin137F.dwH = %s" % spin137F.dwH) 3355 3356 # Checks for residue :135S. 3357 self.assertAlmostEqual(spin135S.r2[r20_key1], 28.2499549832749, 4) 3358 self.assertAlmostEqual(spin135S.r2[r20_key2], 31.7529931145939, 4) 3359 self.assertAlmostEqual(spin135S.pA, 0.836602053942836, 4) 3360 self.assertAlmostEqual(spin135S.dw, 0.582996164517237, 4) 3361 self.assertAlmostEqual(spin135S.dwH, 0.0361431023785737, 4) 3362 self.assertAlmostEqual(spin135S.kex, 241.827943268269, 4) 3363 self.assertAlmostEqual(spin135S.chi2, 12.4224061774664, 4) 3364 3365 # Checks for residue :135F. 3366 self.assertAlmostEqual(spin135F.r2[r20_key1], 42.7201353164699, 4) 3367 self.assertAlmostEqual(spin135F.r2[r20_key2], 57.3182694767754, 4) 3368 self.assertAlmostEqual(spin135F.pA, 0.836602053942836, 4) 3369 self.assertAlmostEqual(spin135F.dw, 0.805844579818815, 4) 3370 self.assertAlmostEqual(spin135F.dwH, 0.0215772589360951, 4) 3371 self.assertAlmostEqual(spin135F.kex, 241.827943268269, 4) 3372 self.assertAlmostEqual(spin135F.chi2, 12.4224061774664, 4) 3373 3374 # Checks for residue :137S. 3375 self.assertAlmostEqual(spin137S.r2[r20_key1], 26.0130900829802, 4) 3376 self.assertAlmostEqual(spin137S.r2[r20_key2], 30.5756150883564, 4) 3377 self.assertAlmostEqual(spin137S.pA, 0.836602053942836, 4) 3378 self.assertAlmostEqual(spin137S.dw, 0.688110098029141, 4) 3379 self.assertAlmostEqual(spin137S.dwH, 0.0344479518787365, 4) 3380 self.assertAlmostEqual(spin137S.kex, 241.827943268269, 4) 3381 self.assertAlmostEqual(spin137S.chi2, 12.4224061774664, 4) 3382 3383 # Checks for residue :137F. 3384 self.assertAlmostEqual(spin137F.r2[r20_key1], 46.6966999976701, 4) 3385 self.assertAlmostEqual(spin137F.r2[r20_key2], 58.6021572404496, 4) 3386 self.assertAlmostEqual(spin137F.pA, 0.836602053942836, 4) 3387 self.assertAlmostEqual(spin137F.dw, 0.949766944294449, 4) 3388 self.assertAlmostEqual(spin137F.dwH, 1.60128740101484e-07, 4) 3389 self.assertAlmostEqual(spin137F.kex, 241.827943268269, 4) 3390 self.assertAlmostEqual(spin137F.chi2, 12.4224061774664, 4)
3391 3392
3393 - def test_sprangers_data_to_ns_mmq_2site(self, model=None):
3394 """Test the 'NS MMQ 2-site' model fitting against Remco Sprangers' ClpP data. 3395 3396 This uses the data from Remco Sprangers' paper at http://dx.doi.org/10.1073/pnas.0507370102. This is MQ CPMG data with a fixed relaxation time period. 3397 """ 3398 3399 # Reset. 3400 self.interpreter.reset() 3401 3402 # Create the data pipe and load the base data. 3403 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Sprangers_ClpP' 3404 self.interpreter.state.load(data_path+sep+'r2eff_values') 3405 3406 # The model data pipe. 3407 model = 'NS MMQ 2-site' 3408 pipe_name = "%s - relax_disp" % model 3409 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to=pipe_name, bundle_to='relax_disp') 3410 self.interpreter.pipe.switch(pipe_name=pipe_name) 3411 3412 # Set the model. 3413 self.interpreter.relax_disp.select_model(model=model) 3414 3415 # Cluster everything. 3416 self.interpreter.relax_disp.cluster(cluster_id='all', spin_id=":135-137") 3417 3418 # Copy the data. 3419 self.interpreter.value.copy(pipe_from='R2eff', pipe_to=pipe_name, param='r2eff') 3420 3421 # Alias the spins. 3422 spin135S = cdp.mol[0].res[0].spin[0] 3423 spin135F = cdp.mol[0].res[0].spin[1] 3424 spin137S = cdp.mol[0].res[1].spin[0] 3425 spin137F = cdp.mol[0].res[1].spin[1] 3426 3427 # The R20 keys. 3428 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6) 3429 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6) 3430 3431 # Set the cluster specific parameters (only for the first spin). 3432 spin135S.pA = 0.847378444499757 3433 spin135S.kex = 264.055604934724329 3434 3435 # Set the initial parameter values. 3436 spin135S.r2 = {r20_key1: 30.315119723745390, r20_key2: 37.411874745645299} 3437 spin135S.dw = 0.585574008745351 3438 spin135S.dwH = 0.000000000000002 3439 3440 spin135F.r2 = {r20_key1: 41.440843383778287, r20_key2: 56.989726795397893} 3441 spin135F.dw = 0.856699277665748 3442 spin135F.dwH = 0.000000000582587 3443 3444 spin137S.r2 = {r20_key1: 23.051695938570266, r20_key2: 28.352806483953824} 3445 spin137S.dw = 0.772904450844973 3446 spin137S.dwH = 0.183351478512970 3447 3448 spin137F.r2 = {r20_key1: 44.702032074210429, r20_key2: 56.453146052685319} 3449 spin137F.dw = 0.984568590342831 3450 spin137F.dwH = 0.000000001993458 3451 3452 # Low precision optimisation. 3453 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-5, grad_tol=None, max_iter=100, constraints=True, scaling=True, verbosity=1) 3454 3455 # Printout. 3456 print("\n\nOptimised parameters:\n") 3457 print("%-20s %-20s %-20s %-20s %-20s" % ("Parameter", "Value (:135@S)", "Value (:135@F)", "Value (:137@S)", "Value (:137@F)")) 3458 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("R2 (500 MHz)", spin135S.r2[r20_key1], spin135F.r2[r20_key1], spin137S.r2[r20_key1], spin137F.r2[r20_key1])) 3459 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("R2 (800 MHz)", spin135S.r2[r20_key2], spin135F.r2[r20_key2], spin137S.r2[r20_key2], spin137F.r2[r20_key2])) 3460 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("pA", spin135S.pA, spin135F.pA, spin137S.pA, spin137F.pA)) 3461 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("dw", spin135S.dw, spin135F.dw, spin137S.dw, spin137F.dw)) 3462 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("dwH", spin135S.dwH, spin135F.dwH, spin137S.dwH, spin137F.dwH)) 3463 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("kex", spin135S.kex, spin135F.kex, spin137S.kex, spin137F.kex)) 3464 print("%-20s %20.15g %20.15g %20.15g %20.15g\n" % ("chi2", spin135S.chi2, spin135F.chi2, spin137S.chi2, spin137F.chi2)) 3465 3466 # FIXME: Remove this temporary return and properly check the results. 3467 return 3468 3469 # Checks for residue :135S. 3470 self.assertAlmostEqual(spin135S.r2[r20_key1], 30.3151197237454, 4) 3471 self.assertAlmostEqual(spin135S.r2[r20_key2], 37.4118747456453, 4) 3472 self.assertAlmostEqual(spin135S.pA, 0.847378444499757, 4) 3473 self.assertAlmostEqual(spin135S.dw, 0.585574008745351, 4) 3474 self.assertAlmostEqual(spin135S.dwH, 2e-15, 4) 3475 self.assertAlmostEqual(spin135S.kex, 264.055604934724, 4) 3476 self.assertAlmostEqual(spin135S.chi2, 13.859423588071, 1) 3477 3478 # Checks for residue :135F. 3479 self.assertAlmostEqual(spin135F.r2[r20_key1], 41.4408433837783, 4) 3480 self.assertAlmostEqual(spin135F.r2[r20_key2], 56.9897267953979, 4) 3481 self.assertAlmostEqual(spin135F.pA, 0.847378444499757, 4) 3482 self.assertAlmostEqual(spin135F.dw, 0.856699277665748, 4) 3483 self.assertAlmostEqual(spin135F.dwH, 5.82587e-10, 4) 3484 self.assertAlmostEqual(spin135F.kex, 264.055604934724, 4) 3485 self.assertAlmostEqual(spin135F.chi2, 13.859423588071, 1) 3486 3487 # Checks for residue :137S. 3488 self.assertAlmostEqual(spin137S.r2[r20_key1], 23.0516959385703, 4) 3489 self.assertAlmostEqual(spin137S.r2[r20_key2], 28.3528064839538, 4) 3490 self.assertAlmostEqual(spin137S.pA, 0.847378444499757, 4) 3491 self.assertAlmostEqual(spin137S.dw, 0.772904450844973, 4) 3492 self.assertAlmostEqual(spin137S.dwH, 0.18335147851297, 4) 3493 self.assertAlmostEqual(spin137S.kex, 264.055604934724, 4) 3494 self.assertAlmostEqual(spin137S.chi2, 13.859423588071, 1) 3495 3496 # Checks for residue :137F. 3497 self.assertAlmostEqual(spin137F.r2[r20_key1], 44.7020320742104, 4) 3498 self.assertAlmostEqual(spin137F.r2[r20_key2], 56.4531460526853, 4) 3499 self.assertAlmostEqual(spin137F.pA, 0.847378444499757, 4) 3500 self.assertAlmostEqual(spin137F.dw, 0.984568590342831, 4) 3501 self.assertAlmostEqual(spin137F.dwH, 2.0931309e-09, 4) 3502 self.assertAlmostEqual(spin137F.kex, 264.055604934724, 4) 3503 self.assertAlmostEqual(spin137F.chi2, 13.859423588071, 1)
3504 3505
3506 - def test_tp02_data_to_ns_r1rho_2site(self, model=None):
3507 """Test the relaxation dispersion 'NS R1rho 2-site' model fitting against the 'TP02' test data.""" 3508 3509 # Reset. 3510 self.interpreter.reset() 3511 3512 # Create the data pipe and load the base data. 3513 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r1rho_off_res_tp02' 3514 self.interpreter.state.load(data_path+sep+'r2eff_values') 3515 3516 # The model data pipe. 3517 model = 'NS R1rho 2-site' 3518 pipe_name = "%s - relax_disp" % model 3519 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to=pipe_name, bundle_to='relax_disp') 3520 self.interpreter.pipe.switch(pipe_name=pipe_name) 3521 3522 # Set the model. 3523 self.interpreter.relax_disp.select_model(model=model) 3524 3525 # Copy the data. 3526 self.interpreter.value.copy(pipe_from='R2eff', pipe_to=pipe_name, param='r2eff') 3527 3528 # Alias the spins. 3529 spin1 = cdp.mol[0].res[0].spin[0] 3530 spin2 = cdp.mol[0].res[1].spin[0] 3531 3532 # The R20 keys. 3533 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6) 3534 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6) 3535 3536 # Set the initial parameter values. 3537 spin1.r2 = {r20_key1: 9.9963793866185, r20_key2: 15.0056724422684} 3538 spin1.pA = 0.779782428085762 3539 spin1.dw = 7.57855284496424 3540 spin1.kex = 1116.7911285203 3541 spin2.r2 = {r20_key1: 11.9983346935434, r20_key2: 18.0076097513337} 3542 spin2.pA = 0.826666229688602 3543 spin2.dw = 9.5732624231366 3544 spin2.kex = 1380.46162655657 3545 3546 # Low precision optimisation. 3547 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1) 3548 3549 # Printout. 3550 print("\n\nOptimised parameters:\n") 3551 print("%-20s %-20s %-20s" % ("Parameter", "Value (:1)", "Value (:2)")) 3552 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin1.r2[r20_key1], spin2.r2[r20_key1])) 3553 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin1.r2[r20_key2], spin2.r2[r20_key2])) 3554 print("%-20s %20.15g %20.15g" % ("pA", spin1.pA, spin2.pA)) 3555 print("%-20s %20.15g %20.15g" % ("dw", spin1.dw, spin2.dw)) 3556 print("%-20s %20.15g %20.15g" % ("kex", spin1.kex, spin2.kex)) 3557 print("%-20s %20.15g %20.15g\n" % ("chi2", spin1.chi2, spin2.chi2)) 3558 3559 # Checks for residue :1. 3560 self.assertAlmostEqual(spin1.r2[r20_key1], 8.50207717367548, 4) 3561 self.assertAlmostEqual(spin1.r2[r20_key2], 13.4680429589972, 4) 3562 self.assertAlmostEqual(spin1.pA, 0.864523128842393, 4) 3563 self.assertAlmostEqual(spin1.dw, 8.85204828994151, 4) 3564 self.assertAlmostEqual(spin1.kex/1000, 1199.56359549637/1000, 4) 3565 self.assertAlmostEqual(spin1.chi2, 2.99182130153514, 4) 3566 3567 # Checks for residue :2. 3568 self.assertAlmostEqual(spin2.r2[r20_key1], 10.1334196530849, 4) 3569 self.assertAlmostEqual(spin2.r2[r20_key2], 16.140167863407, 4) 3570 self.assertAlmostEqual(spin2.pA, 0.829988381197468, 4) 3571 self.assertAlmostEqual(spin2.dw, 9.5657894936005, 4) 3572 self.assertAlmostEqual(spin2.kex/1000, 1404.76852145933/1000, 4) 3573 self.assertAlmostEqual(spin2.chi2, 0.000150052743893402, 4)
3574 3575
3576 - def test_tp02_data_to_mp05(self):
3577 """Test the dispersion 'MP05' model fitting against the 'TP02' test data.""" 3578 3579 # Fixed time variable and the models. 3580 ds.fixed = True 3581 ds.models = ['R2eff', 'MP05'] 3582 3583 # Execute the script. 3584 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_off_res_tp02.py') 3585 3586 # The original TP02 parameters. 3587 #r1rho_prime = [[10.0, 15.0], [12.0, 18.0]] 3588 #pA = 0.7654321 3589 #kex = 1234.56789 3590 #delta_omega = [7.0, 9.0] 3591 3592 # The equivalent MP05 parameters. 3593 r1rho_prime = [[10.0058087306952, 15.0058071785643], [11.9997883441526, 17.9972824143268]] 3594 pA = [0.775054986621315, 0.806128964050712] 3595 kex = [1235.20228577117, 1220.23684410068] 3596 delta_omega = [7.08193971314044, 9.69856821121164] 3597 chi2 = [0.0370400968687155, 8.28321387676908e-06] 3598 3599 # Alias the spins. 3600 spin1 = cdp.mol[0].res[0].spin[0] 3601 spin2 = cdp.mol[0].res[1].spin[0] 3602 3603 # The R20 keys. 3604 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6) 3605 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6) 3606 3607 # Printout. 3608 print("\n\nOptimised parameters:\n") 3609 print("%-20s %-20s %-20s" % ("Parameter", "Value (:1)", "Value (:2)")) 3610 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin1.r2[r20_key1], spin2.r2[r20_key1])) 3611 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin1.r2[r20_key2], spin2.r2[r20_key2])) 3612 print("%-20s %20.15g %20.15g" % ("pA", spin1.pA, spin2.pA)) 3613 print("%-20s %20.15g %20.15g" % ("dw", spin1.dw, spin2.dw)) 3614 print("%-20s %20.15g %20.15g" % ("kex", spin1.kex, spin2.kex)) 3615 print("%-20s %20.15g %20.15g\n" % ("chi2", spin1.chi2, spin2.chi2)) 3616 3617 # Switch to the 'MP05' model data pipe, then check for each spin. 3618 self.interpreter.pipe.switch('MP05 - relax_disp') 3619 spin_index = 0 3620 for spin, spin_id in spin_loop(return_id=True): 3621 # Printout. 3622 print("\nSpin %s." % spin_id) 3623 3624 # Check the fitted parameters. 3625 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index][0]/10, 4) 3626 self.assertAlmostEqual(spin.r2[r20_key2]/10, r1rho_prime[spin_index][1]/10, 4) 3627 self.assertAlmostEqual(spin.pA, pA[spin_index], 3) 3628 self.assertAlmostEqual(spin.dw, delta_omega[spin_index], 3) 3629 self.assertAlmostEqual(spin.kex/1000.0, kex[spin_index]/1000.0, 3) 3630 self.assertAlmostEqual(spin.chi2, chi2[spin_index], 3) 3631 3632 # Increment the spin index. 3633 spin_index += 1
3634 3635
3636 - def test_tp02_data_to_tap03(self):
3637 """Test the dispersion 'TAP03' model fitting against the 'TP02' test data.""" 3638 3639 # Fixed time variable and the models. 3640 ds.fixed = True 3641 ds.models = ['R2eff', 'TAP03'] 3642 3643 # Execute the script. 3644 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_off_res_tp02.py') 3645 3646 # The original TP02 parameters. 3647 #r1rho_prime = [[10.0, 15.0], [12.0, 18.0]] 3648 #pA = 0.7654321 3649 #kex = 1234.56789 3650 #delta_omega = [7.0, 9.0] 3651 3652 # The equivalent TAP03 parameters. 3653 r1rho_prime = [[10.0058156951248, 15.0058184739705], [11.9997721585529, 17.9972521618894]] 3654 pA = [0.775042773953145, 0.80618481966515] 3655 kex = [1235.20914100608, 1220.44317542746] 3656 delta_omega = [7.08176850835834, 9.69883920692148] 3657 chi2 = [0.0371366837334911, 8.45422574594191e-06] 3658 3659 # Alias the spins. 3660 spin1 = cdp.mol[0].res[0].spin[0] 3661 spin2 = cdp.mol[0].res[1].spin[0] 3662 3663 # The R20 keys. 3664 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6) 3665 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6) 3666 3667 # Printout. 3668 print("\n\nOptimised parameters:\n") 3669 print("%-20s %-20s %-20s" % ("Parameter", "Value (:1)", "Value (:2)")) 3670 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin1.r2[r20_key1], spin2.r2[r20_key1])) 3671 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin1.r2[r20_key2], spin2.r2[r20_key2])) 3672 print("%-20s %20.15g %20.15g" % ("pA", spin1.pA, spin2.pA)) 3673 print("%-20s %20.15g %20.15g" % ("dw", spin1.dw, spin2.dw)) 3674 print("%-20s %20.15g %20.15g" % ("kex", spin1.kex, spin2.kex)) 3675 print("%-20s %20.15g %20.15g\n" % ("chi2", spin1.chi2, spin2.chi2)) 3676 3677 # Switch to the 'MP05' model data pipe, then check for each spin. 3678 self.interpreter.pipe.switch('TAP03 - relax_disp') 3679 spin_index = 0 3680 for spin, spin_id in spin_loop(return_id=True): 3681 # Printout. 3682 print("\nSpin %s." % spin_id) 3683 3684 # Check the fitted parameters. 3685 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index][0]/10, 4) 3686 self.assertAlmostEqual(spin.r2[r20_key2]/10, r1rho_prime[spin_index][1]/10, 4) 3687 self.assertAlmostEqual(spin.pA, pA[spin_index], 3) 3688 self.assertAlmostEqual(spin.dw, delta_omega[spin_index], 3) 3689 self.assertAlmostEqual(spin.kex/1000.0, kex[spin_index]/1000.0, 3) 3690 self.assertAlmostEqual(spin.chi2, chi2[spin_index], 3) 3691 3692 # Increment the spin index. 3693 spin_index += 1
3694 3695
3696 - def test_tp02_data_to_tp02(self):
3697 """Test the relaxation dispersion 'TP02' model curve fitting to fixed time synthetic data.""" 3698 3699 # Fixed time variable. 3700 ds.fixed = True 3701 3702 # Execute the script. 3703 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_off_res_tp02.py') 3704 3705 # The original parameters. 3706 r1rho_prime = [[10.0, 15.0], [12.0, 18.0]] 3707 pA = 0.7654321 3708 kex = 1234.56789 3709 delta_omega = [7.0, 9.0] 3710 3711 # The R20 keys. 3712 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6) 3713 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6) 3714 3715 # Switch to the 'TP02' model data pipe, then check for each spin. 3716 self.interpreter.pipe.switch('TP02 - relax_disp') 3717 spin_index = 0 3718 for spin, spin_id in spin_loop(return_id=True): 3719 # Printout. 3720 print("\nSpin %s." % spin_id) 3721 3722 # Check the fitted parameters. 3723 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index][0]/10, 4) 3724 self.assertAlmostEqual(spin.r2[r20_key2]/10, r1rho_prime[spin_index][1]/10, 4) 3725 self.assertAlmostEqual(spin.dw, delta_omega[spin_index], 3) 3726 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 3) 3727 3728 # Increment the spin index. 3729 spin_index += 1
3730 3731
3733 """System test of the value.write function to write intensities for an R1rho setup. 3734 This system test is to make sure, that modifying the API for special parameters theta and w_eff does not alter the functionality value.write. 3735 3736 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}. 3737 """ 3738 3739 # Load the state. 3740 statefile = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2' 3741 self.interpreter.state.load(statefile, force=True) 3742 3743 # Set filepaths. 3744 int_filepath = ds.tmpdir+sep+'int.out' 3745 3746 # Write out the intensity parameter file. 3747 # The writing out of intensity file is to make sure the API function retains its function after modification for special parameters. 3748 self.interpreter.value.write(param='intensities', file='int.out', dir=ds.tmpdir, scaling=1.0, force=True) 3749 3750 # Test the file exists. 3751 self.assert_(access(int_filepath, F_OK)) 3752 3753 # Open the files for testing. 3754 int_file = open(int_filepath, 'r') 3755 3756 # Loop over the intensity file to test values. 3757 for line in int_file: 3758 # Skip lines starting with #. 3759 if line[0] == "#": 3760 continue 3761 3762 # Split the line 3763 linesplit = line.split() 3764 3765 # Assume values 3766 if linesplit[0] == "None" and linesplit[1] == "5" and linesplit[2] == "I": 3767 self.assertEqual(linesplit[5], "115571.4") 3768 elif linesplit[0] == "None" and linesplit[1] == "6" and linesplit[2] == "S": 3769 self.assertEqual(linesplit[5], "68377.52") 3770 elif linesplit[0] == "None" and linesplit[1] == "8" and linesplit[2] == "S": 3771 self.assertEqual(linesplit[5], "9141.689") 3772 elif linesplit[0] == "None" and linesplit[1] == "9" and linesplit[2] == "A": 3773 self.assertEqual(linesplit[5], "29123.77") 3774 elif linesplit[0] == "None" and linesplit[1] == "10" and linesplit[2] == "L": 3775 self.assertEqual(linesplit[5], "58914.94") 3776 3777 # Close files 3778 int_file.close()
3779 3780
3782 """System test of the value.write function to write return values of theta from calc_rotating_frame_params() function for an R1rho setup. 3783 3784 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}. 3785 """ 3786 3787 # Load the state. 3788 statefile = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2' 3789 self.interpreter.state.load(statefile, force=True) 3790 3791 # Set filepaths. 3792 theta_filepath = ds.tmpdir+sep+'theta.out' 3793 3794 # Write out the theta parameter file. 3795 self.interpreter.value.write(param='theta', file='theta.out', dir=ds.tmpdir, scaling=1.0, force=True) 3796 3797 # Test the file exists. 3798 self.assert_(access(theta_filepath, F_OK)) 3799 3800 # Open the files for testing. 3801 theta_file = open(theta_filepath, 'r') 3802 3803 # Loop over the theta file to test values. 3804 for line in theta_file: 3805 # Skip lines starting with #. 3806 if line[0] == "#": 3807 continue 3808 # Print lines, not including newline character. 3809 print(line[:-1]) 3810 3811 # Split the line 3812 linesplit = line.split() 3813 3814 # Assume values 3815 if linesplit[0] == "None" and linesplit[1] == "5" and linesplit[2] == "I": 3816 self.assertNotEqual(linesplit[5], "None") 3817 elif linesplit[0] == "None" and linesplit[1] == "6" and linesplit[2] == "S": 3818 self.assertNotEqual(linesplit[5], "None") 3819 elif linesplit[0] == "None" and linesplit[1] == "8" and linesplit[2] == "S": 3820 self.assertNotEqual(linesplit[5], "None") 3821 elif linesplit[0] == "None" and linesplit[1] == "9" and linesplit[2] == "A": 3822 self.assertNotEqual(linesplit[5], "None") 3823 elif linesplit[0] == "None" and linesplit[1] == "10" and linesplit[2] == "L": 3824 self.assertNotEqual(linesplit[5], "None") 3825 3826 # Close files 3827 theta_file.close()
3828 3829
3831 """System test of the value.write function to write return values of w_eff from calc_rotating_frame_params() function for an R1rho setup. 3832 3833 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}. 3834 """ 3835 3836 # Load the state. 3837 statefile = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2' 3838 self.interpreter.state.load(statefile, force=True) 3839 3840 # Set filepaths. 3841 w_eff_filepath = ds.tmpdir+sep+'w_eff.out' 3842 3843 # Write out the w_eff parameter file. 3844 self.interpreter.value.write(param='w_eff', file='w_eff.out', dir=ds.tmpdir, scaling=1.0, force=True) 3845 3846 # Test the file exists. 3847 self.assert_(access(w_eff_filepath, F_OK)) 3848 3849 # Open the files for testing. 3850 w_eff_file = open(w_eff_filepath, 'r') 3851 3852 # Loop over the w_eff file to test values. 3853 for line in w_eff_file: 3854 # Skip lines starting with #. 3855 if line[0] == "#": 3856 continue 3857 # Print lines, not including newline character. 3858 print(line[:-1]) 3859 3860 # Split the line 3861 linesplit = line.split() 3862 3863 # Assume values 3864 if linesplit[0] == "None" and linesplit[1] == "5" and linesplit[2] == "I": 3865 self.assertNotEqual(linesplit[5], "None") 3866 elif linesplit[0] == "None" and linesplit[1] == "6" and linesplit[2] == "S": 3867 self.assertNotEqual(linesplit[5], "None") 3868 elif linesplit[0] == "None" and linesplit[1] == "8" and linesplit[2] == "S": 3869 self.assertNotEqual(linesplit[5], "None") 3870 elif linesplit[0] == "None" and linesplit[1] == "9" and linesplit[2] == "A": 3871 self.assertNotEqual(linesplit[5], "None") 3872 elif linesplit[0] == "None" and linesplit[1] == "10" and linesplit[2] == "L": 3873 self.assertNotEqual(linesplit[5], "None") 3874 3875 # Close files 3876 w_eff_file.close()
3877 3878
3880 """System test of the auto_analysis value.write function to write theta and w_eff values for an R1rho setup. 3881 3882 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}. 3883 """ 3884 3885 # Load the state. 3886 statefile = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344.bz2' 3887 self.interpreter.state.load(statefile, force=True) 3888 3889 # Set pipe name, bundle and type. 3890 pipe_name = 'base pipe' 3891 pipe_bundle = 'relax_disp' 3892 pipe_type= 'relax_disp' 3893 3894 # The path to the data files. 3895 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013' 3896 3897 # Deselect all spins 3898 self.interpreter.deselect.all() 3899 3900 # Specify spins to be selected. 3901 select_spin_ids = [ 3902 ":13@N", 3903 ":15@N", 3904 ":16@N", 3905 ":25@N", 3906 ":26@N", 3907 ":28@N", 3908 ":39@N", 3909 ":40@N", 3910 ":41@N", 3911 ":43@N", 3912 ":44@N", 3913 ":45@N", 3914 ":49@N", 3915 ":52@N", 3916 ":53@N"] 3917 3918 # Reverse the selection for the spins. 3919 for curspin in select_spin_ids: 3920 print("Selecting spin %s"%curspin) 3921 self.interpreter.deselect.reverse(spin_id=curspin) 3922 3923 # Read the R1 data 3924 self.interpreter.relax_data.read(ri_id='R1', ri_type='R1', frq=cdp.spectrometer_frq_list[0], file='R1_fitted_values.txt', dir=data_path, mol_name_col=1, res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7) 3925 3926 # The dispersion models. 3927 MODELS = ['R2eff'] 3928 3929 # The grid search size (the number of increments per dimension). 3930 GRID_INC = 4 3931 3932 # The number of Monte Carlo simulations to be used for error analysis at the end of the analysis. 3933 MC_NUM = 3 3934 3935 # Model selection technique. 3936 MODSEL = 'AIC' 3937 3938 # Execute the auto-analysis (fast). 3939 # Standard parameters are: func_tol=1e-25, grad_tol=None, max_iter=10000000, 3940 OPT_FUNC_TOL = 1e-1 3941 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL 3942 OPT_MAX_ITERATIONS = 1000 3943 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS 3944 3945 # Run the analysis. 3946 relax_disp.Relax_disp(pipe_name=pipe_name, pipe_bundle=pipe_bundle, results_dir=ds.tmpdir, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL) 3947 3948 ## Check for file creation 3949 # Set filepaths. 3950 theta_filepath = ds.tmpdir+sep+MODELS[0]+sep+'theta.out' 3951 w_eff_filepath = ds.tmpdir+sep+MODELS[0]+sep+'w_eff.out' 3952 3953 # Test the files exists. 3954 self.assert_(access(theta_filepath, F_OK)) 3955 self.assert_(access(w_eff_filepath, F_OK)) 3956 3957 # Open the files for testing. 3958 theta_file = open(theta_filepath, 'r') 3959 theta_result = [ 3960 "# Parameter description: Rotating frame tilt angle : ( theta = arctan(w_1 / Omega) ) (rad).\n", 3961 "#\n", 3962 "# mol_name res_num res_name spin_num spin_name r1rho_799.77739910_118.078_1341.110 sd(r1rho_799.77739910_118.078_1341.110) r1rho_799.77739910_118.078_1648.500 sd(r1rho_799.77739910_118.078_1648.500) r1rho_799.77739910_118.078_431.000 sd(r1rho_799.77739910_118.078_431.000) r1rho_799.77739910_118.078_651.200 sd(r1rho_799.77739910_118.078_651.200) r1rho_799.77739910_118.078_800.500 sd(r1rho_799.77739910_118.078_800.500) r1rho_799.77739910_118.078_984.000 sd(r1rho_799.77739910_118.078_984.000) r1rho_799.77739910_124.247_1341.110 sd(r1rho_799.77739910_124.247_1341.110) r1rho_799.77739910_130.416_1341.110 sd(r1rho_799.77739910_130.416_1341.110) r1rho_799.77739910_130.416_1648.500 sd(r1rho_799.77739910_130.416_1648.500) r1rho_799.77739910_130.416_800.500 sd(r1rho_799.77739910_130.416_800.500) r1rho_799.77739910_142.754_1341.110 sd(r1rho_799.77739910_142.754_1341.110) r1rho_799.77739910_142.754_800.500 sd(r1rho_799.77739910_142.754_800.500) r1rho_799.77739910_179.768_1341.110 sd(r1rho_799.77739910_179.768_1341.110) r1rho_799.77739910_241.459_1341.110 sd(r1rho_799.77739910_241.459_1341.110) \n", 3963 "None 5 I None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3964 "None 6 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3965 "None 8 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3966 "None 9 A None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3967 "None 10 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3968 "None 11 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3969 "None 12 D None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3970 "None 13 L None N 1.83827367612531 None 1.79015307643158 None 2.2768687598681 None 2.08461171779445 None 2.00120623474388 None 1.92825070277699 None 1.47212860033516 None 1.12978017906854 None 1.20415336139956 None 0.901691390796334 None 0.687390207543568 None 0.455635480573046 None 0.281637123971289 None 0.138259661766539 None \n", 3971 "None 14 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3972 "None 15 R None N 1.58367544790673 None 1.58127411936947 None 1.61085209029811 None 1.59731540507347 None 1.59237108385522 None 1.58834866344307 None 1.2251048782537 None 0.938142786712004 None 1.03297495592991 None 0.683284686224254 None 0.594447788256641 None 0.383528609383686 None 0.262780814059893 None 0.133469839450564 None \n", 3973 "None 16 T None N 1.40984232256624 None 1.43947245672073 None 1.10299856647417 None 1.24811470332083 None 1.30521602599932 None 1.35302443831853 None 1.07923777467974 None 0.833345927788896 None 0.934350308974616 None 0.581325254389991 None 0.543659670184793 None 0.346238480454282 None 0.251454336191817 None 0.130436714663781 None \n", 3974 "None 17 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3975 "None 18 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3976 "None 19 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3977 "None 21 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3978 "None 24 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3979 "None 25 Q None N 1.81569700258844 None 1.77137827615015 None 2.23175875585624 None 2.04612705363098 None 1.9673155780155 None 1.89908711012298 None 1.44829660124856 None 1.11023386429581 None 1.18716091371256 None 0.877306975624962 None 0.677790118853413 None 0.447932002242236 None 0.279785379050945 None 0.137802891887767 None \n", 3980 "None 26 Q None N 1.61128821168674 None 1.60374392042003 None 1.69619923953765 None 1.65403989292986 None 1.63856717205868 None 1.62595755714564 None 1.24977859227795 None 0.956353494917591 None 1.04972090035774 None 0.702164059520172 None 0.603227813742091 None 0.390116910781037 None 0.264658552037535 None 0.133960994297096 None \n", 3981 "None 27 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3982 "None 28 Q None N 1.65182797011356 None 1.63676707684161 None 1.81830827892972 None 1.7365089711986 None 1.70601955220877 None 1.68102938663686 None 1.28685736157369 None 0.984047498595701 None 1.0749792109454 None 0.731585685663053 None 0.616577997665602 None 0.400219205533665 None 0.267471993812649 None 0.134690869499646 None \n", 3983 "None 29 V None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3984 "None 30 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3985 "None 31 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3986 "None 32 I None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3987 "None 33 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3988 "None 34 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3989 "None 35 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3990 "None 36 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3991 "None 38 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3992 "None 39 L None N 1.76426439181176 None 1.72885318885161 None 2.11826300085737 None 1.95430201082222 None 1.88794717058464 None 1.83172922971397 None 1.39549951193417 None 1.06783946148624 None 1.14997013232702 None 0.826128785942585 None 0.657105386950171 None 0.431542911580536 None 0.275725736430539 None 0.136791385554619 None \n", 3993 "None 40 M None N 1.5521741199158 None 1.55564594516135 None 1.51290906497298 None 1.53245929150759 None 1.53960430408466 None 1.54541832596591 None 1.19750223001929 None 0.917959090226757 None 1.01428385962747 None 0.662779584695967 None 0.584708929219264 None 0.376271266885303 None 0.260671619214194 None 0.132914250767089 None \n", 3994 "None 41 A None N 1.68339451828261 None 1.66252964414082 None 1.90911961276946 None 1.79959323497326 None 1.75801925517113 None 1.72370710837265 None 1.31646868936419 None 1.00647189763597 None 1.09525348649914 None 0.75605702767542 None 0.627395557358039 None 0.408481831044309 None 0.269716174238842 None 0.135267948387412 None \n", 3995 "None 42 A None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 3996 "None 43 F None N 1.58506597154432 None 1.58240542750302 None 1.61517196062351 None 1.60017740004898 None 1.59469990835425 None 1.59024353162528 None 1.22633651794829 None 0.939047922181951 None 1.03380990731605 None 0.684214484755514 None 0.594884298549546 None 0.383855128702894 None 0.262874695048502 None 0.13349447283116 None \n", 3997 "None 44 I None N 1.57575471961837 None 1.57483015671791 None 1.58622388390755 None 1.58100758841935 None 1.57910319967536 None 1.57755415552211 None 1.21811077066835 None 0.933010299763027 None 1.02823520295828 None 0.67802911457195 None 0.591972285081647 None 0.381678892926696 None 0.262247347241724 None 0.133329708422379 None \n", 3998 "None 45 K None N 1.77147501495754 None 1.73479633022489 None 2.13509660780385 None 1.96751045408372 None 1.89924480319914 None 1.84124387452692 None 1.40277881643715 None 1.07361367582571 None 1.15506365550891 None 0.832963505534767 None 0.659913187081268 None 0.433751178249555 None 0.276282572106685 None 0.13693095791902 None \n", 3999 "None 46 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4000 "None 48 T None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4001 "None 49 A None N 2.00297059962685 None 1.92978318052058 None 2.53305709323468 None 2.33052197276846 None 2.22870514722639 None 2.13201782446864 None 1.6587904412969 None 1.29333162369472 None 1.34311052758116 None 1.12559033900783 None 0.770195063841652 None 0.524846264860003 None 0.296857751274362 None 0.141908833673671 None \n", 4002 "None 50 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4003 "None 51 Y None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4004 "None 52 V None N 1.82421571143794 None 1.77845404105203 None 2.24910726268822 None 2.06078232916932 None 1.98017451806059 None 1.91012195713554 None 1.45724107606646 None 1.11753869321304 None 1.19352234944057 None 0.886361068343012 None 0.681372607920812 None 0.450799407357501 None 0.280478735779163 None 0.137974257665877 None \n", 4005 "None 53 A None N 2.05019708195234 None 1.97089957318506 None 2.58789168363698 None 2.39027806684801 None 2.28731354878582 None 2.1872118539319 None 1.7165709935896 None 1.34832362477229 None 1.38879751095815 None 1.2085314357749 None 0.799450059125864 None 0.550583841461621 None 0.30195492609136 None 0.143090604877102 None \n", 4006 "None 54 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4007 "None 55 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4008 "None 57 G None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4009 "None 58 M None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4010 "None 59 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n" ] 4011 # Check the created theta file. 4012 lines = theta_file.readlines() 4013 for i in range(len(lines)): 4014 # Test lines starting with # 4015 if theta_result[i][0] == "#": 4016 self.assertEqual(theta_result[i], lines[i]) 4017 # If the line is equal each other, make a line comparison. This should catch lines with None values. 4018 if theta_result[i] == lines[i]: 4019 self.assertEqual(theta_result[i], lines[i]) 4020 # If the line is not equal each other, make a slower comparison of values. 4021 else: 4022 # Print lines if they don't match. To help find differences. 4023 print(theta_result[i]) 4024 print(lines[i]) 4025 4026 # First test first 62 characters containing spin information 4027 self.assertEqual(theta_result[i][:62], lines[i][:62]) 4028 4029 # Make a string split after 62 characters. Select each second element, so None values are skipped. 4030 theta_result_s = theta_result[i][62:].split()[::2] 4031 print(theta_result_s ) 4032 lines_s = lines[i][62:].split()[::2] 4033 print(lines_s) 4034 # Loop over the value elements 4035 for j in range(len(lines_s)): 4036 print(theta_result_s[j], lines_s[j]) 4037 # Assume a precision to digits. 4038 self.assertAlmostEqual(float(theta_result_s[j]), float(lines_s[j]), 14) 4039 4040 # Close file 4041 theta_file.close() 4042 4043 w_eff_file = open(w_eff_filepath, 'r') 4044 w_eff_result = [ 4045 "# Parameter description: Effective field in rotating frame : ( w_eff = sqrt(Omega^2 + w_1^2) ) (rad.s^-1).\n", 4046 "#\n", 4047 "# mol_name res_num res_name spin_num spin_name r1rho_799.77739910_118.078_1341.110 sd(r1rho_799.77739910_118.078_1341.110) r1rho_799.77739910_118.078_1648.500 sd(r1rho_799.77739910_118.078_1648.500) r1rho_799.77739910_118.078_431.000 sd(r1rho_799.77739910_118.078_431.000) r1rho_799.77739910_118.078_651.200 sd(r1rho_799.77739910_118.078_651.200) r1rho_799.77739910_118.078_800.500 sd(r1rho_799.77739910_118.078_800.500) r1rho_799.77739910_118.078_984.000 sd(r1rho_799.77739910_118.078_984.000) r1rho_799.77739910_124.247_1341.110 sd(r1rho_799.77739910_124.247_1341.110) r1rho_799.77739910_130.416_1341.110 sd(r1rho_799.77739910_130.416_1341.110) r1rho_799.77739910_130.416_1648.500 sd(r1rho_799.77739910_130.416_1648.500) r1rho_799.77739910_130.416_800.500 sd(r1rho_799.77739910_130.416_800.500) r1rho_799.77739910_142.754_1341.110 sd(r1rho_799.77739910_142.754_1341.110) r1rho_799.77739910_142.754_800.500 sd(r1rho_799.77739910_142.754_800.500) r1rho_799.77739910_179.768_1341.110 sd(r1rho_799.77739910_179.768_1341.110) r1rho_799.77739910_241.459_1341.110 sd(r1rho_799.77739910_241.459_1341.110) \n", 4048 "None 5 I None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4049 "None 6 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4050 "None 8 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4051 "None 9 A None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4052 "None 10 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4053 "None 11 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4054 "None 12 D None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4055 "None 13 L None N 8737.12883908829 None 10612.1226552258 None 3558.93734069587 None 4698.27194621826 None 5534.46153956037 None 6599.82570817753 None 8467.62674839481 None 9318.00441649087 None 11095.2662520767 None 6412.33580591254 None 13279.9803044242 None 11430.254637056 None 30318.7268264644 None 61141.1080046448 None \n", 4056 "None 14 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4057 "None 15 R None N 8427.14155005377 None 10358.3995676635 None 2710.22680763322 None 4093.04942975722 None 5030.86065069262 None 6183.60685459024 None 8956.28403254202 None 10448.6627754369 None 12060.4428066937 None 7966.64282975241 None 15045.8392092364 None 13441.3586252373 None 32438.4764809909 None 63321.5201471181 None \n", 4058 "None 16 T None N 8536.7818857229 None 10447.792678989 None 3034.01707453628 None 4314.2767521567 None 5212.43600885913 None 6332.21319855067 None 9558.14311447582 None 11384.2336494604 None 12879.4604966293 None 9159.34604475399 None 16290.1746838959 None 14821.0200530829 None 33866.5933527757 None 64785.3205696403 None \n", 4059 "None 17 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4060 "None 18 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4061 "None 19 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4062 "None 21 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4063 "None 24 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4064 "None 25 Q None N 8685.60895531182 None 10569.7459677762 None 3430.51272680396 None 4601.75421490393 None 5452.76508815826 None 6531.46859076009 None 8490.06475886501 None 9406.58372902508 None 11169.7602637607 None 6540.38696356753 None 13437.7348017798 None 11613.1632549021 None 30514.0741594726 None 61342.4792156782 None \n", 4065 "None 26 Q None N 8433.35533683544 None 10363.4554631194 None 2729.48656005151 None 4105.82770792005 None 5041.26238350827 None 6192.07245313098 None 8880.08366342131 None 10312.6868786802 None 11942.8320576165 None 7787.44854491812 None 14853.4987024375 None 13225.7048162038 None 32213.6690023282 None 63090.7407990801 None \n", 4066 "None 27 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4067 "None 28 Q None N 8454.18308422202 None 10380.4112885894 None 2793.17494362899 None 4148.43953208179 None 5076.02756135055 None 6220.40920270029 None 8777.91538040813 None 10118.8737706315 None 11775.8792998529 None 7528.90766101027 None 14572.4015102398 None 12909.211050939 None 31882.8171856889 None 62750.9120842199 None \n", 4068 "None 29 V None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4069 "None 30 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4070 "None 31 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4071 "None 32 I None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4072 "None 33 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4073 "None 34 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4074 "None 35 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4075 "None 36 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4076 "None 38 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4077 "None 39 L None N 8586.6405431352 None 10488.5710521378 None 3171.59430904777 None 4412.11227722123 None 5293.69814015286 None 6399.27143075725 None 8557.58926327909 None 9617.45773774313 None 11347.9169998729 None 6840.20010813426 None 13795.1250622375 None 12024.9041436853 None 30951.651485352 None 61793.2130509111 None \n", 4078 "None 40 M None N 8427.90394711227 None 10359.0198301036 None 2712.59646573568 None 4094.61889210019 None 5032.13762965554 None 6184.6458240746 None 9049.68452800053 None 10607.7913029633 None 12198.5639821231 None 8174.23271685285 None 15266.4924700447 None 13687.9010998756 None 32694.9043143038 None 63584.6371927381 None \n", 4079 "None 41 A None N 8480.14299737436 None 10401.5648897003 None 2870.79081440785 None 4201.09083283266 None 5119.14733505123 None 6255.64579267482 None 8706.50768957471 None 9972.71017314947 None 11650.5225246067 None 7331.28858930568 None 14354.1616183112 None 12662.3378547029 None 31623.9195264738 None 62484.8290612112 None \n", 4080 "None 42 A None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4081 "None 43 F None N 8427.30062786474 None 10358.5289868368 None 2710.7214015056 None 4093.37694357637 None 5031.12711571215 None 6183.82364721878 None 8952.31975962078 None 10441.7375680915 None 12054.4435931163 None 7957.55789315654 None 15036.1316712316 None 13430.4914212645 None 32427.1596037519 None 63309.9050677925 None \n", 4082 "None 44 I None N 8426.54623319716 None 10357.9152496503 None 2708.3751705368 None 4091.82359712664 None 5029.86337809029 None 6182.79552045043 None 8979.12144335458 None 10488.2688526334 None 12094.7720286018 None 8018.51779989075 None 15101.1843990883 None 13503.2816173444 None 32502.9389163062 None 63387.6763306952 None \n", 4083 "None 45 K None N 8599.01176345321 None 10498.7013581079 None 3204.93649737055 None 4436.14046641897 None 5313.74138343704 None 6415.86177652694 None 8546.79665373249 None 9587.16245449134 None 11322.2529042385 None 6797.53838612575 None 13745.1536613763 None 11967.5433300612 None 30890.8603419261 None 61730.6213936947 None \n", 4084 "None 46 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4085 "None 48 T None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4086 "None 49 A None N 9279.63849130869 None 11063.0654625247 None 4737.11992391463 None 5643.40583860235 None 6356.45614406507 None 7302.87406141381 None 8459.17105047661 None 8761.54554569995 None 10632.2343488142 None 5572.92782399155 None 12102.1714908775 None 10037.6988885228 None 28806.6916858172 None 59579.0348769179 None \n", 4087 "None 50 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4088 "None 51 Y None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4089 "None 52 V None N 8704.45610117774 None 10585.2389163429 None 3477.9549539207 None 4637.22923167743 None 5482.73656118686 None 6556.5108895527 None 8481.06470969555 None 9372.86414918436 None 11141.3782476763 None 6491.79686536093 None 13378.2843939736 None 11544.3205736882 None 30440.62308788 None 61266.7742546508 None \n", 4090 "None 53 A None N 9497.02860450276 None 11246.0339326126 None 5149.96766581255 None 5994.15475647208 None 6669.81232845336 None 7577.19152075731 None 8516.77431951689 None 8639.36099840319 None 10531.7750336522 None 5378.79193153767 None 11752.8060152439 None 9613.59939949642 None 28334.9153747994 None 59090.2988815445 None \n", 4091 "None 54 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4092 "None 55 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4093 "None 57 G None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4094 "None 58 M None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n", 4095 "None 59 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n" 4096 ] 4097 4098 # Check the created w_eff file. 4099 lines = w_eff_file.readlines() 4100 for i in range(len(lines)): 4101 # Test lines starting with # 4102 if w_eff_result[i][0] == "#": 4103 self.assertEqual(w_eff_result[i], lines[i]) 4104 # If the line is equal each other, make a line comparison. This should catch lines with None values. 4105 if w_eff_result[i] == lines[i]: 4106 self.assertEqual(w_eff_result[i], lines[i]) 4107 # If the line is not equal each other, make a slower comparison of values. 4108 else: 4109 # Print lines if they don't match. To help find differences. 4110 print(w_eff_result[i]) 4111 print(lines[i]) 4112 4113 # First test first 62 characters containing spin information 4114 self.assertEqual(w_eff_result[i][:62], lines[i][:62]) 4115 4116 # Make a string split after 62 characters. Select each second element, so None values are skipped. 4117 w_eff_result_s = w_eff_result[i][62:].split()[::2] 4118 print(w_eff_result_s ) 4119 lines_s = lines[i][62:].split()[::2] 4120 print(lines_s) 4121 # Loop over the value elements 4122 for j in range(len(lines_s)): 4123 print(w_eff_result_s[j], lines_s[j]) 4124 # Assume a precision to digits. 4125 self.assertAlmostEqual(float(w_eff_result_s[j]), float(lines_s[j]), 14) 4126 4127 # Close file 4128 w_eff_file.close()
4129