Esempio n. 1
0
    def add_offset(self, index):
        """Add the offset info to the element.

        @param index:   The column index for the data.
        @type index:    int
        @return:        True if the data exists, False otherwise.
        @rtype:         bool
        """

        # Append a column.
        self.element.InsertColumn(index, u("Offset \u03C9_rf (ppm)"))

        # No data.
        if not hasattr(cdp, 'spectrum_ids'):
            return True

        # Set the values.
        for i in range(len(cdp.spectrum_ids)):
            if hasattr(cdp, 'spin_lock_offset'
                       ) and cdp.spectrum_ids[i] in cdp.spin_lock_offset:
                if dep_check.wx_classic:
                    self.element.SetStringItem(
                        i, index,
                        float_to_gui(
                            cdp.spin_lock_offset[cdp.spectrum_ids[i]]))
                else:
                    self.element.SetItem(
                        i, index,
                        float_to_gui(
                            cdp.spin_lock_offset[cdp.spectrum_ids[i]]))

        # Successful.
        return True
Esempio n. 2
0
    def add_disp_point(self, index):
        """Add the dispersion point info to the element.

        This is either the CPMG pulse frequency or the spin-lock field strength.  Both share the same column.

        @param index:   The column index for the data.
        @type index:    int
        @return:        True if the data exists, False otherwise.
        @rtype:         bool
        """

        # Append a column.
        self.element.InsertColumn(index, u("\u03BDCPMG (Hz) or Spin-lock \u03BD1 (Hz)"))

        # No data.
        if not hasattr(cdp, 'spectrum_ids'):
            return True

        # Set the values.
        for i in range(len(cdp.spectrum_ids)):
            # Set the CPMG frequency.
            if hasattr(cdp, 'cpmg_frqs') and cdp.spectrum_ids[i] in cdp.cpmg_frqs:
                self.element.SetStringItem(i, index, float_to_gui(cdp.cpmg_frqs[cdp.spectrum_ids[i]]))

            # Set the spin-lock field strength.
            if hasattr(cdp, 'spin_lock_nu1') and cdp.spectrum_ids[i] in cdp.spin_lock_nu1:
                self.element.SetStringItem(i, index, float_to_gui(cdp.spin_lock_nu1[cdp.spectrum_ids[i]]))

        # Successful.
        return True
Esempio n. 3
0
    def add_exp_type(self, index):
        """Add the experiment type info to the element.

        @param index:   The column index for the data.
        @type index:    int
        @return:        True if the data exists, False otherwise.
        @rtype:         bool
        """

        # Append a column.
        self.element.InsertColumn(index, u("Experiment type"))

        # No data.
        if not hasattr(cdp, 'spectrum_ids') or not hasattr(cdp, 'exp_type'):
            return True

        # Set the values.
        for i in range(len(cdp.spectrum_ids)):
            # No value.
            if cdp.spectrum_ids[i] not in cdp.exp_type:
                continue

            # Set the value.
            if dep_check.wx_classic:
                self.element.SetStringItem(
                    i, index, float_to_gui(cdp.exp_type[cdp.spectrum_ids[i]]))
            else:
                self.element.SetItem(
                    i, index, float_to_gui(cdp.exp_type[cdp.spectrum_ids[i]]))

        # Successful.
        return True
Esempio n. 4
0
    def relax_times(self, index):
        """Add the relaxation delay time info to the element.

        @param index:   The column index for the data.
        @type index:    int
        @return:        True if relaxation times exist, False otherwise.
        @rtype:         bool
        """

        # No type info.
        if not hasattr(cdp, 'relax_times') or not len(cdp.relax_times):
            return False

        # Append a column.
        self.element.InsertColumn(index, str_to_gui("Delay times (s)"))

        # No data.
        if not hasattr(cdp, 'spectrum_ids'):
            return True

        # Set the values.
        for i in range(len(cdp.spectrum_ids)):
            # No value.
            if cdp.spectrum_ids[i] not in cdp.relax_times:
                continue

            # Set the value.
            self.element.SetStringItem(
                i, index, float_to_gui(cdp.relax_times[cdp.spectrum_ids[i]]))

        # Successful.
        return True
