Author: bugman Date: Mon Sep 1 17:26:48 2014 New Revision: 25507 URL: http://svn.gna.org/viewcvs/relax?rev=25507&view=rev Log: Merged revisions 25499-25502,25504,25506 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk ........ r25499 | bugman | 2014-09-01 14:33:25 +0200 (Mon, 01 Sep 2014) | 8 lines Modified specific_analyses.relax_disp.parameters.r1_setup() to initialise the 'r1' variable. This relates to bug 22541 (https://gna.org/bugs/?22541), the R1 fit flag does not work in the GUI. This is a hack, as all of the dispersion analysis code assumes that all parameters are initialised. This is a dangerous assumption that will have to be eliminated in the future. ........ r25500 | bugman | 2014-09-01 14:37:07 +0200 (Mon, 01 Sep 2014) | 10 lines The dispersion get_param_values() API method now calls the r1_setup() function. This relates to bug #22541 (https://gna.org/bugs/?22541), the R1 fit flag does not work in the GUI. This is to make sure that the parameters are correctly set up prior to obtaining all parameter values. The R1 parameter is dynamic hence r1_setup() needs to be called at any point model parameters are accessed, as the R1 parameter can be turned on or off at any time with the relax_disp.r1_fit user function. ........ r25501 | tlinnet | 2014-09-01 14:54:48 +0200 (Mon, 01 Sep 2014) | 1 line Yet another try to implement constrained method in verify_estimate_r2eff_err_compare_mc. ........ r25502 | tlinnet | 2014-09-01 15:09:41 +0200 (Mon, 01 Sep 2014) | 7 lines Another attempt to reach constrained method in minfx through relax. I would need to specify: l: Lower bound constraint vector (l <= x <= u). u: Upper bound constraint vector (l <= x <= u). c: User supplied constraint function. dc: User supplied constraint gradient function. ........ r25504 | bugman | 2014-09-01 16:33:30 +0200 (Mon, 01 Sep 2014) | 7 lines Added a derivation of the R2eff/R1rho error estimate for the two-point measurement to the manual. This is from http://thread.gmane.org/gmane.science.nmr.relax.devel/6929/focus=6993 and is for the rate uncertainty of a 2-parameter exponential curve when only two data points have been collected. The derivation has been added to the dispersion chapter of the manual. ........ r25506 | bugman | 2014-09-01 16:40:24 +0200 (Mon, 01 Sep 2014) | 3 lines Equation fixes for the two-point exponential error derivation in the dispersion chapter of the manual. ........ Modified: branches/frame_order_cleanup/ (props changed) branches/frame_order_cleanup/docs/latex/dispersion.tex branches/frame_order_cleanup/specific_analyses/relax_disp/api.py branches/frame_order_cleanup/specific_analyses/relax_disp/parameters.py branches/frame_order_cleanup/test_suite/system_tests/relax_disp.py Propchange: branches/frame_order_cleanup/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Mon Sep 1 17:26:48 2014 @@ -1 +1 @@ -/trunk:1-25498 +/trunk:1-25506 Modified: branches/frame_order_cleanup/docs/latex/dispersion.tex URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/docs/latex/dispersion.tex?rev=25507&r1=25506&r2=25507&view=diff ============================================================================== --- branches/frame_order_cleanup/docs/latex/dispersion.tex (original) +++ branches/frame_order_cleanup/docs/latex/dispersion.tex Mon Sep 1 17:26:48 2014 @@ -239,7 +239,7 @@ \subsubsection{Fixed relaxation period experiments} For the fixed relaxation time period CPMG-type experiments, the $\Rtwoeff$/$\Ronerho$ values are determined by direct calculation using the formula -\begin{equation} +\begin{equation} \label{eq: R2eff two-point} \Rtwoeff(\nucpmg) = - \frac{1}{\Trelax} \cdot \ln \left( \frac{I_1(\nucpmg)}{I_0} \right) . \end{equation} @@ -253,6 +253,44 @@ \begin{equation} \label{eq: dispersion error} \sigma_{\Rtwo} = \frac{1}{\Trelax} \sqrt{ \left( \frac{\sigma_{I_1}}{I_1(\omega_1)} \right)^2 + \left( \frac{\sigma_{I_0}}{I_0} \right)^2 } . \end{equation} + +The derivation of this is simple enough. +Rearranging~\ref{eq: R2eff two-point}, +\begin{equation} + \Rtwo \cdot \Trelax = -\ln \left( \frac{I_1}{I_0} \right) . +\end{equation} + +Using the rule +\begin{equation} + \ln\left(\frac{X}{Y}\right) = \ln(X) - \ln(Y), +\end{equation} + +where X and Y are normally distributed variables, then +\begin{equation} + \Rtwo \cdot \Trelax = \ln(I_0) - \ln(I_1) , +\end{equation} + +and +\begin{equation} + \Rtwo = - \frac{1}{\Trelax} \cdot \left( \ln(I_0) - \ln(I_1) \right) , +\end{equation} + +Using the estimate from \url{https://en.wikipedia.org/wiki/Propagation_of_uncertainty} that for +\begin{equation} + f = a \ln(A), +\end{equation} + +the variance of $f$ is +\begin{equation} + \sigma_f^2 = \left( a * \frac{\sigma_A}{A} \right)^2 , +\end{equation} + +then the $\Rtwo$ variance is +\begin{equation} + \sigma_{\Rtwo}^2 = \left( \frac{1}{\Trelax} \cdot \frac{\sigma_{I_0}}{I_0} \right)^2 + \left( \frac{1}{\Trelax} \cdot \frac{\sigma_{I_1}}{I_1} \right)^2. +\end{equation} + +Rearranging gives~\ref{eq: dispersion error}. In a number of publications, the error formula from \citet{IshimaTorchia05} has been used. This is the collapse of Equation~\ref{eq: dispersion error} by setting $\sigma_{I_0}$ to zero: Modified: branches/frame_order_cleanup/specific_analyses/relax_disp/api.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/specific_analyses/relax_disp/api.py?rev=25507&r1=25506&r2=25507&view=diff ============================================================================== --- branches/frame_order_cleanup/specific_analyses/relax_disp/api.py (original) +++ branches/frame_order_cleanup/specific_analyses/relax_disp/api.py Mon Sep 1 17:26:48 2014 @@ -44,7 +44,7 @@ from specific_analyses.relax_disp.data import average_intensity, calc_rotating_frame_params, find_intensity_keys, generate_r20_key, has_exponential_exp_type, has_proton_mmq_cpmg, loop_cluster, loop_exp_frq, loop_exp_frq_offset_point, loop_time, pack_back_calc_r2eff, return_param_key_from_data, spin_ids_to_containers from specific_analyses.relax_disp.optimisation import Disp_memo, Disp_minimise_command, back_calc_peak_intensities, back_calc_r2eff, calculate_r2eff, minimise_r2eff from specific_analyses.relax_disp.parameter_object import Relax_disp_params -from specific_analyses.relax_disp.parameters import get_param_names, get_value, loop_parameters, param_index_to_param_info, param_num +from specific_analyses.relax_disp.parameters import get_param_names, get_value, loop_parameters, param_index_to_param_info, param_num, r1_setup from specific_analyses.relax_disp.variables import EXP_TYPE_CPMG_PROTON_MQ, EXP_TYPE_CPMG_PROTON_SQ, MODEL_LIST_MMQ, MODEL_R2EFF, PARAMS_R20 @@ -456,6 +456,9 @@ # No spins. if not len(spins): return None + + # Set up the R1 parameter, if needed. + r1_setup() # Loop over the parameters of the cluster, fetching their values. values = [] Modified: branches/frame_order_cleanup/specific_analyses/relax_disp/parameters.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/specific_analyses/relax_disp/parameters.py?rev=25507&r1=25506&r2=25507&view=diff ============================================================================== --- branches/frame_order_cleanup/specific_analyses/relax_disp/parameters.py (original) +++ branches/frame_order_cleanup/specific_analyses/relax_disp/parameters.py Mon Sep 1 17:26:48 2014 @@ -940,9 +940,11 @@ # Should R1 data be optimised? r1_fit = is_r1_optimised(spin.model) - # Prepend R1. + # Prepend R1 and add it to the spin container. if r1_fit and 'r1' not in spin.params: spin.params.insert(0, 'r1') + if r1_fit and not hasattr(spin, 'r1'): + spin.r1 = {} # Remove the R1 parameter. if not r1_fit and 'r1' in spin.params: Modified: branches/frame_order_cleanup/test_suite/system_tests/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/system_tests/relax_disp.py?rev=25507&r1=25506&r2=25507&view=diff ============================================================================== --- branches/frame_order_cleanup/test_suite/system_tests/relax_disp.py (original) +++ branches/frame_order_cleanup/test_suite/system_tests/relax_disp.py Mon Sep 1 17:26:48 2014 @@ -37,11 +37,13 @@ from lib.errors import RelaxError from lib.io import get_file_path from pipe_control.mol_res_spin import generate_spin_string, return_spin, spin_loop +from pipe_control.minimise import assemble_scaling_matrix from specific_analyses.relax_disp.checks import check_missing_r1 from specific_analyses.relax_disp.estimate_r2eff import estimate_r2eff -from specific_analyses.relax_disp.data import average_intensity, check_intensity_errors, generate_r20_key, get_curve_type, has_exponential_exp_type, has_r1rho_exp_type, loop_exp_frq, loop_exp_frq_offset_point, loop_exp_frq_offset_point_time, loop_time, return_grace_file_name_ini, return_param_key_from_data +from specific_analyses.relax_disp.data import average_intensity, check_intensity_errors, generate_r20_key, get_curve_type, has_exponential_exp_type, has_r1rho_exp_type, loop_exp_frq, loop_exp_frq_offset_point, loop_exp_frq_offset_point_time, loop_time, return_grace_file_name_ini, return_param_key_from_data, spin_ids_to_containers from specific_analyses.relax_disp.data import INTERPOLATE_DISP, INTERPOLATE_OFFSET, X_AXIS_DISP, X_AXIS_W_EFF, X_AXIS_THETA, Y_AXIS_R2_R1RHO, Y_AXIS_R2_EFF from specific_analyses.relax_disp.model import models_info, nesting_param +from specific_analyses.relax_disp.parameters import linear_constraints 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_LIST, EXP_TYPE_R1RHO, MODEL_B14_FULL, MODEL_CR72, MODEL_CR72_FULL, MODEL_DPL94, MODEL_IT99, MODEL_LIST_ANALYTIC_CPMG, MODEL_LIST_FULL, MODEL_LIST_NUMERIC_CPMG, MODEL_LM63, MODEL_M61, MODEL_M61B, MODEL_MP05, MODEL_NOREX, MODEL_NS_CPMG_2SITE_3D_FULL, MODEL_NS_CPMG_2SITE_EXPANDED, MODEL_NS_CPMG_2SITE_STAR_FULL, MODEL_NS_R1RHO_2SITE, MODEL_NS_R1RHO_3SITE, MODEL_NS_R1RHO_3SITE_LINEAR, MODEL_PARAMS, MODEL_R2EFF, MODEL_TP02, MODEL_TAP03 from status import Status; status = Status() from test_suite.system_tests.base_classes import SystemTestCase @@ -8004,8 +8006,20 @@ min_options = ('%s'%(min_algor),) #min_algor = 'Log barrier' min_algor = 'Method of Multipliers' + scaling_matrix = assemble_scaling_matrix(scaling=True) + + # Collect spins + all_spin_ids = [] + for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True): + all_spin_ids.append(spin_id) + + spins = spin_ids_to_containers(all_spin_ids[:1]) + + # Get constraints + A, b = linear_constraints(spins=spins, scaling_matrix=scaling_matrix[0]) else: min_options = () + A, b = None, None min_options = () sim_boot = 200 scaling_list = [1.0, 1.0] @@ -8087,7 +8101,15 @@ x0 = [r2eff, i0] setup(num_params=len(x0), num_times=len(times), values=I_err, sd=errors, relax_times=times, scaling_matrix=scaling_list) - params_minfx_sim_j, chi2_minfx_sim_j, iter_count, f_count, g_count, h_count, warning = generic_minimise(func=func, dfunc=dfunc, d2func=d2func, args=(), x0=x0, min_algor=min_algor, min_options=min_options, full_output=True, print_flag=0) + # Ref input. + #def generic_minimise(func=None, dfunc=None, d2func=None, args=(), x0=None, min_algor=None, min_options=None, func_tol=1e-25, grad_tol=None, maxiter=1e6, A=None, b=None, l=None, u=None, c=None, dc=None, d2c=None, print_flag=0, print_prefix="", full_output=False): + # l=l, u=u, c=c, dc=dc, d2c=d2c + # l: Lower bound constraint vector (l <= x <= u). + # u: Upper bound constraint vector (l <= x <= u). + # c: User supplied constraint function. + # dc: User supplied constraint gradient function. + params_minfx_sim_j, chi2_minfx_sim_j, iter_count, f_count, g_count, h_count, warning = generic_minimise(func=func, dfunc=dfunc, d2func=d2func, args=(), x0=x0, min_algor=min_algor, min_options=min_options, A=A, b=b, full_output=True, print_flag=0) + R_m_sim_j, I0_m_sim_j = params_minfx_sim_j R_m_sim_l.append(R_m_sim_j) I0_m_sim_l.append(I0_m_sim_j)