Exemple #1
0
    def wizard_page_after_cpmg_setup(self):
        """Set the page after the CPMG setup page.

        This should either be the R1rho page if R1rho experiment types exist, or terminate the wizard.


        @return:    The index of the next page, which is the current page index plus one.
        @rtype:     int
        """

        # R1rho experiments exists.
        if has_r1rho_exp_type():
            return self.page_indices['spin_lock_field']

        # Nothing left, so run off the end.
        else:
            return self._num_pages + 1
Exemple #2
0
    def wizard_page_after_cpmg_setup(self):
        """Set the page after the CPMG setup page.

        This should either be the R1rho page if R1rho experiment types exist, or terminate the wizard.


        @return:    The index of the next page, which is the current page index plus one.
        @rtype:     int
        """

        # R1rho experiments exists.
        if has_r1rho_exp_type():
            return self.page_indices['spin_lock_field']

        # Nothing left, so run off the end.
        else:
            return self._num_pages + 1
Exemple #3
0
    def write_results(self, path=None, model=None):
        """Create a set of results, text and Grace files for the current data pipe.

        @keyword path:  The directory to place the files into.
        @type path:     str
        """

        # Printout.
        section(file=sys.stdout, text="Results writing", prespace=2)

        # If this is the final model selection round, check which models have been tested.
        if model == None:
            models_tested = []
            for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
                spin_model = spin.model

                # Add to list, if not in already.
                if spin_model not in models_tested:
                    models_tested.append(spin_model)
        else:
            models_tested = None

        # Special for R2eff model.
        if model == MODEL_R2EFF:
            # The R2eff parameter.
            self.interpreter.value.write(param='r2eff',
                                         file='r2eff.out',
                                         dir=path,
                                         force=True)
            self.interpreter.grace.write(x_data_type='res_num',
                                         y_data_type='r2eff',
                                         file='r2eff.agr',
                                         dir=path,
                                         force=True)

            # Exponential curves.
            if has_exponential_exp_type():
                self.interpreter.relax_disp.plot_exp_curves(
                    file='intensities.agr', dir=path,
                    force=True)  # Average peak intensities.
                self.interpreter.relax_disp.plot_exp_curves(
                    file='intensities_norm.agr',
                    dir=path,
                    force=True,
                    norm=True)  # Average peak intensities (normalised).

                # The I0 parameter.
                self.interpreter.value.write(param='i0',
                                             file='i0.out',
                                             dir=path,
                                             force=True)
                self.interpreter.grace.write(x_data_type='res_num',
                                             y_data_type='i0',
                                             file='i0.agr',
                                             dir=path,
                                             force=True)

        # Dispersion curves.
        self.interpreter.relax_disp.plot_disp_curves(dir=path, force=True)
        self.interpreter.relax_disp.write_disp_curves(dir=path, force=True)

        # The selected models for the final run.
        if model == None:
            self.interpreter.value.write(param='model',
                                         file='model.out',
                                         dir=path,
                                         force=True)

        # For CPMG models.
        if has_cpmg_exp_type():
            # The R20 parameter.
            self.write_results_test(path=path,
                                    model=model,
                                    models_tested=models_tested,
                                    param='r2',
                                    file_name_ini='r20')

            # The R20A and R20B parameters.
            self.write_results_test(path=path,
                                    model=model,
                                    models_tested=models_tested,
                                    param='r2a',
                                    file_name_ini='r20a')
            self.write_results_test(path=path,
                                    model=model,
                                    models_tested=models_tested,
                                    param='r2b',
                                    file_name_ini='r20b')

        # For R1ho models.
        if has_r1rho_exp_type():
            # The R1 parameter.
            self.write_results_test(path=path,
                                    model=model,
                                    models_tested=models_tested,
                                    param='r1')

            # The R1rho prime parameter.
            self.write_results_test(path=path,
                                    model=model,
                                    models_tested=models_tested,
                                    param='r2',
                                    file_name_ini='r1rho_prime')

            # Plot specific R1rho graphs.
            if model in [None] + MODEL_LIST_R1RHO:
                self.interpreter.relax_disp.plot_disp_curves(
                    dir=path, x_axis=X_AXIS_THETA, force=True)
                self.interpreter.relax_disp.plot_disp_curves(
                    dir=path,
                    y_axis=Y_AXIS_R2_R1RHO,
                    x_axis=X_AXIS_W_EFF,
                    force=True)
                self.interpreter.relax_disp.plot_disp_curves(
                    dir=path,
                    y_axis=Y_AXIS_R2_EFF,
                    x_axis=X_AXIS_THETA,
                    interpolate=INTERPOLATE_OFFSET,
                    force=True)

            # The calculation of theta and w_eff parameter in R1rho experiments.
            if model in MODEL_LIST_R1RHO_FULL:
                self.interpreter.value.write(param='theta',
                                             file='theta.out',
                                             dir=path,
                                             force=True)
                self.interpreter.value.write(param='w_eff',
                                             file='w_eff.out',
                                             dir=path,
                                             force=True)

        # The pA and pB parameters.
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='pA')
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='pB')

        # The pC parameter.
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='pC')

        # The phi_ex parameter.
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='phi_ex')

        # The phi_ex_B nd phi_ex_C parameters.
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='phi_ex_B')
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='phi_ex_C')

        # The dw parameter.
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='dw')

        # The dw_AB, dw_BC and dw_AC parameter.
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='dw_AB')
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='dw_BC')
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='dw_AC')

        # The dwH parameter.
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='dwH')

        # The dwH_AB, dwH_BC and dwH_AC parameter.
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='dwH_AB')
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='dwH_BC')
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='dwH_AC')

        # The k_AB, kex and tex parameters.
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='k_AB')
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='kex')
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='tex')

        # The kex_AB, kex_BC, kex_AC parameters.
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='kex_AB')
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='kex_BC')
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='kex_AC')

        # The kB and kC parameters.
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='kB')
        self.write_results_test(path=path,
                                model=model,
                                models_tested=models_tested,
                                param='kC')

        # Minimisation statistics.
        if not (model == MODEL_R2EFF and has_fixed_time_exp_type()):
            self.interpreter.value.write(param='chi2',
                                         file='chi2.out',
                                         dir=path,
                                         force=True)
            self.interpreter.grace.write(y_data_type='chi2',
                                         file='chi2.agr',
                                         dir=path,
                                         force=True)

        # Finally save the results.  This is last to allow the continuation of an interrupted analysis while ensuring that all results files have been created.
        self.interpreter.results.write(file='results', dir=path, force=True)