Esempio n. 5
0
    def sync_ds(self, upload=False):
        """Synchronise the analysis frame and the relax data store, both ways.

        This method allows the frame information to be uploaded into the relax data store, or for the information in the relax data store to be downloaded by the frame.

        @keyword upload:    A flag which if True will cause the frame to send data to the relax data store.  If False, data will be downloaded from the relax data store to update the frame.
        @type upload:       bool
        """

        # The numeric solution only flag.
        if upload:
            self.data.numeric_only = self.numeric_only.GetValue()
        elif hasattr(self.data, 'numeric_only'):
            self.numeric_only.SetValue(bool(self.data.numeric_only))

        # The grid incs.
        if upload:
            self.data.grid_inc = gui_to_int(self.grid_inc.GetValue())
        elif hasattr(self.data, 'grid_inc'):
            self.grid_inc.SetValue(int(self.data.grid_inc))

        # The MC sim number.
        if upload:
            self.data.mc_sim_num = gui_to_int(self.mc_sim_num.GetValue())
        elif hasattr(self.data, 'mc_sim_num'):
            self.mc_sim_num.SetValue(int(self.data.mc_sim_num))

        # The All model MC sim flag.
        if upload:
            self.data.mc_sim_all_models = self.mc_sim_all_models.GetValue()
        elif hasattr(self.data, 'mc_sim_all_models'):
            self.mc_sim_all_models.SetValue(bool(self.data.mc_sim_all_models))

        # The insignificance level.
        if upload:
            self.data.insignificance = self.insignificance.GetValue()
            try:
                self.data.insignificance = gui_to_float(self.data.insignificance)
            except:
                pass
        elif hasattr(self.data, 'insignificance'):
            self.insignificance.SetValue(float_to_gui(self.data.insignificance))

        # The results directory.
        if upload:
            self.data.save_dir = gui_to_str(self.field_results_dir.GetValue())
        else:
            self.field_results_dir.SetValue(str_to_gui(self.data.save_dir))

        # The previous run results directory.
        if upload:
            self.data.pre_run_dir = gui_to_str(self.field_pre_run_dir.GetValue())
        elif hasattr(self.data, 'pre_run_dir'):
            self.field_pre_run_dir.SetValue(str_to_gui(self.data.pre_run_dir))

        # The models to use.
        if upload:
            self.data.disp_models = self.model_field.GetValue()
        else:
            self.model_field.set_value(self.data.disp_models)
Esempio n. 6
0
    def relax_times(self, index):
        """Add the relaxation delay time info to the element.

        @param index:   The column index for the data.
        @type index:    int
        @return:        True if relaxation times exist, False otherwise.
        @rtype:         bool
        """

        # No type info.
        if not hasattr(cdp, 'relax_times') or not len(cdp.relax_times):
            return False

        # Append a column.
        self.element.InsertColumn(index, str_to_gui("Delay times (s)"))

        # No data.
        if not hasattr(cdp, 'spectrum_ids'):
            return True

        # Set the values.
        for i in range(len(cdp.spectrum_ids)):
            # No value.
            if cdp.spectrum_ids[i] not in cdp.relax_times:
                continue

            # Set the value.
            self.element.SetStringItem(i, index, float_to_gui(cdp.relax_times[cdp.spectrum_ids[i]]))

        # Successful.
        return True
    def test_value_set(self):
        """Test the full operation of the value.set user function GUI window."""

        # Open the pipe.create user function window, set the args and execute.
        uf = uf_store['pipe.create']
        uf._sync = True
        uf.create_wizard(parent=self.app.gui)
        uf.page.SetValue('pipe_name', str_to_gui('value.set user function test'))
        uf.page.SetValue('pipe_type', str_to_gui('mf'))
        uf.wizard._go_next(None)

        # Create a spin to add data to.
        uf = uf_store['spin.create']
        uf._sync = True
        uf.create_wizard(parent=self.app.gui)
        uf.page.SetValue('res_num', int_to_gui(1))
        uf.page.SetValue('res_name', str_to_gui('Gly'))
        uf.page.SetValue('spin_name', str_to_gui('N'))
        uf.wizard._go_next(None)

        # Open the value.set user function window.
        uf = uf_store['value.set']
        uf._sync = True
        uf.create_wizard(parent=self.app.gui)
        uf.page.SetValue('val', float_to_gui(-0.000172))
        uf.page.SetValue('param', str_to_gui('csa'))
        uf.wizard._go_next(None)
Esempio n. 8
0
    def add_frqs(self, index):
        """Add the spectrometer frequency info to the element.

        @param index:   The column index for the data.
        @type index:    int
        @return:        True if the frequency data exists, False otherwise.
        @rtype:         bool
        """

        # Append a column.
        self.element.InsertColumn(index, u("\u03C9H (MHz)"))

        # No data.
        if not hasattr(cdp, 'spectrum_ids'):
            return True
        if not hasattr(cdp, 'spectrometer_frq') or not len(cdp.spectrometer_frq):
            return True

        # Set the values.
        for i in range(len(cdp.spectrum_ids)):
            # No value.
            if cdp.spectrum_ids[i] not in cdp.spectrometer_frq:
                continue

            # Set the value (in MHz).
            self.element.SetStringItem(i, index, float_to_gui(cdp.spectrometer_frq[cdp.spectrum_ids[i]]/1e6))

        # Successful.
        return True
Esempio n. 9
0
    def add_exp_type(self, index):
        """Add the experiment type info to the element.

        @param index:   The column index for the data.
        @type index:    int
        @return:        True if the data exists, False otherwise.
        @rtype:         bool
        """

        # Append a column.
        self.element.InsertColumn(index, u("Experiment type"))

        # No data.
        if not hasattr(cdp, 'spectrum_ids') or not hasattr(cdp, 'exp_type'):
            return True

        # Set the values.
        for i in range(len(cdp.spectrum_ids)):
            # No value.
            if cdp.spectrum_ids[i] not in cdp.exp_type:
                continue

            # Set the value.
            self.element.SetStringItem(i, index, float_to_gui(cdp.exp_type[cdp.spectrum_ids[i]]))

        # Successful.
        return True
