Author: tlinnet Date: Tue Aug 12 10:55:03 2014 New Revision: 24995 URL: http://svn.gna.org/viewcvs/relax?rev=24995&view=rev Log: Added function to sort models before auto analyses. They are sorted in order: exp_type: EXP_TYPE_R2EFF, EXP_TYPE_NOREX, EXP_TYPE_NOREX_R1RHO, EXP_TYPE_CPMG_SQ, EXP_TYPE_CPMG_MMQ, EXP_TYPE_R1RHO equation: EQ_SILICO, EQ_ANALYTIC, EQ_NUMERIC Nr of chemical sites: 2 or 3 Year: Newest models first. Nr of params: 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/specific_analyses/relax_disp/variables.py Modified: branches/R1_fitting/specific_analyses/relax_disp/variables.py URL: http://svn.gna.org/viewcvs/relax/branches/R1_fitting/specific_analyses/relax_disp/variables.py?rev=24995&r1=24994&r2=24995&view=diff ============================================================================== --- branches/R1_fitting/specific_analyses/relax_disp/variables.py (original) +++ branches/R1_fitting/specific_analyses/relax_disp/variables.py Tue Aug 12 10:55:03 2014 @@ -785,6 +785,12 @@ # Save the index of current model to order of equation type. self.eq_i = order_eq.index(self.eq) + # Define the order of how equation type ranks, when sorting before auto analyses. + order_s = [EQ_SILICO, EQ_ANALYTIC, EQ_NUMERIC] + + # Save the index of current model to order of equation type. + self.eq_s = order_s.index(self.eq) + # Save the difference in year from now, to implemented model. self.year_diff = date.today().year - self.year @@ -983,3 +989,30 @@ else: return model_info, None + + +# Define function, to sort models. +def sort_models(models=None): + """Determine how to order the models for analyses. + + @keyword models: The list of all models to be analysed. + @type models: list of str + @return: The ordered list how models should be analysed. + @rtype: list of str + """ + + # Get the info of the models selected for analysis. + all_models_info = models_info(models) + + # Sort the models according to: exp_type, equation type, chemical sites, year for model, number of parameters. + all_models_info_sorted = sorted(all_models_info, key=attrgetter('exp_type_i', 'eq_s', 'sites', 'year_diff', 'params_nr')) + + # Define list of sorted models. + sorted_models = [] + + # Loop over the models info, and extract model. + for model_info in all_models_info_sorted: + sorted_models.append(model_info.model) + + # Return sorted list of models. + return sorted_models