Author: tlinnet Date: Mon Aug 25 01:50:58 2014 New Revision: 25239 URL: http://svn.gna.org/viewcvs/relax?rev=25239&view=rev Log: Added systemtest Relax_disp.test_estimate_r2eff_error(). This is to get insight in the error difference between 2000 monto carlo simulations and then scipy.optimize.leastsq. R1rho at 799.8 MHz, for offset=118.078 ppm and dispersion point 431.0. r2eff=8.646/8.646 r2eff_err=0.0348/0.0692 i0=202664.191/202664.191 i0_err=699.6443/712.4201 R1rho at 799.8 MHz, for offset=118.078 ppm and dispersion point 651.2. r2eff=10.377/10.377 r2eff_err=0.0403/0.0810 i0=206049.558/206049.558 i0_err=776.4215/782.1833 R1rho at 799.8 MHz, for offset=118.078 ppm and dispersion point 800.5. r2eff=10.506/10.506 r2eff_err=0.0440/0.0853 i0=202586.332/202586.332 i0_err=763.9678/758.7052 R1rho at 799.8 MHz, for offset=118.078 ppm and dispersion point 984.0. r2eff=10.903/10.903 r2eff_err=0.0476/0.0922 i0=203455.021/203455.021 i0_err=837.8779/828.7280 R1rho at 799.8 MHz, for offset=118.078 ppm and dispersion point 1341.1. r2eff=10.684/10.684 r2eff_err=0.0446/0.0853 i0=218670.412/218670.411 i0_err=850.0210/830.9558 R1rho at 799.8 MHz, for offset=118.078 ppm and dispersion point 1648.5. r2eff=10.501/10.501 r2eff_err=0.0371/0.0742 i0=206502.512/206502.512 i0_err=794.0523/772.9843 R1rho at 799.8 MHz, for offset=124.247 ppm and dispersion point 1341.1. r2eff=11.118/11.118 r2eff_err=0.0413/0.0827 i0=216447.241/216447.241 i0_err=784.6562/788.0384 R1rho at 799.8 MHz, for offset=130.416 ppm and dispersion point 800.5. r2eff=7.866/7.866 r2eff_err=0.0347/0.0695 i0=211869.715/211869.715 i0_err=749.2776/763.6930 R1rho at 799.8 MHz, for offset=130.416 ppm and dispersion point 1341.1. r2eff=9.259/9.259 r2eff_err=0.0331/0.0661 i0=217703.151/217703.151 i0_err=682.2137/685.5838 R1rho at 799.8 MHz, for offset=130.416 ppm and dispersion point 1648.5. r2eff=9.565/9.565 r2eff_err=0.0373/0.0745 i0=211988.939/211988.939 i0_err=839.0313/827.0373 R1rho at 799.8 MHz, for offset=142.754 ppm and dispersion point 800.5. r2eff=3.240/3.240 r2eff_err=0.0127/0.0253 i0=214417.382/214417.382 i0_err=595.8865/613.4378 R1rho at 799.8 MHz, for offset=142.754 ppm and dispersion point 1341.1. r2eff=5.084/5.084 r2eff_err=0.0177/0.0352 i0=226358.691/226358.691 i0_err=660.5314/655.7670 R1rho at 799.8 MHz, for offset=179.768 ppm and dispersion point 1341.1. r2eff=2.208/2.208 r2eff_err=0.0091/0.0178 i0=228620.553/228620.553 i0_err=564.8353/560.0873 R1rho at 799.8 MHz, for offset=241.459 ppm and dispersion point 1341.1. r2eff=1.711/1.711 r2eff_err=0.0077/0.0155 i0=224087.486/224087.486 i0_err=539.4300/546.4217 task #7822(https://gna.org/task/index.php?7822): Implement user function to estimate R2eff and associated errors for exponential curve fitting. Modified: trunk/test_suite/system_tests/relax_disp.py Modified: trunk/test_suite/system_tests/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/trunk/test_suite/system_tests/relax_disp.py?rev=25239&r1=25238&r2=25239&view=diff ============================================================================== --- trunk/test_suite/system_tests/relax_disp.py (original) +++ trunk/test_suite/system_tests/relax_disp.py Mon Aug 25 01:50:58 2014 @@ -2726,6 +2726,94 @@ # Verify the data. self.verify_r1rho_kjaergaard_missing_r1(models=MODELS, result_dir_name=result_dir_name, do_assert=False) + + + def test_estimate_r2eff_error(self): + """Test the user function for estimating R2eff and associated errors for exponential curve fitting. + This is compared with a run where erros are estimated by 2000 Monte Carlo simulations. + + This follows Task 7822. + U{task #7822<https://gna.org/task/index.php?7822>}: Implement user function to estimate R2eff and associated errors for exponential curve fitting. + + This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}. + Optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'DPL' model. + """ + + # Define data path. + prev_data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013' +sep+ "check_graphs" +sep+ "mc_2000" +sep+ "R2eff" + + # Create pipe. + self.interpreter.pipe.create('MC_2000', 'relax_disp') + + # Read results for 2000 MC simulations. + self.interpreter.results.read(prev_data_path + sep + 'results') + + # Start dic. + my_dic = {} + param_key_list = [] + + for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True): + # Add key to dic. + my_dic[spin_id] = {} + + # Generate spin string. + spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn) + + for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True): + # Generate the param_key. + param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point) + + # Append key. + param_key_list.append(param_key) + + # Add key to dic. + my_dic[spin_id][param_key] = {} + + # Get the value. + r2eff = getattr(cur_spin, 'r2eff')[param_key] + r2eff_err = getattr(cur_spin, 'r2eff_err')[param_key] + i0 = getattr(cur_spin, 'i0')[param_key] + i0_err = getattr(cur_spin, 'i0_err')[param_key] + + # Save to dic. + my_dic[spin_id][param_key]['r2eff'] = r2eff + my_dic[spin_id][param_key]['r2eff_err'] = r2eff_err + my_dic[spin_id][param_key]['i0'] = i0 + my_dic[spin_id][param_key]['i0_err'] = i0_err + + # A new data pipe. + self.interpreter.pipe.copy(pipe_from='MC_2000', pipe_to='r2eff_est') + self.interpreter.pipe.switch(pipe_name='r2eff_est') + + # Set the model. + self.interpreter.relax_disp.select_model(MODEL_R2EFF) + + # Estimate R2eff and errors. + self.interpreter.relax_disp.r2eff_estimate(verbosity=0) + + for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True): + # Generate spin string. + spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn) + + for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True): + # Generate the param_key. + param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point) + + # Get the value. + r2eff_est = getattr(cur_spin, 'r2eff')[param_key] + r2eff_err_est = getattr(cur_spin, 'r2eff_err')[param_key] + i0_est = getattr(cur_spin, 'i0')[param_key] + i0_err_est = getattr(cur_spin, 'i0_err')[param_key] + + # Get from dic. + r2eff = my_dic[spin_id][param_key]['r2eff'] + r2eff_err = my_dic[spin_id][param_key]['r2eff_err'] + i0 = my_dic[spin_id][param_key]['i0'] + i0_err = my_dic[spin_id][param_key]['i0_err'] + + print("%s at %3.1f MHz, for offset=%3.3f ppm and dispersion point %-5.1f." % (exp_type, frq/1E6, offset, point) ) + print("r2eff=%3.3f/%3.3f r2eff_err=%3.4f/%3.4f" % (r2eff, r2eff_est, r2eff_err, r2eff_err_est) ), + print("i0=%3.3f/%3.3f i0_err=%3.4f/%3.4f\n" % (i0, i0_est, i0_err, i0_err_est) ) def test_exp_fit(self):