Exemple #4
0
    def assemble_data(self):
        """Assemble the data required for the Auto_noe class.

        @return:    A container with all the data required for the auto-analysis, the missing list, and a list of models that don't match the experiment types.
        @rtype:     class instance, list of str, list of str
        """

        # The data container.
        data = Container()
        missing = []
        model_mismatch = []

        # The pipe name and bundle.
        data.pipe_name = self.data.pipe_name
        data.pipe_bundle = self.data.pipe_bundle

        # Results directories.
        data.save_dir = self.data.save_dir
        data.pre_run_dir = gui_to_str(self.field_pre_run_dir.GetValue())

        # Check if sequence data is loaded
        if not exists_mol_res_spin_data():
            missing.append("Sequence data")

        # Spin variables.
        for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
            # The message skeleton.
            msg = "Spin '%s' - %s (try the %s user function)." % (spin_id, "%s", "%s")

            # Test if the nuclear isotope type has been set.
            if not hasattr(spin, 'isotope') or spin.isotope == None:
                missing.append(msg % ("nuclear isotope data", "spin.isotope"))

        # Spectral data.
        if not hasattr(cdp, 'spectrum_ids') or len(cdp.spectrum_ids) < 2:
            missing.append("Spectral data")

        # The dispersion models.
        data.models = self.model_field.GetValue()

        # Invalid models.
        for model in data.models:
            # Invalid CPMG models.
            if model != MODEL_NOREX and model in MODEL_LIST_CPMG and not has_cpmg_exp_type():
                model_mismatch.append([model, 'CPMG'])

            # Invalid R1rho models.
            if model != MODEL_NOREX and model in MODEL_LIST_R1RHO and not has_r1rho_exp_type():
                model_mismatch.append([model, 'R1rho'])

        # The R1 parameter fitting flag.
        data.r1_fit = self.r1_fit.GetValue()

        # The numeric only solution.
        data.numeric_only = self.numeric_only.GetValue()

        # Increment size.
        data.inc = gui_to_int(self.grid_inc.GetValue())

        # The number of Monte Carlo simulations to be used for error analysis at the end of the analysis.
        data.mc_sim_num = gui_to_int(self.mc_sim_num.GetValue())
        data.exp_mc_sim_num = gui_to_int(self.exp_mc_sim_num.GetValue())
        data.mc_sim_all_models = self.mc_sim_all_models.GetValue()

        # The insignificance level.
        data.insignificance = self.insignificance.GetValue()
        try:
            data.insignificance = gui_to_float(data.insignificance)
        except:
            missing.append("The insignificance level must be a number.")

        # Optimisation precision.
        data.opt_func_tol = self.opt_func_tol
        data.opt_max_iterations = self.opt_max_iterations

        # Return the container, the list of missing data, and any models that don't match the experiment types.
        return data, missing, model_mismatch
