Hi Edward.

I partly implemented this.

But I think some of the functionality still missing in the run(self)
part of the analysis.

I think this part will give problems.

--------
            # Select the model.
            self.interpreter.relax_disp.select_model(model)

            # Copy the R2eff values from the R2eff model data pipe.
            if model != MODEL_R2EFF and MODEL_R2EFF in self.models:

self.interpreter.value.copy(pipe_from=self.name_pipe(MODEL_R2EFF),
pipe_to=model_pipe, param='r2eff')

            # Calculate the R2eff values for the fixed relaxation time
period data types.
            if model == MODEL_R2EFF and not has_exponential_exp_type():
                self.interpreter.minimise.calculate()
---------

Just reading in R2eff values by relax_disp.r2eff_read, will not give
enough information?

best
Troels

2014-08-18 18:46 GMT+02:00 Edward d'Auvergne <[email protected]>:
> I would suggest a slightly different solution.  If the data pipe sent
> into the auto-analysis already contains R2eff values and errors, then
> skip that model optimisation.  The flag can be used anyway to force
> the R2eff parameter optimisation.
>
> On another note, this flag is not necessarily related to the pre_run
> and can be used without a pre-run.  For example, a user like Nikolai
> could have files of R2eff values that are read in via the
> relax_disp.r2eff_read.  So the flag would be better called
> optimise_r2eff.  You currently use the flag when no pre-run data is
> used, so that part needs no changing.
>
> Cheers,
>
> Edward
>
>
>
> On 12 August 2014 15:23,  <[email protected]> wrote:
>> Author: tlinnet
>> Date: Tue Aug 12 15:23:57 2014
>> New Revision: 25000
>>
>> URL: http://svn.gna.org/viewcvs/relax?rev=25000&view=rev
>> Log:
>> Added keyword to relax_disp auto analysis, if R2eff values should be 
>> optimised.
>>
>> Here optimisation means minimisation and Monte Carlo simulations of the 
>> error.
>>
>> sr #3135(https://gna.org/support/?3135): Optimisation of the R1 relaxation 
>> rate for the off-resonance R1rho relaxation dispersion models.
>>
>> Modified:
>>     branches/R1_fitting/auto_analyses/relax_disp.py
>>
>> Modified: branches/R1_fitting/auto_analyses/relax_disp.py
>> URL: 
>> http://svn.gna.org/viewcvs/relax/branches/R1_fitting/auto_analyses/relax_disp.py?rev=25000&r1=24999&r2=25000&view=diff
>> ==============================================================================
>> --- branches/R1_fitting/auto_analyses/relax_disp.py     (original)
>> +++ branches/R1_fitting/auto_analyses/relax_disp.py     Tue Aug 12 15:23:57 
>> 2014
>> @@ -51,38 +51,39 @@
>>      opt_func_tol = 1e-25
>>      opt_max_iterations = int(1e7)
>>
>> -    def __init__(self, pipe_name=None, pipe_bundle=None, results_dir=None, 
>> models=[MODEL_R2EFF], grid_inc=11, mc_sim_num=500, exp_mc_sim_num=None, 
>> modsel='AIC', pre_run_dir=None, insignificance=0.0, numeric_only=False, 
>> mc_sim_all_models=False, eliminate=True, set_grid_r20=False):
>> +    def __init__(self, pipe_name=None, pipe_bundle=None, results_dir=None, 
>> models=[MODEL_R2EFF], grid_inc=11, mc_sim_num=500, exp_mc_sim_num=None, 
>> modsel='AIC', pre_run_dir=None, optimise_pre_run_r2eff=True, 
>> insignificance=0.0, numeric_only=False, mc_sim_all_models=False, 
>> eliminate=True, set_grid_r20=False):
>>          """Perform a full relaxation dispersion analysis for the given list 
>> of models.
>>
>> -        @keyword pipe_name:         The name of the data pipe containing 
>> all of the data for the analysis.
>> -        @type pipe_name:            str
>> -        @keyword pipe_bundle:       The data pipe bundle to associate all 
>> spawned data pipes with.
>> -        @type pipe_bundle:          str
>> -        @keyword results_dir:       The directory where results files are 
>> saved.
>> -        @type results_dir:          str
>> -        @keyword models:            The list of relaxation dispersion 
>> models to optimise.
>> -        @type models:               list of str
>> -        @keyword grid_inc:          Number of grid search increments.  If 
>> set to None, then the grid search will be turned off and the default 
>> parameter values will be used instead.
>> -        @type grid_inc:             int or None
>> -        @keyword mc_sim_num:        The number of Monte Carlo simulations 
>> to be used for error analysis at the end of the analysis.
>> -        @type mc_sim_num:           int
>> -        @keyword exp_mc_sim_num:    The number of Monte Carlo simulations 
>> for the error analysis in the 'R2eff' model when exponential curves are 
>> fitted.  This defaults to the value of the mc_sim_num argument when not 
>> given.  For the 2-point fixed-time calculation for the 'R2eff' model, this 
>> argument is ignored.
>> -        @type exp_mc_sim_num:       int or None
>> -        @type
>> -        @keyword modsel:            The model selection technique to use in 
>> the analysis to determine which model is the best for each spin cluster.  
>> This can currently be one of 'AIC', 'AICc', and 'BIC'.
>> -        @type modsel:               str
>> -        @keyword pre_run_dir:       The optional directory containing the 
>> dispersion auto-analysis results from a previous run.  The optimised 
>> parameters from these previous results will be used as the starting point 
>> for optimisation rather than performing a grid search.  This is essential 
>> for when large spin clusters are specified, as a grid search becomes 
>> prohibitively expensive with clusters of three or more spins.  At some point 
>> a RelaxError will occur because the grid search is impossibly large.  For 
>> the cluster specific parameters, i.e. the populations of the states and the 
>> exchange parameters, an average value will be used as the starting point.  
>> For all other parameters, the R20 values for each spin and magnetic field, 
>> as well as the parameters related to the chemical shift difference dw, the 
>> optimised values of the previous run will be directly copied.
>> -        @type pre_run_dir:          None or str
>> -        @keyword insignificance:    The R2eff/R1rho value in rad/s by which 
>> to judge insignificance.  If the maximum difference between two points on 
>> all dispersion curves for a spin is less than this value, that spin will be 
>> deselected.  This does not affect the 'No Rex' model.  Set this value to 0.0 
>> to use all data.  The value will be passed on to the 
>> relax_disp.insignificance user function.
>> -        @type insignificance:       float
>> -        @keyword numeric_only:      The class of models to use in the model 
>> selection.  The default of False allows all dispersion models to be used in 
>> the analysis (no exchange, the analytic models and the numeric models).  The 
>> value of True will activate a pure numeric solution - the analytic models 
>> will be optimised, as they are very useful for replacing the grid search for 
>> the numeric models, but the final model selection will not include them.
>> -        @type numeric_only:         bool
>> -        @keyword mc_sim_all_models: A flag which if True will cause Monte 
>> Carlo simulations to be performed for each individual model.  Otherwise 
>> Monte Carlo simulations will be reserved for the final model.
>> -        @type mc_sim_all_models:    bool
>> -        @keyword eliminate:         A flag which if True will enable the 
>> elimination of failed models and failed Monte Carlo simulations through the 
>> eliminate user function.
>> -        @type eliminate:            bool
>> -        @keyword set_grid_r20:      A flag which if True will set the grid 
>> R20 values from the minimum R2eff values through the r20_from_min_r2eff user 
>> function. This will speed up the grid search with a factor 
>> GRID_INC^(Nr_spec_freq). For a CPMG experiment with two fields and standard 
>> GRID_INC=21, the speed-up is a factor 441.
>> -        @type set_grid_r20:         bool
>> +        @keyword pipe_name:                 The name of the data pipe 
>> containing all of the data for the analysis.
>> +        @type pipe_name:                    str
>> +        @keyword pipe_bundle:               The data pipe bundle to 
>> associate all spawned data pipes with.
>> +        @type pipe_bundle:                  str
>> +        @keyword results_dir:               The directory where results 
>> files are saved.
>> +        @type results_dir:                  str
>> +        @keyword models:                    The list of relaxation 
>> dispersion models to optimise.
>> +        @type models:                       list of str
>> +        @keyword grid_inc:                  Number of grid search 
>> increments.  If set to None, then the grid search will be turned off and the 
>> default parameter values will be used instead.
>> +        @type grid_inc:                     int or None
>> +        @keyword mc_sim_num:                The number of Monte Carlo 
>> simulations to be used for error analysis at the end of the analysis.
>> +        @type mc_sim_num:                   int
>> +        @keyword exp_mc_sim_num:            The number of Monte Carlo 
>> simulations for the error analysis in the 'R2eff' model when exponential 
>> curves are fitted.  This defaults to the value of the mc_sim_num argument 
>> when not given.  For the 2-point fixed-time calculation for the 'R2eff' 
>> model, this argument is ignored.
>> +        @type exp_mc_sim_num:               int or None
>> +        @keyword modsel:                    The model selection technique 
>> to use in the analysis to determine which model is the best for each spin 
>> cluster.  This can currently be one of 'AIC', 'AICc', and 'BIC'.
>> +        @type modsel:                       str
>> +        @keyword pre_run_dir:               The optional directory 
>> containing the dispersion auto-analysis results from a previous run.  The 
>> optimised parameters from these previous results will be used as the 
>> starting point for optimisation rather than performing a grid search.  This 
>> is essential for when large spin clusters are specified, as a grid search 
>> becomes prohibitively expensive with clusters of three or more spins.  At 
>> some point a RelaxError will occur because the grid search is impossibly 
>> large.  For the cluster specific parameters, i.e. the populations of the 
>> states and the exchange parameters, an average value will be used as the 
>> starting point.  For all other parameters, the R20 values for each spin and 
>> magnetic field, as well as the parameters related to the chemical shift 
>> difference dw, the optimised values of the previous run will be directly 
>> copied.
>> +        @type pre_run_dir:                  None or str
>> +        @keyword optimise_pre_run_r2eff:    Flag to specify if the read 
>> previous R2eff results should be optimised.  For R1rho models where the 
>> error of R2eff values are determined by Monte-Carlo simulations, it can be 
>> valuable to make an initial R2eff run with a high number of Monte-Carlo 
>> simulations.  Any subsequent model analysis can then be based on these R2eff 
>> values, without optimising the R2eff values.
>> +        @type optimise_pre_run_r2eff:       bool
>> +        @keyword insignificance:            The R2eff/R1rho value in rad/s 
>> by which to judge insignificance.  If the maximum difference between two 
>> points on all dispersion curves for a spin is less than this value, that 
>> spin will be deselected.  This does not affect the 'No Rex' model.  Set this 
>> value to 0.0 to use all data.  The value will be passed on to the 
>> relax_disp.insignificance user function.
>> +        @type insignificance:               float
>> +        @keyword numeric_only:              The class of models to use in 
>> the model selection.  The default of False allows all dispersion models to 
>> be used in the analysis (no exchange, the analytic models and the numeric 
>> models).  The value of True will activate a pure numeric solution - the 
>> analytic models will be optimised, as they are very useful for replacing the 
>> grid search for the numeric models, but the final model selection will not 
>> include them.
>> +        @type numeric_only:                 bool
>> +        @keyword mc_sim_all_models:         A flag which if True will cause 
>> Monte Carlo simulations to be performed for each individual model.  
>> Otherwise Monte Carlo simulations will be reserved for the final model.
>> +        @type mc_sim_all_models:            bool
>> +        @keyword eliminate:                 A flag which if True will 
>> enable the elimination of failed models and failed Monte Carlo simulations 
>> through the eliminate user function.
>> +        @type eliminate:                    bool
>> +        @keyword set_grid_r20:              A flag which if True will set 
>> the grid R20 values from the minimum R2eff values through the 
>> r20_from_min_r2eff user function. This will speed up the grid search with a 
>> factor GRID_INC^(Nr_spec_freq). For a CPMG experiment with two fields and 
>> standard GRID_INC=21, the speed-up is a factor 441.
>> +        @type set_grid_r20:                 bool
>>          """
>>
>>          # Printout.
>> @@ -104,6 +105,7 @@
>>          self.exp_mc_sim_num = exp_mc_sim_num
>>          self.modsel = modsel
>>          self.pre_run_dir = pre_run_dir
>> +        self.optimise_pre_run_r2eff = optimise_pre_run_r2eff
>>          self.insignificance = insignificance
>>          self.set_grid_r20 = set_grid_r20
>>          self.numeric_only = numeric_only
>> @@ -481,14 +483,21 @@
>>                          self.interpreter.value.set(param=param, index=None)
>>
>>          # Minimise.
>> -        self.interpreter.minimise.execute('simplex', 
>> func_tol=self.opt_func_tol, max_iter=self.opt_max_iterations, 
>> constraints=True)
>> +        if model == MODEL_R2EFF:
>> +            if self.optimise_pre_run_r2eff:
>> +                self.interpreter.minimise.execute('simplex', 
>> func_tol=self.opt_func_tol, max_iter=self.opt_max_iterations, 
>> constraints=True)
>> +            else:
>> +                pass
>> +        else:
>> +            self.interpreter.minimise.execute('simplex', 
>> func_tol=self.opt_func_tol, max_iter=self.opt_max_iterations, 
>> constraints=True)
>> +
>>
>>          # Model elimination.
>>          if self.eliminate:
>>              self.interpreter.eliminate()
>>
>>          # Monte Carlo simulations.
>> -        if self.mc_sim_all_models or len(self.models) < 2 or model == 
>> MODEL_R2EFF:
>> +        if self.mc_sim_all_models or len(self.models) < 2 or (model == 
>> MODEL_R2EFF and self.optimise_pre_run_r2eff):
>>              if model == MODEL_R2EFF and self.exp_mc_sim_num != None:
>>                  
>> self.interpreter.monte_carlo.setup(number=self.exp_mc_sim_num)
>>              else:
>>
>>
>> _______________________________________________
>> relax (http://www.nmr-relax.com)
>>
>> This is the relax-commits mailing list
>> [email protected]
>>
>> To unsubscribe from this list, get a password
>> reminder, or change your subscription options,
>> visit the list information page at
>> https://mail.gna.org/listinfo/relax-commits
>
> _______________________________________________
> relax (http://www.nmr-relax.com)
>
> This is the relax-devel mailing list
> [email protected]
>
> To unsubscribe from this list, get a password
> reminder, or change your subscription options,
> visit the list information page at
> https://mail.gna.org/listinfo/relax-devel

_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-devel mailing list
[email protected]

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-devel

Reply via email to