Esempio n. 10
0
    def test(self):
        """Run the test."""

        # Get the App.
        app = wx.GetApp()

        # Repetitive calling of the align_tensor.init user function.
        for i in self.muppy_loop():
            # First reset relax.
            self._execute_uf(uf_name='reset')

            # Set up a data pipe.
            self._execute_uf(uf_name='pipe.create', pipe_name='GUI uf test', pipe_type='N-state')

            # Open the align_tensor.init user function window.
            uf = uf_store['align_tensor.init']
            uf._sync = True
            uf.create_wizard(parent=app.gui)

            # Set the parameters.
            uf.page.uf_args['params'].SetValue(str_to_gui('(0.00000, -0.00017, 0.00016, 0.00060, -0.00019)'))
            uf.page.uf_args['params'].selection_win_show()
            uf.page.uf_args['params'].sel_win.sequence.SetStringItem(0, 1, float_to_gui(0.00037))
            uf.page.uf_args['params'].selection_win_data()

            # Set up the other tensor data.
            uf.page.uf_args['tensor'].SetValue(str_to_gui('Dy'))
            uf.page.uf_args['align_id'].SetValue(str_to_gui('Dy'))

            # Execute.
            uf.wizard._go_next(None)

            # Destroy the user function object.
            uf.Destroy()
Esempio n. 11
0
    def update_data(self):
        """Method called from self.build_element_safe() to update the list data."""

        # Translation table for the Rx data types.
        table = {
            "NOE": "Steady-state NOE",
            "R1": "%s longitudinal relaxation" % r1,
            "R2": "%s transverse relaxation" % r2
        }

        # Expand the number of rows to match the number of relaxation IDs, and add the IDs.
        n = 0
        if hasattr(cdp, 'ri_ids'):
            # The number of IDs.
            n = len(cdp.ri_ids)

            # Add all the data.
            for i in range(n):
                # Set the IDs.
                id = cdp.ri_ids[i]
                self.element.InsertStringItem(i, str_to_gui(id))

                # Set the data types.
                self.element.SetStringItem(i, 1, str_to_gui(table[cdp.ri_type[id]]))

                # Set the frequencies.
                self.element.SetStringItem(i, 2, float_to_gui(cdp.spectrometer_frq[id]))
Esempio n. 12
0
    def update_data(self):
        """Method called from self.build_element_safe() to update the list data."""

        # Translation table for the Rx data types.
        table = {
            "NOE": "Steady-state NOE",
            "R1": "%s longitudinal relaxation" % r1,
            "R2": "%s transverse relaxation" % r2
        }

        # Expand the number of rows to match the number of relaxation IDs, and add the IDs.
        n = 0
        if hasattr(cdp, 'ri_ids'):
            # The number of IDs.
            n = len(cdp.ri_ids)

            # Add all the data.
            for i in range(n):
                # Set the IDs.
                id = cdp.ri_ids[i]
                self.element.InsertStringItem(i, str_to_gui(id))

                # Set the data types.
                self.element.SetStringItem(i, 1,
                                           str_to_gui(table[cdp.ri_type[id]]))

                # Set the frequencies.
                self.element.SetStringItem(
                    i, 2, float_to_gui(cdp.spectrometer_frq[id]))
Esempio n. 13
0
    def add_frqs(self, index):
        """Add the spectrometer frequency info to the element.

        @param index:   The column index for the data.
        @type index:    int
        @return:        True if the frequency data exists, False otherwise.
        @rtype:         bool
        """

        # Append a column.
        self.element.InsertColumn(index, u("\u03C9H (MHz)"))

        # No data.
        if not hasattr(cdp, 'spectrum_ids'):
            return True
        if not hasattr(cdp, 'spectrometer_frq') or not len(
                cdp.spectrometer_frq):
            return True

        # Set the values.
        for i in range(len(cdp.spectrum_ids)):
            # No value.
            if cdp.spectrum_ids[i] not in cdp.spectrometer_frq:
                continue

            # Set the value (in MHz).
            self.element.SetStringItem(
                i, index,
                float_to_gui(cdp.spectrometer_frq[cdp.spectrum_ids[i]] / 1e6))

        # Successful.
        return True