Exemple #5
0
    def assemble_data(self):
        """Assemble the data required for the Auto_noe class.

        @return:    A container with all the data required for the auto-analysis, the missing list, and a list of models that don't match the experiment types.
        @rtype:     class instance, list of str, list of str
        """

        # The data container.
        data = Container()
        missing = []
        model_mismatch = []

        # The pipe name and bundle.
        data.pipe_name = self.data.pipe_name
        data.pipe_bundle = self.data.pipe_bundle

        # Results directories.
        data.save_dir = self.data.save_dir
        data.pre_run_dir = gui_to_str(self.field_pre_run_dir.GetValue())

        # Check if sequence data is loaded
        if not exists_mol_res_spin_data():
            missing.append("Sequence data")

        # Spin variables.
        for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
            # The message skeleton.
            msg = "Spin '%s' - %s (try the %s user function)." % (spin_id, "%s", "%s")

            # Test if the nuclear isotope type has been set.
            if not hasattr(spin, 'isotope') or spin.isotope == None:
                missing.append(msg % ("nuclear isotope data", "spin.isotope"))

        # Spectral data.
        if not hasattr(cdp, 'spectrum_ids') or len(cdp.spectrum_ids) < 2:
            missing.append("Spectral data")

        # The dispersion models.
        data.models = self.model_field.GetValue()

        # Invalid models.
        for model in data.models:
            # Invalid CPMG models.
            if model != MODEL_NOREX and model in MODEL_LIST_CPMG and not has_cpmg_exp_type():
                model_mismatch.append([model, 'CPMG'])

            # Invalid R1rho models.
            if model != MODEL_NOREX and model in MODEL_LIST_R1RHO and not has_r1rho_exp_type():
                model_mismatch.append([model, 'R1rho'])

        # The R1 parameter fitting flag.
        data.r1_fit = self.r1_fit.GetValue()

        # The numeric only solution.
        data.numeric_only = self.numeric_only.GetValue()

        # Increment size.
        data.inc = gui_to_int(self.grid_inc.GetValue())

        # The number of Monte Carlo simulations to be used for error analysis at the end of the analysis.
        data.mc_sim_num = gui_to_int(self.mc_sim_num.GetValue())
        data.exp_mc_sim_num = gui_to_int(self.exp_mc_sim_num.GetValue())
        data.mc_sim_all_models = self.mc_sim_all_models.GetValue()

        # The insignificance level.
        data.insignificance = self.insignificance.GetValue()
        try:
            data.insignificance = gui_to_float(data.insignificance)
        except:
            missing.append("The insignificance level must be a number.")

        # Optimisation precision.
        data.opt_func_tol = self.opt_func_tol
        data.opt_max_iterations = self.opt_max_iterations

        # Return the container, the list of missing data, and any models that don't match the experiment types.
        return data, missing, model_mismatch
