Author: tlinnet Date: Wed Aug 27 21:55:19 2014 New Revision: 25358 URL: http://svn.gna.org/viewcvs/relax?rev=25358&view=rev Log: Added systemtest, Relax_disp.test_estimate_r2eff_err_auto and extended functionality to the auto analyses protocol. If "exp_mc_sim_num" is set to "-1" and sent to the auto analyses, the errors of R2eff will be estimated from the Co-Variance matrix. These errors is HIGHLY likely to be wrong, but can be used in an initial test fase, to rapidly produce data for plotting data. task #7822(https://gna.org/task/index.php?7822): Implement user function to estimate R2eff and associated errors for exponential curve fitting. Modified: trunk/auto_analyses/relax_disp.py trunk/test_suite/system_tests/relax_disp.py Modified: trunk/auto_analyses/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/trunk/auto_analyses/relax_disp.py?rev=25358&r1=25357&r2=25358&view=diff ============================================================================== --- trunk/auto_analyses/relax_disp.py (original) +++ trunk/auto_analyses/relax_disp.py Wed Aug 27 21:55:19 2014 @@ -497,18 +497,31 @@ # The minimisation algorithm to use. If the Jacobian and Hessian matrix have not been specified for fitting, 'simplex' should be used. min_algor = 'simplex' - # Do Monte Carlo simulations. + # Error estimation by Monte Carlo simulations. if do_monte_carlo: + # Set the number of Monte-Carlo simulations. + monte_carlo_sim = self.mc_sim_num + + # If the number for exponential curve fitting has been set. if model == MODEL_R2EFF and self.exp_mc_sim_num != None: - self.interpreter.monte_carlo.setup(number=self.exp_mc_sim_num) + monte_carlo_sim = self.exp_mc_sim_num + + # When set to minus 1, estimation of the errors will be extracted from the covariance matrix. + # This is HIGHLY likely to be wrong, but can be used in an initial test fase. + if model == MODEL_R2EFF and self.exp_mc_sim_num == -1: + # Print + subsection(file=sys.stdout, text="Estimating errors from Covariance matrix", prespace=1) + + # Estimate errors + self.interpreter.relax_disp.r2eff_err_estimate() else: - self.interpreter.monte_carlo.setup(number=self.mc_sim_num) - self.interpreter.monte_carlo.create_data() - self.interpreter.monte_carlo.initial_values() - self.interpreter.minimise.execute(min_algor=min_algor, func_tol=self.opt_func_tol, max_iter=self.opt_max_iterations, constraints=constraints) - if self.eliminate: - self.interpreter.eliminate() - self.interpreter.monte_carlo.error_analysis() + self.interpreter.monte_carlo.setup(number=monte_carlo_sim) + self.interpreter.monte_carlo.create_data() + self.interpreter.monte_carlo.initial_values() + self.interpreter.minimise.execute(min_algor=min_algor, func_tol=self.opt_func_tol, max_iter=self.opt_max_iterations, constraints=constraints) + if self.eliminate: + self.interpreter.eliminate() + self.interpreter.monte_carlo.error_analysis() def pre_run_parameters(self, model=None, model_path=None): 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=25358&r1=25357&r2=25358&view=diff ============================================================================== --- trunk/test_suite/system_tests/relax_disp.py (original) +++ trunk/test_suite/system_tests/relax_disp.py Wed Aug 27 21:55:19 2014 @@ -63,6 +63,7 @@ to_skip = [ "test_bug_21344_sparse_time_spinlock_acquired_r1rho_fail_relax_disp", "test_estimate_r2eff_err", + "test_estimate_r2eff_err_auto", "test_estimate_r2eff_err_methods" "test_exp_fit", "test_m61_exp_data_to_m61", @@ -2746,6 +2747,86 @@ # Run the analysis. relax_disp.Relax_disp(pipe_name=ds.pipe_name, pipe_bundle=ds.pipe_bundle, results_dir=result_dir_name, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL) + + # Verify the data. + self.verify_r1rho_kjaergaard_missing_r1(models=MODELS, result_dir_name=result_dir_name, do_assert=False) + + + def test_estimate_r2eff_err_auto(self): + """Test the user function for estimating R2eff errors from exponential curve fitting, via the auto_analyses menu. + + 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. + """ + + # Cluster residues + cluster_ids = [ + ":13@N", + ":15@N", + ":16@N", + ":25@N", + ":26@N", + ":28@N", + ":39@N", + ":40@N", + ":41@N", + ":43@N", + ":44@N", + ":45@N", + ":49@N", + ":52@N", + ":53@N"] + + # Load the data. + self.setup_r1rho_kjaergaard(cluster_ids=cluster_ids, read_R1=False) + + # The dispersion models. + MODELS = [MODEL_R2EFF, MODEL_NOREX] + + # The grid search size (the number of increments per dimension). + GRID_INC = None + + # The number of Monte Carlo simulations to be used for error analysis for exponential curve fitting of R2eff. + # When set to minus 1, estimation of the errors will be extracted from the covariance matrix. + # This is HIGHLY likely to be wrong, but can be used in an initial test fase. + EXP_MC_NUM = -1 + + # The number of Monte Carlo simulations to be used for error analysis at the end of the analysis. + MC_NUM = 3 + + # Model selection technique. + MODSEL = 'AIC' + + # Execute the auto-analysis (fast). + # Standard parameters are: func_tol = 1e-25, grad_tol = None, max_iter = 10000000, + OPT_FUNC_TOL = 1e-25 + relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL + OPT_MAX_ITERATIONS = 10000000 + relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS + + result_dir_name = ds.tmpdir + + # Make all spins free + for curspin in cluster_ids: + self.interpreter.relax_disp.cluster('free spins', curspin) + # Shut them down + self.interpreter.deselect.spin(spin_id=curspin, change_all=False) + + # Select only a subset of spins for global fitting + #self.interpreter.select.spin(spin_id=':41@N', change_all=False) + #self.interpreter.relax_disp.cluster('model_cluster', ':41@N') + + #self.interpreter.select.spin(spin_id=':40@N', change_all=False) + #self.interpreter.relax_disp.cluster('model_cluster', ':40@N') + + self.interpreter.select.spin(spin_id=':52@N', change_all=False) + #self.interpreter.relax_disp.cluster('model_cluster', ':52@N') + + # Run the analysis. + relax_disp.Relax_disp(pipe_name=ds.pipe_name, pipe_bundle=ds.pipe_bundle, results_dir=result_dir_name, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, exp_mc_sim_num=EXP_MC_NUM, modsel=MODSEL) # Verify the data. self.verify_r1rho_kjaergaard_missing_r1(models=MODELS, result_dir_name=result_dir_name, do_assert=False)