Esempio n. 14
0
    def add_disp_point(self, index):
        """Add the dispersion point info to the element.

        This is either the CPMG pulse frequency or the spin-lock field strength.  Both share the same column.

        @param index:   The column index for the data.
        @type index:    int
        @return:        True if the data exists, False otherwise.
        @rtype:         bool
        """

        # Append a column.
        self.element.InsertColumn(
            index, u("\u03BDCPMG (Hz) or Spin-lock \u03BD1 (Hz)"))

        # No data.
        if not hasattr(cdp, 'spectrum_ids'):
            return True

        # Set the values.
        for i in range(len(cdp.spectrum_ids)):
            # Set the CPMG frequency.
            if hasattr(cdp,
                       'cpmg_frqs') and cdp.spectrum_ids[i] in cdp.cpmg_frqs:
                if dep_check.wx_classic:
                    self.element.SetStringItem(
                        i, index,
                        float_to_gui(cdp.cpmg_frqs[cdp.spectrum_ids[i]]))
                else:
                    self.element.SetItem(
                        i, index,
                        float_to_gui(cdp.cpmg_frqs[cdp.spectrum_ids[i]]))

            # Set the spin-lock field strength.
            if hasattr(cdp, 'spin_lock_nu1'
                       ) and cdp.spectrum_ids[i] in cdp.spin_lock_nu1:
                if dep_check.wx_classic:
                    self.element.SetStringItem(
                        i, index,
                        float_to_gui(cdp.spin_lock_nu1[cdp.spectrum_ids[i]]))
                else:
                    self.element.SetItem(
                        i, index,
                        float_to_gui(cdp.spin_lock_nu1[cdp.spectrum_ids[i]]))

        # Successful.
        return True
Esempio n. 15
0
    def setup_page(self, page=None, **kargs):
        """Allow a specified user function page to be remotely set up.

        @keyword page:  The page to setup.  This is the page index key.
        @type page:     str
        """

        # Get the page.
        page = self.get_page(self.page_indices[page])

        # Loop over the keyword arguments and set them.
        for arg in kargs:
            # The value.
            value = kargs[arg]
            if isinstance(value, str):
                value = str_to_gui(value)
            elif is_float(value):
                value = float_to_gui(value)

            # Set the argument.
            page.SetValue(arg, value)
Esempio n. 16
0
    def setup_page(self, page=None, **kargs):
        """Allow a specified user function page to be remotely set up.

        @keyword page:  The page to setup.  This is the page index key.
        @type page:     str
        """

        # Get the page.
        page = self.get_page(self.page_indices[page])

        # Loop over the keyword arguments and set them.
        for arg in kargs:
            # The value.
            value = kargs[arg]
            if isinstance(value, str):
                value = str_to_gui(value)
            elif is_float(value):
                value = float_to_gui(value)

            # Set the argument.
            page.SetValue(arg, value)
Esempio n. 17
0
    def test_value_set(self):
        """Test the full operation of the value.set user function GUI window."""

        # Create the data pipe.
        self.exec_uf_pipe_create(pipe_name='value.set user function test')

        # Create a spin to add data to.
        uf = uf_store['spin.create']
        uf._sync = True
        uf.create_wizard(parent=self.app.gui)
        uf.page.SetValue('res_num', int_to_gui(1))
        uf.page.SetValue('res_name', str_to_gui('Gly'))
        uf.page.SetValue('spin_name', str_to_gui('N'))
        uf.wizard._go_next(None)

        # Open the value.set user function window.
        uf = uf_store['value.set']
        uf._sync = True
        uf.create_wizard(parent=self.app.gui)
        uf.page.SetValue('val', float_to_gui(-0.000172))
        uf.page.SetValue('param', str_to_gui('csa'))
        uf.wizard._go_next(None)
Esempio n. 18
0
    def add_offset(self, index):
        """Add the offset info to the element.

        @param index:   The column index for the data.
        @type index:    int
        @return:        True if the data exists, False otherwise.
        @rtype:         bool
        """

        # Append a column.
        self.element.InsertColumn(index, u("Offset \u03C9_rf (ppm)"))

        # No data.
        if not hasattr(cdp, 'spectrum_ids'):
            return True

        # Set the values.
        for i in range(len(cdp.spectrum_ids)):
            if hasattr(cdp, 'spin_lock_offset') and cdp.spectrum_ids[i] in cdp.spin_lock_offset:
                self.element.SetStringItem(i, index, float_to_gui(cdp.spin_lock_offset[cdp.spectrum_ids[i]]))

        # Successful.
        return True