Exemple #6
0
    def write_results(self, path=None, model=None):
        """Create a set of results, text and Grace files for the current data pipe.

        @keyword path:  The directory to place the files into.
        @type path:     str
        """

        # Printout.
        section(file=sys.stdout, text="Results writing", prespace=2)

        # If this is the final model selection round, check which models have been tested.
        if model == None:
            models_tested = []
            for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
                spin_model = spin.model

                # Add to list, if not in already.
                if spin_model not in models_tested:
                    models_tested.append(spin_model)
        else:
            models_tested = None

        # Special for R2eff model.
        if model == MODEL_R2EFF:
            # The R2eff parameter.
            self.interpreter.value.write(param='r2eff', file='r2eff.out', dir=path, force=True)
            self.interpreter.grace.write(x_data_type='res_num', y_data_type='r2eff', file='r2eff.agr', dir=path, force=True)

            # Exponential curves.
            if has_exponential_exp_type():
                self.interpreter.relax_disp.plot_exp_curves(file='intensities.agr', dir=path, force=True)    # Average peak intensities.
                self.interpreter.relax_disp.plot_exp_curves(file='intensities_norm.agr', dir=path, force=True, norm=True)    # Average peak intensities (normalised).

                # The I0 parameter.
                self.interpreter.value.write(param='i0', file='i0.out', dir=path, force=True)
                self.interpreter.grace.write(x_data_type='res_num', y_data_type='i0', file='i0.agr', dir=path, force=True)

        # Dispersion curves.
        self.interpreter.relax_disp.plot_disp_curves(dir=path, force=True)
        self.interpreter.relax_disp.write_disp_curves(dir=path, force=True)

        # The selected models for the final run.
        if model == None:
            self.interpreter.value.write(param='model', file='model.out', dir=path, force=True)

        # For CPMG models.
        if has_cpmg_exp_type():
            # The R20 parameter.
            self.write_results_test(path=path, model=model, models_tested=models_tested, param='r2', file_name_ini='r20')

            # The R20A and R20B parameters.
            self.write_results_test(path=path, model=model, models_tested=models_tested, param='r2a', file_name_ini='r20a')
            self.write_results_test(path=path, model=model, models_tested=models_tested, param='r2b', file_name_ini='r20b')

        # For R1ho models.
        if has_r1rho_exp_type():
            # The R1 parameter.
            self.write_results_test(path=path, model=model, models_tested=models_tested, param='r1')

            # The R1rho prime parameter.
            self.write_results_test(path=path, model=model, models_tested=models_tested, param='r2', file_name_ini='r1rho_prime')

            # Plot specific R1rho graphs.
            if model in [None] + MODEL_LIST_R1RHO:
                self.interpreter.relax_disp.plot_disp_curves(dir=path, x_axis=X_AXIS_THETA, force=True)
                self.interpreter.relax_disp.plot_disp_curves(dir=path, y_axis=Y_AXIS_R2_R1RHO, x_axis=X_AXIS_W_EFF, force=True)
                self.interpreter.relax_disp.plot_disp_curves(dir=path, y_axis=Y_AXIS_R2_EFF, x_axis=X_AXIS_THETA, interpolate=INTERPOLATE_OFFSET, force=True)

            # The calculation of theta and w_eff parameter in R1rho experiments.
            if model in MODEL_LIST_R1RHO_FULL:
                self.interpreter.value.write(param='theta', file='theta.out', dir=path, force=True)
                self.interpreter.value.write(param='w_eff', file='w_eff.out', dir=path, force=True)

        # The pA and pB parameters.
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='pA')
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='pB')

        # The pC parameter.
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='pC')

        # The phi_ex parameter.
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='phi_ex')

        # The phi_ex_B nd phi_ex_C parameters.
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='phi_ex_B')
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='phi_ex_C')

        # The dw parameter.
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='dw')

        # The dw_AB, dw_BC and dw_AC parameter.
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='dw_AB')
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='dw_BC')
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='dw_AC')

        # The dwH parameter.
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='dwH')

        # The dwH_AB, dwH_BC and dwH_AC parameter.
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='dwH_AB')
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='dwH_BC')
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='dwH_AC')

        # The k_AB, kex and tex parameters.
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='k_AB')
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='kex')
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='tex')

        # The kex_AB, kex_BC, kex_AC parameters.
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='kex_AB')
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='kex_BC')
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='kex_AC')

        # The kB and kC parameters.
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='kB')
        self.write_results_test(path=path, model=model, models_tested=models_tested, param='kC')

        # Minimisation statistics.
        if not (model == MODEL_R2EFF and has_fixed_time_exp_type()):
            self.interpreter.value.write(param='chi2', file='chi2.out', dir=path, force=True)
            self.interpreter.grace.write(y_data_type='chi2', file='chi2.agr', dir=path, force=True)

        # Finally save the results.  This is last to allow the continuation of an interrupted analysis while ensuring that all results files have been created.
        self.interpreter.results.write(file='results', dir=path, force=True)