Esempio n. 19
0
    def sync_ds(self, upload=False):
        """Synchronise the analysis frame and the relax data store, both ways.

        This method allows the frame information to be uploaded into the relax data store, or for the information in the relax data store to be downloaded by the frame.

        @keyword upload:    A flag which if True will cause the frame to send data to the relax data store.  If False, data will be downloaded from the relax data store to update the frame.
        @type upload:       bool
        """

        # The R1 parameter fitting flag.
        if upload:
            self.data.r1_fit = self.r1_fit.GetValue()
        elif hasattr(self.data, 'r1_fit'):
            self.r1_fit.SetValue(bool(self.data.r1_fit))

        # The numeric solution only flag.
        if upload:
            self.data.numeric_only = self.numeric_only.GetValue()
        elif hasattr(self.data, 'numeric_only'):
            self.numeric_only.SetValue(bool(self.data.numeric_only))

        # The grid incs.
        if upload:
            self.data.grid_inc = gui_to_int(self.grid_inc.GetValue())
        elif hasattr(self.data, 'grid_inc'):
            if self.data.grid_inc == None:
                self.data.grid_inc = default_grid_inc
            self.grid_inc.SetValue(int(self.data.grid_inc))

        # The MC sim number.
        if upload:
            self.data.mc_sim_num = gui_to_int(self.mc_sim_num.GetValue())
        elif hasattr(self.data, 'mc_sim_num'):
            if self.data.mc_sim_num == None:
                self.data.mc_sim_num = default_mc_sim_num
            self.mc_sim_num.SetValue(int(self.data.mc_sim_num))

        # The EXP MC sim number.
        if upload:
            self.data.exp_mc_sim_num = gui_to_int(self.exp_mc_sim_num.GetValue())
        elif hasattr(self.data, 'exp_mc_sim_num'):
            if self.data.exp_mc_sim_num == None:
                self.data.exp_mc_sim_num = default_exp_mc_sim_num
            self.exp_mc_sim_num.SetValue(int(self.data.exp_mc_sim_num))

        # The All model MC sim flag.
        if upload:
            self.data.mc_sim_all_models = self.mc_sim_all_models.GetValue()
        elif hasattr(self.data, 'mc_sim_all_models'):
            self.mc_sim_all_models.SetValue(bool(self.data.mc_sim_all_models))

        # The insignificance level.
        if upload:
            self.data.insignificance = self.insignificance.GetValue()
            try:
                self.data.insignificance = gui_to_float(self.data.insignificance)
            except:
                pass
        elif hasattr(self.data, 'insignificance'):
            self.insignificance.SetValue(float_to_gui(self.data.insignificance))

        # The results directory.
        if upload:
            self.data.save_dir = gui_to_str(self.field_results_dir.GetValue())
        else:
            self.field_results_dir.SetValue(str_to_gui(self.data.save_dir))

        # The previous run results directory.
        if upload:
            self.data.pre_run_dir = gui_to_str(self.field_pre_run_dir.GetValue())
        elif hasattr(self.data, 'pre_run_dir'):
            self.field_pre_run_dir.SetValue(str_to_gui(self.data.pre_run_dir))

        # The models to use.
        if upload:
            self.data.disp_models = self.model_field.GetValue()
        else:
            self.model_field.set_value(self.data.disp_models)
Esempio n. 20
0
    def test_r1_analysis(self):
        """Test the r1 analysis."""

        # The path to the data files.
        data_path = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'curve_fitting' + sep

        # Simulate the new analysis wizard.
        analysis = self.new_analysis_wizard(analysis_type='r1')

        # The frequency label.
        analysis.field_nmr_frq.SetValue(str_to_gui('600'))

        # Change the results directory.
        analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir))

        # Load the sequence.
        file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'Ap4Aase.seq'
        self._execute_uf(uf_name='sequence.read', file=file, mol_name_col=None, res_name_col=2, res_num_col=1, spin_name_col=None, spin_num_col=None)

        # Unresolved spins.
        self._execute_uf(uf_name='deselect.read', file=data_path+'unresolved', mol_name_col=None, res_name_col=None, res_num_col=1, spin_name_col=None, spin_num_col=None, change_all=True)

        # Name the spins.
        self._execute_uf(uf_name='spin.name', name='N')

        # Flush the interpreter in preparation for the synchronous user functions of the peak list wizard.
        interpreter.flush()

        # Spectrum names.
        names = [
            'T2_ncyc1_ave',
            'T2_ncyc1b_ave',
            'T2_ncyc2_ave',
            'T2_ncyc4_ave',
            'T2_ncyc4b_ave',
            'T2_ncyc6_ave',
            'T2_ncyc9_ave',
            'T2_ncyc9b_ave',
            'T2_ncyc11_ave',
            'T2_ncyc11b_ave'
        ]

        # Replicated spectra.
        replicated = {
            'T2_ncyc1b_ave': 'T2_ncyc1_ave',
            'T2_ncyc4b_ave': 'T2_ncyc4_ave',
            'T2_ncyc9b_ave': 'T2_ncyc9_ave',
            'T2_ncyc11b_ave': 'T2_ncyc11_ave'
        }

        # Number of cycles.
        ncyc = [1,
                1,
                2,
                4,
                4,
                6,
                9,
                9,
                11,
                11
        ]

        # The delay time.
        time = 0.0176

        # Add the spectra and number of cycles.
        for i in range(len(names)):
            # Set up the peak intensity wizard.
            analysis.peak_wizard_launch(None)
            wizard = analysis.peak_wizard

            # The spectrum.
            page = wizard.get_page(wizard.page_indices['read'])
            page.uf_args['file'].SetValue(str_to_gui("%s%s.list" % (data_path, names[i])))
            page.uf_args['spectrum_id'].SetValue(str_to_gui(names[i]))

            # Go to the next page.
            wizard._go_next(None)

            # The error type.
            page = wizard.get_page(wizard.page_indices['err_type'])
            page.selection = 'repl'

            # Go to the next page.
            wizard._go_next(None)

            # Replicated spectra:
            if names[i] in replicated:
                page = wizard.get_page(wizard.page_indices['repl'])
                page.uf_args['spectrum_ids'].SetValue(value=replicated[names[i]], index=1)

            # Go to the next page.
            wizard._go_next(None)

            # Set the delay ime.
            page = wizard.get_page(wizard.page_indices['relax_time'])
            page.uf_args['time'].SetValue(float_to_gui(ncyc[i]*time))

            # Go to the next page (i.e. finish).
            wizard._go_next(None)

        # Set up the nuclear isotopes.
        analysis.select_model()
        uf_store['relax_fit.select_model'].wizard._go_next()
        interpreter.flush()    # Required because of the asynchronous uf call.

        # Set the number of MC sims.
        analysis.mc_sim_num.SetValue(3)

        # Execute relax.
        analysis.execute(wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, analysis.button_exec_relax.GetId()))

        # Wait for execution to complete.
        analysis.thread.join()

        # Flush all wx events.
        wx.Yield()

        # Exceptions in the thread.
        self.check_exceptions()

        # Check the relax controller.
        # FIXME: skipping the checks for certain wxPython bugs.
        if status.relax_mode != 'gui' and wx.version() != '2.9.4.1 gtk2 (classic)':
            self.assertEqual(self.app.gui.controller.mc_gauge_rx.GetValue(), 100)
            self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100)

        # Check the data pipe.
        self.assertEqual(cdp_name(), ds.relax_gui.analyses[0].pipe_name)

        # Check the data.
        self.check_curve_fitting()

        # Check the created files.
        self.assert_(access(ds.tmpdir+sep+'r1.600.out', F_OK))
        self.assert_(access(ds.tmpdir+sep+'results.bz2', F_OK))
        self.assert_(access(ds.tmpdir+sep+'r1.600.save.bz2', F_OK))
        self.assert_(access(ds.tmpdir+sep+'grace'+sep+'r1.600.agr', F_OK))
        self.assert_(access(ds.tmpdir+sep+'grace'+sep+'chi2.agr', F_OK))
        self.assert_(access(ds.tmpdir+sep+'grace'+sep+'i0.agr', F_OK))
        self.assert_(access(ds.tmpdir+sep+'grace'+sep+'intensities.agr', F_OK))
        self.assert_(access(ds.tmpdir+sep+'grace'+sep+'intensities_norm.agr', F_OK))
Esempio n. 21
0
    def test_r1_analysis(self):
        """Test the r1 analysis."""

        # The path to the data files.
        data_path = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'curve_fitting' + sep

        # Simulate the new analysis wizard.
        analysis = self.new_analysis_wizard(analysis_type='r1')

        # The frequency label.
        analysis.field_nmr_frq.SetValue(str_to_gui('600'))

        # Change the results directory.
        analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir))

        # Load the sequence.
        file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'Ap4Aase.seq'
        self._execute_uf(uf_name='sequence.read',
                         file=file,
                         mol_name_col=None,
                         res_name_col=2,
                         res_num_col=1,
                         spin_name_col=None,
                         spin_num_col=None)

        # Unresolved spins.
        self._execute_uf(uf_name='deselect.read',
                         file=data_path + 'unresolved',
                         mol_name_col=None,
                         res_name_col=None,
                         res_num_col=1,
                         spin_name_col=None,
                         spin_num_col=None,
                         change_all=True)

        # Name the spins.
        self._execute_uf(uf_name='spin.name', name='N')

        # Flush the interpreter in preparation for the synchronous user functions of the peak list wizard.
        interpreter.flush()

        # Spectrum names.
        names = [
            'T2_ncyc1_ave', 'T2_ncyc1b_ave', 'T2_ncyc2_ave', 'T2_ncyc4_ave',
            'T2_ncyc4b_ave', 'T2_ncyc6_ave', 'T2_ncyc9_ave', 'T2_ncyc9b_ave',
            'T2_ncyc11_ave', 'T2_ncyc11b_ave'
        ]

        # Replicated spectra.
        replicated = {
            'T2_ncyc1b_ave': 'T2_ncyc1_ave',
            'T2_ncyc4b_ave': 'T2_ncyc4_ave',
            'T2_ncyc9b_ave': 'T2_ncyc9_ave',
            'T2_ncyc11b_ave': 'T2_ncyc11_ave'
        }

        # Number of cycles.
        ncyc = [1, 1, 2, 4, 4, 6, 9, 9, 11, 11]

        # The delay time.
        time = 0.0176

        # Add the spectra and number of cycles.
        for i in range(len(names)):
            # Set up the peak intensity wizard.
            analysis.peak_wizard_launch(None)
            wizard = analysis.peak_wizard

            # The spectrum.
            page = wizard.get_page(wizard.page_indices['read'])
            page.uf_args['file'].SetValue(
                str_to_gui("%s%s.list" % (data_path, names[i])))
            page.uf_args['spectrum_id'].SetValue(str_to_gui(names[i]))

            # Go to the next page.
            wizard._go_next(None)

            # The error type.
            page = wizard.get_page(wizard.page_indices['err_type'])
            page.selection = 'repl'

            # Go to the next page.
            wizard._go_next(None)

            # Replicated spectra:
            if names[i] in replicated:
                page = wizard.get_page(wizard.page_indices['repl'])
                page.uf_args['spectrum_ids'].SetValue(
                    value=replicated[names[i]], index=1)

            # Go to the next page.
            wizard._go_next(None)

            # Set the delay ime.
            page = wizard.get_page(wizard.page_indices['relax_time'])
            page.uf_args['time'].SetValue(float_to_gui(ncyc[i] * time))

            # Go to the next page (i.e. finish).
            wizard._go_next(None)

        # Set up the nuclear isotopes.
        analysis.select_model()
        uf_store['relax_fit.select_model'].wizard._go_next()
        interpreter.flush()  # Required because of the asynchronous uf call.

        # Set the number of MC sims.
        analysis.mc_sim_num.SetValue(3)

        # Execute relax.
        analysis.execute(
            wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED,
                            analysis.button_exec_relax.GetId()))

        # Wait for execution to complete.
        analysis.thread.join()

        # Flush all wx events.
        wx.Yield()

        # Exceptions in the thread.
        self.check_exceptions()

        # Check the relax controller.
        # FIXME: skipping the checks for certain wxPython bugs.
        if status.relax_mode != 'gui' and wx.version(
        ) != '2.9.4.1 gtk2 (classic)':
            self.assertEqual(self.app.gui.controller.mc_gauge_rx.GetValue(),
                             100)
            self.assertEqual(self.app.gui.controller.main_gauge.GetValue(),
                             100)

        # Check the data pipe.
        self.assertEqual(cdp_name(), ds.relax_gui.analyses[0].pipe_name)

        # Check the data.
        self.check_curve_fitting()

        # Check the created files.
        self.assert_(access(ds.tmpdir + sep + 'r1.600.out', F_OK))
        self.assert_(access(ds.tmpdir + sep + 'results.bz2', F_OK))
        self.assert_(access(ds.tmpdir + sep + 'state.bz2', F_OK))
        self.assert_(
            access(ds.tmpdir + sep + 'grace' + sep + 'r1.600.agr', F_OK))
        self.assert_(access(ds.tmpdir + sep + 'grace' + sep + 'chi2.agr',
                            F_OK))
        self.assert_(access(ds.tmpdir + sep + 'grace' + sep + 'i0.agr', F_OK))
        self.assert_(
            access(ds.tmpdir + sep + 'grace' + sep + 'intensities.agr', F_OK))
        self.assert_(
            access(ds.tmpdir + sep + 'grace' + sep + 'intensities_norm.agr',
                   F_OK))
Esempio n. 22
0
    def test_bug_20889_multi_col_peak_list(self):
        """Test catching U{bug #20889<https://web.archive.org/web/https://gna.org/bugs/?20889>}, the custom peak intensity reading with a list of spectrum_ids submitted by Troels E. Linnet."""

        # The path to the files.
        path = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'peak_lists' + sep

        # Simulate the new analysis wizard, selecting the fixed time CPMG experiment.
        analysis = self.new_analysis_wizard(analysis_type='disp')

        # Change the results directory.
        analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir))

        # Load the sequence.
        file = path + 'test.seq'
        self._execute_uf(uf_name='sequence.read',
                         file=file,
                         mol_name_col=1,
                         res_name_col=3,
                         res_num_col=2,
                         spin_name_col=5,
                         spin_num_col=4)

        # Flush the interpreter in preparation for the synchronous user functions of the peak list wizard.
        interpreter.flush()

        # Set up the nuclear isotopes.
        analysis.spin_isotope()
        uf_store['spin.isotope'].page.SetValue('spin_id', '')
        uf_store['spin.isotope'].wizard._go_next()
        interpreter.flush()  # Required because of the asynchronous uf call.

        # Set up the peak intensity wizard.
        analysis.peak_wizard_launch(None)
        wizard = analysis.peak_wizard

        # The spectrum.
        page = wizard.get_page(wizard.page_indices['read'])
        page.uf_args['file'].SetValue(str_to_gui("%stest.seq" % path))
        page.uf_args['spectrum_id'].SetValue(['0_2', '1_0'])
        page.uf_args['int_col'].SetValue([6, 7])
        wizard._go_next(None)

        # The error type.
        page = wizard.get_page(wizard.page_indices['err_type'])
        page.selection = 'rmsd'
        wizard._go_next(None)

        # Set the RMSD.
        page = wizard.get_page(wizard.page_indices['rmsd'])
        page.uf_args['error'].SetValue(float_to_gui(3000.0))
        wizard._ok(None)

        # The peak intensities.
        data_2 = [
            337765.90000000002, 1697771.0, 867389.80000000005, 2339480.0,
            2574062.0, 1609356.0, 2179341.0, 1563795.0, 1535896.0, 3578841.0
        ]
        data_0 = [
            636244.59999999998, 3015788.0, 1726064.0, 4039142.0, 4313824.0,
            2927111.0, 4067343.0, 2921316.0, 3005234.0, 6352595.0
        ]

        # Data checks.
        for i in range(len(cdp.mol[0].res)):
            # Alias the spin.
            spin = cdp.mol[0].res[i].spin[0]

            # The intensities.
            self.assertEqual(spin.peak_intensity['1_0'], data_0[i])
            self.assertEqual(spin.peak_intensity['0_2'], data_2[i])

            # The errors.
            self.assert_(hasattr(spin, 'baseplane_rmsd'))
            self.assertEqual(spin.baseplane_rmsd['0_2'], 3000.0)
    def test(self):
        """Run the test."""

        # Get the App.
        app = wx.GetApp()

        # Repetitive calling of the align_tensor.init user function.
        for i in self.muppy_loop():
            # First reset relax.
            self._execute_uf(uf_name='reset')

            # Set up a data pipe.
            self._execute_uf(uf_name='pipe.create', pipe_name='GUI uf test', pipe_type='N-state')

            # Open the align_tensor.init user function window.
            uf = uf_store['align_tensor.init']
            uf._sync = True
            uf.create_wizard(parent=app.gui)

            # Set the parameters.
            uf.page.uf_args['params'].SetValue(str_to_gui('(0.00000, -0.00017, 0.00016, 0.00060, -0.00019)'))
            uf.page.uf_args['params'].selection_win_show()
            uf.page.uf_args['params'].sel_win.sequence.SetStringItem(index=0, col=1, label=float_to_gui(0.00037))
            uf.page.uf_args['params'].selection_win_data()

            # Set up the other tensor data.
            uf.page.uf_args['tensor'].SetValue(str_to_gui('Dy'))
            uf.page.uf_args['align_id'].SetValue(str_to_gui('Dy'))

            # Execute.
            uf.wizard._go_next(None)

            # Destroy the user function object.
            uf.Destroy()
Esempio n. 24
0
    def test_bug_20889_multi_col_peak_list(self):
        """Test catching U{bug #20889<https://gna.org/bugs/?20889>}, the custom peak intensity reading with a list of spectrum_ids submitted by Troels E. Linnet."""

        # The path to the files.
        path = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'peak_lists' + sep

        # Simulate the new analysis wizard, selecting the fixed time CPMG experiment.
        analysis = self.new_analysis_wizard(analysis_type='disp')

        # Change the results directory.
        analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir))

        # Load the sequence.
        file = path + 'test.seq'
        self._execute_uf(uf_name='sequence.read', file=file, mol_name_col=1, res_name_col=3, res_num_col=2, spin_name_col=5, spin_num_col=4)

        # Flush the interpreter in preparation for the synchronous user functions of the peak list wizard.
        interpreter.flush()

        # Set up the nuclear isotopes.
        analysis.spin_isotope()
        uf_store['spin.isotope'].page.SetValue('spin_id', '')
        uf_store['spin.isotope'].wizard._go_next()
        interpreter.flush()    # Required because of the asynchronous uf call.

        # Set up the peak intensity wizard.
        analysis.peak_wizard_launch(None)
        wizard = analysis.peak_wizard

        # The spectrum.
        page = wizard.get_page(wizard.page_indices['read'])
        page.uf_args['file'].SetValue(str_to_gui("%stest.seq" % path))
        page.uf_args['spectrum_id'].SetValue(['0_2', '1_0'])
        page.uf_args['int_col'].SetValue([6, 7])
        wizard._go_next(None)

        # The error type.
        page = wizard.get_page(wizard.page_indices['err_type'])
        page.selection = 'rmsd'
        wizard._go_next(None)

        # Set the RMSD.
        page = wizard.get_page(wizard.page_indices['rmsd'])
        page.uf_args['error'].SetValue(float_to_gui(3000.0))
        wizard._ok(None)

        # The peak intensities.
        data_2 = [337765.90000000002, 1697771.0, 867389.80000000005, 2339480.0, 2574062.0, 1609356.0, 2179341.0, 1563795.0, 1535896.0, 3578841.0]
        data_0 = [636244.59999999998, 3015788.0, 1726064.0, 4039142.0, 4313824.0, 2927111.0, 4067343.0, 2921316.0, 3005234.0, 6352595.0]

        # Data checks.
        for i in range(len(cdp.mol[0].res)):
            # Alias the spin.
            spin = cdp.mol[0].res[i].spin[0]

            # The intensities.
            self.assertEqual(spin.peak_intensity['1_0'], data_0[i])
            self.assertEqual(spin.peak_intensity['0_2'], data_2[i])

            # The errors.
            self.assert_(hasattr(spin, 'baseplane_rmsd'))
            self.assertEqual(spin.baseplane_rmsd['0_2'], 3000.0)