Ejemplo n.º 1
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()
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
    def set_vals(self):
        """Set the free file format widget contents to the values from the relax data store."""

        # The default GUI element.
        if self.element_type == 'default':
            # The column numbers.
            self.spin_id_col.SetValue(int_to_gui(ds.relax_gui.free_file_format.spin_id_col))
            self.mol_name_col.SetValue(int_to_gui(ds.relax_gui.free_file_format.mol_name_col))
            self.res_num_col.SetValue(int_to_gui(ds.relax_gui.free_file_format.res_num_col))
            self.res_name_col.SetValue(int_to_gui(ds.relax_gui.free_file_format.res_name_col))
            self.spin_num_col.SetValue(int_to_gui(ds.relax_gui.free_file_format.spin_num_col))
            self.spin_name_col.SetValue(int_to_gui(ds.relax_gui.free_file_format.spin_name_col))
            if hasattr(self, 'data_col'):
                self.data_col.SetValue(int_to_gui(ds.relax_gui.free_file_format.data_col))
            if hasattr(self, 'error_col'):
                self.error_col.SetValue(int_to_gui(ds.relax_gui.free_file_format.error_col))

            # The column separator.
            if not ds.relax_gui.free_file_format.sep:
                self.sep.SetValue(str_to_gui("white space"))
            else:
                self.sep.SetValue(str_to_gui(ds.relax_gui.free_file_format.sep))

        # The mini GUI element.
        elif self.element_type == 'mini':
            # The string.
            if self.data_cols:
                string = self.to_string(spin_id_col=ds.relax_gui.free_file_format.spin_id_col, mol_name_col=ds.relax_gui.free_file_format.mol_name_col, res_num_col=ds.relax_gui.free_file_format.res_num_col, res_name_col=ds.relax_gui.free_file_format.res_name_col, spin_num_col=ds.relax_gui.free_file_format.spin_num_col, spin_name_col=ds.relax_gui.free_file_format.spin_name_col, data_col=ds.relax_gui.free_file_format.data_col, error_col=ds.relax_gui.free_file_format.error_col, sep=ds.relax_gui.free_file_format.sep)
            else:
                string = self.to_string(spin_id_col=ds.relax_gui.free_file_format.spin_id_col, mol_name_col=ds.relax_gui.free_file_format.mol_name_col, res_num_col=ds.relax_gui.free_file_format.res_num_col, res_name_col=ds.relax_gui.free_file_format.res_name_col, spin_num_col=ds.relax_gui.free_file_format.spin_num_col, spin_name_col=ds.relax_gui.free_file_format.spin_name_col, sep=ds.relax_gui.free_file_format.sep)
            self.field.SetValue(str_to_gui(string))
Ejemplo n.º 4
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]))
Ejemplo 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 frequency.
        if upload:
            self.data.frq = gui_to_str(self.field_nmr_frq.GetValue())
        else:
            self.field_nmr_frq.SetValue(str_to_gui(self.data.frq))

        # 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 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))
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
    def refresh_safe(self):
        """Update the list of result files (thread safe)."""

        # Acquire the pipe lock.
        status.pipe_lock.acquire('results viewer window')
        try:
            # Update the data pipe selector.
            self.update_pipes()

            # Clear the list.
            self.file_list.DeleteAllItems()
            self.file_data = []

            # Nothing to do.
            if not hasattr(cdp, 'result_files'):
                return

            # Update the list.
            for i in range(len(cdp.result_files)):
                self.file_list.Append((str_to_gui(cdp.result_files[i][1]), str_to_gui(cdp.result_files[i][2])))
                self.file_data.append(cdp.result_files[i][0])

        # Release the locks.
        finally:
            status.pipe_lock.release('results viewer window')
Ejemplo n.º 8
0
    def update_data(self):
        """Method called from self.build_element_safe() to update the list data."""

        # 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 peak intensity types.
                if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'peak_intensity_type') and id in cdp.exp_info.peak_intensity_type:
                    self.element.SetStringItem(i, 1, str_to_gui(cdp.exp_info.peak_intensity_type[id]))

                # Set the temperature calibration methods.
                if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'temp_calibration') and id in cdp.exp_info.temp_calibration:
                    self.element.SetStringItem(i, 2, str_to_gui(cdp.exp_info.temp_calibration[id]))

                # Set the temperature control methods.
                if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'temp_control') and id in cdp.exp_info.temp_control:
                    self.element.SetStringItem(i, 3, str_to_gui(cdp.exp_info.temp_control[id]))
Ejemplo n.º 9
0
    def on_display(self):
        """Update the pipe name."""

        # Generate a name for the data pipe bundle based on the type and time.
        name = "%s (%s)" % (self.parent.analysis_type, asctime(localtime()))

        # Update the fields.
        self.pipe_name.SetValue(str_to_gui("origin - %s" % name))
        self.pipe_bundle.SetValue(str_to_gui(name))
Ejemplo n.º 10
0
    def test_bug_20152_read_dc_file(self):
        """Test the reading of a DC file, catching U{bug #20152<https://gna.org/bugs/?20152>}."""

        # Simulate the new analysis wizard.
        analysis = self.new_analysis_wizard(analysis_type='mf', analysis_name='Model-free test')

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

        # Launch the spin viewer window.
        self.app.gui.show_tree()

        # Spin loading wizard:  Initialisation.
        self.app.gui.spin_viewer.load_spins_wizard()

        # Spin loading wizard:  The PDB file.
        page = self.app.gui.spin_viewer.wizard.get_page(0)
        page.selection = 'new pdb'
        self.app.gui.spin_viewer.wizard._go_next()
        page = self.app.gui.spin_viewer.wizard.get_page(self.app.gui.spin_viewer.wizard._current_page)
        page.uf_args['file'].SetValue(str_to_gui(status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'structures' + sep + '1UBQ_H_trunc.pdb'))
        self.app.gui.spin_viewer.wizard._go_next()
        interpreter.flush()    # Required because of the asynchronous uf call.

        # Spin loading wizard:  The spin loading.
        self.app.gui.spin_viewer.wizard._go_next()
        interpreter.flush()    # Required because of the asynchronous uf call.

        # Close the spin viewer window.
        self.app.gui.spin_viewer.handler_close()

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

        # The data path.
        data_path = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'model_free' + sep + 'sphere' + sep

        # Set up the Bruker DC wizard.
        analysis.relax_data.wizard_bruker(None)

        # The spectrum.
        page = analysis.relax_data.wizard.get_page(analysis.relax_data.page_indices['read'])
        page.uf_args['ri_id'].SetValue(str_to_gui('r1_700'))
        page.uf_args['file'].SetValue(str_to_gui(status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'bruker_files' + sep + 'T1_demo_1UBQ_H_trunc.txt'))

        # Cause the failure.
        analysis.relax_data.wizard._go_next(None)

        # Check that no data was loaded.
        self.assert_(not hasattr(cdp, 'ri_ids'))
        self.assert_(not hasattr(cdp, 'spectrometer_frq'))
        self.assert_(not hasattr(cdp, 'ri_type'))
        for spin in spin_loop():
            self.assert_(not hasattr(spin, 'ri_data'))
            self.assert_(not hasattr(spin, 'ri_data_err'))
Ejemplo n.º 11
0
    def new_analysis_wizard(self, analysis_type=None, analysis_name=None, pipe_name=None, pipe_bundle=None):
        """Simulate the new analysis wizard, and return the analysis page.

        @keyword analysis_type: The type of the analysis to use in the first wizard page.
        @type analysis_type:    str
        @keyword analysis_name: The name of the analysis to use in the first wizard page.
        @type analysis_name:    str
        @keyword pipe_name:     The name of the data pipe to create, if different from the default.
        @type pipe_name:        None or str
        @keyword pipe_bundle:   The name of the data pipe bundle to create, if different from the default.
        @type pipe_bundle:      None or str
        """

        # Simulate the menu selection, but don't destroy the GUI element.
        self.app.gui.analysis.menu_new(None, destroy=False)

        # The first page.
        page = self.app.gui.analysis.new_wizard.wizard.get_page(0)
        if analysis_type == 'noe':
            page.select_noe(None)
        elif analysis_type == 'r1':
            page.select_r1(None)
        elif analysis_type == 'r2':
            page.select_r2(None)
        elif analysis_type == 'mf':
            page.select_mf(None)
        elif analysis_type == 'disp':
            page.select_disp(None)
        else:
            raise RelaxError("Unknown analysis type '%s'." % analysis_type)
        if analysis_name:
            page.analysis_name.SetValue(str_to_gui(analysis_name))
        self.app.gui.analysis.new_wizard.wizard._go_next(None)

        # The second page.
        page = self.app.gui.analysis.new_wizard.wizard.get_page(1)
        if pipe_name:
            page.pipe_name.SetValue(str_to_gui(pipe_name))
        if pipe_bundle:
            page.pipe_bundle.SetValue(str_to_gui(pipe_bundle))
        self.app.gui.analysis.new_wizard.wizard._go_next(None)

        # Get the data, then clean up.
        analysis_type, analysis_name, pipe_name, pipe_bundle, uf_exec = self.app.gui.analysis.new_wizard.get_data()

        # Wizard cleanup.
        wx.Yield()
        self.app.gui.analysis.new_wizard.Destroy()
        del self.app.gui.analysis.new_wizard

        # Set up the analysis.
        self.app.gui.analysis.new_analysis(analysis_type=analysis_type, analysis_name=analysis_name, pipe_name=pipe_name, pipe_bundle=pipe_bundle)

        # Return the analysis page.
        return self.app.gui.analysis.get_page_from_name(analysis_name)
Ejemplo n.º 12
0
    def test_bug_21076_multi_col_peak_list(self):
        """Test catching U{bug #21076<https://gna.org/bugs/?21076>}, loading a multi-spectra NMRPipe seriesTab file through the GUI, Error messages occur."""

        # The paths to the data files.
        data_path = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'dispersion' + sep + 'KTeilum_FMPoulsen_MAkke_2006' + sep + 'acbp_cpmg_disp_101MGuHCl_40C_041223' + 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 = data_path + 'relax_2_spins_trunc.py'
        self._execute_uf(uf_name='script', file=file, dir=None)

        # 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, where the use of Keyword auto will auto-assign spectra Z_A{i}.
        page = wizard.get_page(wizard.page_indices['read'])
        page.uf_args['file'].SetValue(str_to_gui("%sfolded_sparky_corr_final_max_standard_trunc.ser" % data_path))
        page.uf_args['spectrum_id'].SetValue('auto')
        wizard._go_next(None)

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

        # Get ID from RMSD window.
        page = wizard.get_page(wizard.page_indices['rmsd'])

        # Flush all wx events (to allow the spectrum list GUI element to populate all its rows).
        wx.Yield()

        # Get the first ID from list.
        cur_id = page.uf_args['spectrum_id'].GetValue()

        # Now check that the first is set to 'Z_A0', since the keyword 'auto' was used for spectrum_id.
        self.assertEqual(cur_id, 'Z_A0')

        # Finally close the wizard to allow subsequent tests to be able to operate cleanly.
        wizard.Close()
Ejemplo n.º 13
0
    def update_pipes(self):
        """Update the data pipe list."""

        # Clear the previous data pipe.
        self.pipe_name.Clear()

        # The list of data pipes.
        for pipe in pipe_names():
            self.pipe_name.Append(str_to_gui(pipe))

        # Set the name to the current data pipe.
        self.pipe_name.SetValue(str_to_gui(cdp_name()))
Ejemplo n.º 14
0
    def update_data(self):
        """Method called from self.build_element_safe() to update the list data."""

        # Expand the number of rows to match the number of entries, and add the data.
        n = 0
        if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'citations'):
            n = len(cdp.exp_info.citations)
            for i in range(n):
                # Set the citation ID.
                if dep_check.wx_classic:
                    self.element.InsertStringItem(i, str_to_gui(cdp.exp_info.citations[i].cite_id))
                else:
                    self.element.InsertItem(i, str_to_gui(cdp.exp_info.citations[i].cite_id))
Ejemplo n.º 15
0
    def update_data(self):
        """Method called from self.build_element_safe() to update the list data."""

        # Initialise the column index for the data.
        index = 1

        # Delete the rows and columns.
        self.element.DeleteAllItems()
        for i in reversed(range(self.element.GetColumnCount())):
            self.element.DeleteColumn(i)

        # Initialise to a single column.
        self.element.InsertColumn(0, str_to_gui("Spectrum ID"))

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

            # Set the IDs.
            for i in range(n):
                self.element.InsertStringItem(i, str_to_gui(cdp.spectrum_ids[i]))

        # The NOE spectrum type.
        if self.noe_spectrum_type(index):
            index += 1

        # The experiment type.
        if self.relax_disp_flag and self.add_exp_type(index):
            index += 1

        # The spectrometer frequency.
        if self.relax_disp_flag and self.add_frqs(index):
            index += 1

        # The spin-lock field strength or CPMG pulse frequency.
        if self.relax_disp_flag and self.add_disp_point(index):
            index += 1

        # The offset.
        if self.relax_disp_flag and self.add_offset(index):
            index += 1

        # The relaxation times.
        if (self.relax_fit_flag or self.relax_disp_flag) and self.relax_times(index):
            index += 1

        # The replicated spectra.
        if self.replicates(index):
            index += 1
Ejemplo n.º 16
0
    def test_structure_pdb_read(self):
        """Test the full operation of the structure.read_pdb user function GUI window."""

        # Create the data pipe.
        self.exec_uf_pipe_create(pipe_name='PDB reading test')

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

        # The PDB file to operate on.
        file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'structures' + sep + 'trunc_ubi_pcs.pdb'
        uf.page.SetValue('file', str_to_gui(file))

        # Set the models to read.
        uf.page.SetValue('read_model', str_to_gui('6'))
        uf.page.uf_args['read_model'].selection_win_show()
        uf.page.uf_args['read_model'].sel_win.add_element(None)
        if dep_check.wx_classic:
            uf.page.uf_args['read_model'].sel_win.sequence.SetStringItem(0, 1, int_to_gui(2))
            uf.page.uf_args['read_model'].sel_win.sequence.SetStringItem(1, 1, int_to_gui(4))
        else:
            uf.page.uf_args['read_model'].sel_win.sequence.SetItem(0, 1, int_to_gui(2))
            uf.page.uf_args['read_model'].sel_win.sequence.SetItem(1, 1, int_to_gui(4))
        uf.page.uf_args['read_model'].selection_win_data()

        # Renumber the models.
        uf.page.uf_args['set_model_num'].selection_win_show()
        uf.page.uf_args['set_model_num'].sel_win.add_element(None)
        if dep_check.wx_classic:
            uf.page.uf_args['set_model_num'].sel_win.sequence.SetStringItem(0, 1, int_to_gui(1))
            uf.page.uf_args['set_model_num'].sel_win.sequence.SetStringItem(1, 1, int_to_gui(3))
        else:
            uf.page.uf_args['set_model_num'].sel_win.sequence.SetItem(0, 1, int_to_gui(1))
            uf.page.uf_args['set_model_num'].sel_win.sequence.SetItem(1, 1, int_to_gui(3))
        uf.page.uf_args['set_model_num'].selection_win_data()

        # GUI data checks.
        self.assertEqual(uf.page.uf_args['read_model'].GetValue(), [2, 4])
        self.assertEqual(uf.page.uf_args['set_model_num'].GetValue(), [1, 3])

        # Execute the user function.
        uf.wizard._go_next(None)

        # Check the structural data.
        self.assert_(hasattr(cdp, 'structure'))
        self.assert_(hasattr(cdp.structure, 'structural_data'))
        self.assertEqual(len(cdp.structure.structural_data), 2)
        self.assertEqual(cdp.structure.structural_data[0].num, 1)
        self.assertEqual(cdp.structure.structural_data[1].num, 3)
Ejemplo n.º 17
0
    def replicates(self, index):
        """Add the replicated spectra 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, 'replicates') or not len(cdp.replicates):
            return False

        # Replicated spectra.
        repl = replicated_flags()

        # Append a column.
        self.element.InsertColumn(index, str_to_gui("Replicate IDs"))

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

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

            # The replicated spectra.
            id_list = replicated_ids(cdp.spectrum_ids[i])

            # Convert to a string.
            text = ''
            for j in range(len(id_list)):
                # Add the id.
                text = "%s%s" % (text, id_list[j])

                # Separator.
                if j < len(id_list) - 1:
                    text = "%s, " % text

            # Set the value.
            if dep_check.wx_classic:
                self.element.SetStringItem(i, index, str_to_gui(text))
            else:
                self.element.SetItem(i, index, str_to_gui(text))

        # Successful.
        return True
Ejemplo n.º 18
0
    def test_structure_pdb_read(self):
        """Test the full operation of the structure.read_pdb 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('PDB reading test'))
        uf.page.SetValue('pipe_type', str_to_gui('mf'))
        uf.wizard._go_next(None)

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

        # The PDB file to operate on.
        file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'structures' + sep + 'trunc_ubi_pcs.pdb'
        uf.page.SetValue('file', str_to_gui(file))

        # Set the models to read.
        uf.page.SetValue('read_model', str_to_gui('6'))
        uf.page.uf_args['read_model'].selection_win_show()
        uf.page.uf_args['read_model'].sel_win.append_row(None)
        uf.page.uf_args['read_model'].sel_win.sequence.SetStringItem(index=0, col=0, label=int_to_gui(2))
        uf.page.uf_args['read_model'].sel_win.sequence.SetStringItem(index=1, col=0, label=int_to_gui(4))
        uf.page.uf_args['read_model'].selection_win_data()

        # Renumber the models.
        uf.page.uf_args['set_model_num'].selection_win_show()
        uf.page.uf_args['set_model_num'].sel_win.append_row(None)
        uf.page.uf_args['set_model_num'].sel_win.append_row(None)
        uf.page.uf_args['set_model_num'].sel_win.sequence.SetStringItem(index=0, col=0, label=int_to_gui(1))
        uf.page.uf_args['set_model_num'].sel_win.sequence.SetStringItem(index=1, col=0, label=int_to_gui(3))
        uf.page.uf_args['set_model_num'].selection_win_data()

        # GUI data checks.
        self.assertEqual(uf.page.uf_args['read_model'].GetValue(), [2, 4])
        self.assertEqual(uf.page.uf_args['set_model_num'].GetValue(), [1, 3])

        # Execute the user function.
        uf.wizard._go_next(None)

        # Check the structural data.
        self.assert_(hasattr(cdp, 'structure'))
        self.assert_(hasattr(cdp.structure, 'structural_data'))
        self.assertEqual(len(cdp.structure.structural_data), 2)
        self.assertEqual(cdp.structure.structural_data[0].num, 1)
        self.assertEqual(cdp.structure.structural_data[1].num, 3)
Ejemplo n.º 19
0
    def EndEdit(self, row, col, grid):
        """End the editing.

        @param row:     The row index.
        @type row:      int
        @param col:     The column index.
        @type col:      int
        @param grid:    The grid GUI element.
        @type grid:     wx.grid.Grid instance.
        """

        # A reset.
        if self.reset:
            # Reset the reset flag.
            self.reset = False

            # No starting value, so do nothing.
            if self.prev_val == '':
                return False

        # The new value.
        value = self.cell.GetValue()

        # No change.
        if value == self.prev_val:
            return False

        # Set the value in the table (the value of zero shows nothing).
        if value == 0:
            text = ''
        else:
            text = str(value)
        grid.GetTable().SetValue(row, col, str_to_gui(text))

        # The delay cycle time.
        time = self.parent.delay_time.GetValue()

        # No times to update.
        if time == '':
            # A change occurred.
            return True

        # Update the relaxation delay time.
        delay_time = float(time) * float(value)
        grid.GetTable().SetValue(row, col-1, str_to_gui(delay_time))

        # A change occurred.
        return True
Ejemplo n.º 20
0
    def EndEdit(self, row, col, grid):
        """End the editing.

        @param row:     The row index.
        @type row:      int
        @param col:     The column index.
        @type col:      int
        @param grid:    The grid GUI element.
        @type grid:     wx.grid.Grid instance.
        """

        # A reset.
        if self.reset:
            # Reset the reset flag.
            self.reset = False

            # No starting value, so do nothing.
            if self.prev_val == '':
                return False

        # The new value.
        value = self.cell.GetValue()

        # No change.
        if value == self.prev_val:
            return False

        # Set the value in the table (the value of zero shows nothing).
        if value == 0:
            text = ''
        else:
            text = str(value)
        grid.GetTable().SetValue(row, col, str_to_gui(text))

        # The delay cycle time.
        time = self.parent.delay_time.GetValue()

        # No times to update.
        if time == '':
            # A change occurred.
            return True

        # Update the relaxation delay time.
        delay_time = float(time) * float(value)
        grid.GetTable().SetValue(row, col-1, str_to_gui(delay_time))

        # A change occurred.
        return True
Ejemplo n.º 21
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
Ejemplo n.º 22
0
    def test_bug_2_structure_read_pdb_failure(self):
        """Catch U{bug #2<https://sourceforge.net/p/nmr-relax/tickets/2/>}, the failure of the structure.read_pdb user function.

        This was reported by U{Stefano Ciurli<https://sourceforge.net/u/stefanociurli/>}.
        """

        # Create the data pipe.
        self.exec_uf_pipe_create(pipe_name='structure.read_pdb user function failure test')

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

        # The PDB file.
        file = path.join(status.install_path, 'test_suite', 'shared_data', 'structures', '1J7O.pdb')

        # Manually set the PDB file on the first text element - as this is not attached to a uf_args dictionary element!
        uf.page.GetChildren()[6].SetValue(str_to_gui(file))

        # Execute the user function.
        uf.wizard._go_next(None)

        # Check the structural data.
        self.assert_(hasattr(cdp, 'structure'))
        self.assert_(hasattr(cdp.structure, 'structural_data'))
        self.assertEqual(len(cdp.structure.structural_data), 3)
        self.assertEqual(cdp.structure.structural_data[0].num, 1)
        self.assertEqual(cdp.structure.structural_data[1].num, 2)
        self.assertEqual(cdp.structure.structural_data[2].num, 3)
Ejemplo n.º 23
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
Ejemplo n.º 24
0
    def init_element(self, sizer):
        """Initialise the GUI element.

        @param sizer:   The sizer element to pack the element into.
        @type sizer:    wx.BoxSizer instance
        """

        # The list.
        self.element = wx.ListCtrl(self.panel,
                                   -1,
                                   style=wx.BORDER_SUNKEN | wx.LC_REPORT)

        # Initialise the columns.
        for i in range(len(self.columns)):
            self.element.InsertColumn(i, str_to_gui(self.columns[i]))

        # Properties.
        self.element.SetFont(font.normal)

        # Store the base heights.
        self.height_char = self.element.GetCharHeight()

        # Bind some events.
        self.element.Bind(wx.EVT_SIZE, self.resize)
        self.element.Bind(wx.EVT_COMMAND_RIGHT_CLICK,
                          self.on_right_click)  # For wxMSW!
        self.element.Bind(wx.EVT_RIGHT_UP, self.on_right_click)  # For wxGTK!

        # Add list to sizer.
        sizer.Add(self.element, self.proportion, wx.ALL | wx.EXPAND, 0)
Ejemplo n.º 25
0
    def results_directory(self, event):
        """The results directory selection.

        @param event:   The wx event.
        @type event:    wx event
        """

        # The dialog.
        dialog = RelaxDirDialog(parent=self, message='Select the results directory', defaultPath=self.field_results_dir.GetValue())

        # Show the dialog and catch if no file has been selected.
        if status.show_gui and dialog.ShowModal() != wx.ID_OK:
            # Don't do anything.
            return

        # The path (don't do anything if not set).
        path = gui_to_str(dialog.get_path())
        if not path:
            return

        # Store the path.
        self.data.save_dir = path

        # Place the path in the text box.
        self.field_results_dir.SetValue(str_to_gui(path))
Ejemplo n.º 26
0
    def results_directory(self, event):
        """The results directory selection.

        @param event:   The wx event.
        @type event:    wx event
        """

        # The dialog.
        dialog = RelaxDirDialog(parent=self,
                                message='Select the results directory',
                                defaultPath=self.field_results_dir.GetValue())

        # Show the dialog and catch if no file has been selected.
        if status.show_gui and dialog.ShowModal() != wx.ID_OK:
            # Don't do anything.
            return

        # The path (don't do anything if not set).
        path = gui_to_str(dialog.get_path())
        if not path:
            return

        # Store the path.
        self.data.save_dir = path

        # Place the path in the text box.
        self.field_results_dir.SetValue(str_to_gui(path))
Ejemplo n.º 27
0
    def init_element(self, sizer):
        """Initialise the GUI element.

        @param sizer:   The sizer element to pack the element into.
        @type sizer:    wx.BoxSizer instance
        """

        # The list.
        self.element = wx.ListCtrl(self.panel, -1, style=wx.BORDER_SUNKEN | wx.LC_REPORT)

        # Initialise the columns.
        for i in range(len(self.columns)):
            self.element.InsertColumn(i, str_to_gui(self.columns[i]))

        # Properties.
        self.element.SetFont(font.normal)

        # Store the base heights.
        self.height_char = self.element.GetCharHeight()

        # Bind some events.
        self.element.Bind(wx.EVT_SIZE, self.resize)
        self.element.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.on_right_click)  # For wxMSW!
        self.element.Bind(wx.EVT_RIGHT_UP, self.on_right_click)  # For wxGTK!

        # Add list to sizer.
        sizer.Add(self.element, self.proportion, wx.ALL | wx.EXPAND, 0)
Ejemplo n.º 28
0
    def test_paul_schanda_nov_2015(self):
        """This test truncated private data which was provided by Paul Schanda.  This systemtest uncovers some unfortunate problems when
        running an analysis and reading points by the R2eff method.
        """

        # Data path.
        data_path = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'dispersion' + sep + 'Paul_Schanda_2015_Nov'
        file_1 = data_path + sep + '1_prepare_data.py'
        file_2 = data_path + sep + '2_load_data_GUI.py'

        ## Store the out
        outdir = ds.tmpdir
        status.outdir = outdir

        # Simulate the dispersion analysis wizard.
        analysis = self.new_analysis_wizard(analysis_type='disp')

        ## Run script to make data.
        self._execute_uf(uf_name='script', file=file_1, dir=None)

        ## Run script to make setup of data data.
        self._execute_uf(uf_name='script', file=file_2, dir=None)

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

        # Now load the state
        state_file = outdir + sep + "temp_state.bz2"
        self.app.gui.state_load(file_name=state_file)
Ejemplo n.º 29
0
    def test_paul_schanda_nov_2015(self):
        """This test truncated private data which was provided by Paul Schanda.  This systemtest uncovers some unfortunate problems when
        running an analysis and reading points by the R2eff method.
        """

        # Data path.
        data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Paul_Schanda_2015_Nov'
        file_1 = data_path + sep + '1_prepare_data.py'
        file_2 = data_path + sep + '2_load_data_GUI.py'

        ## Store the out
        outdir = ds.tmpdir
        status.outdir = outdir

        # Simulate the dispersion analysis wizard.
        analysis = self.new_analysis_wizard(analysis_type='disp')

        ## Run script to make data.
        self._execute_uf(uf_name='script', file=file_1, dir=None)

        ## Run script to make setup of data data.
        self._execute_uf(uf_name='script', file=file_2, dir=None)

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

        # Now load the state
        state_file = outdir + sep + "temp_state.bz2"
        self.app.gui.state_load(file_name=state_file)
Ejemplo n.º 30
0
    def replicates(self, index):
        """Add the replicated spectra 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, 'replicates') or not len(cdp.replicates):
            return False

        # Replicated spectra.
        repl = replicated_flags()

        # Append a column.
        self.element.InsertColumn(index, str_to_gui("Replicate IDs"))

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

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

            # The replicated spectra.
            id_list = replicated_ids(cdp.spectrum_ids[i])

            # Convert to a string.
            text = ''
            for j in range(len(id_list)):
                # Add the id.
                text = "%s%s" % (text, id_list[j])

                # Separator.
                if j < len(id_list)-1:
                    text = "%s, " % text

            # Set the value.
            self.element.SetStringItem(i, index, str_to_gui(text))

        # Successful.
        return True
Ejemplo n.º 31
0
    def update_pipes(self, event=None):
        """Update the spin view data pipe selector.

        @keyword event: The wx event.
        @type event:    wx event
        """

        # Change the cursor to busy.
        wx.BeginBusyCursor()

        # Init.
        pipe_switch = False

        # The selected pipe.
        if event:
            # The name of the selected pipe.
            pipe = gui_to_str(self.pipe_name.GetString(event.GetSelection()))

            # A pipe change.
            if pipe != cdp_name():
                pipe_switch = True
        else:
            pipe = cdp_name()
        if not pipe:
            pipe = ''

        # Clear the previous data.
        self.pipe_name.Clear()

        # The list of pipe names.
        for name in pipe_names():
            self.pipe_name.Append(str_to_gui(name))

        # Switch.
        if pipe_switch:
            # Switch data pipes.
            self.gui.interpreter.apply('pipe.switch', pipe)

            # Update the tree view.
            self.tree_panel.update()

        # Set the pipe name to the cdp.
        self.pipe_name.SetValue(str_to_gui(pipe))

        # Reset the cursor.
        if wx.IsBusy():
            wx.EndBusyCursor()
Ejemplo n.º 32
0
    def update_pipes(self, event=None):
        """Update the spin view data pipe selector.

        @keyword event: The wx event.
        @type event:    wx event
        """

        # Change the cursor to busy.
        wx.BeginBusyCursor()

        # Init.
        pipe_switch = False

        # The selected pipe.
        if event:
            # The name of the selected pipe.
            pipe = gui_to_str(self.pipe_name.GetString(event.GetSelection()))

            # A pipe change.
            if pipe != cdp_name():
                pipe_switch = True
        else:
            pipe = cdp_name()
        if not pipe:
            pipe = ''

        # Clear the previous data.
        self.pipe_name.Clear()

        # The list of pipe names.
        for name in pipe_names():
            self.pipe_name.Append(str_to_gui(name))

        # Switch.
        if pipe_switch:
            # Switch data pipes.
            self.gui.interpreter.apply('pipe.switch', pipe)

            # Update the tree view.
            self.tree_panel.update()

        # Set the pipe name to the cdp.
        self.pipe_name.SetValue(str_to_gui(pipe))

        # Reset the cursor.
        if wx.IsBusy():
            wx.EndBusyCursor()
Ejemplo n.º 33
0
    def Reset(self):
        """Reset the cell to the previous value."""

        # Set the previous value.
        self.cell.SetValueString(str_to_gui(self.prev_val))

        # Set a flag for EndEdit to catch a reset.
        self.reset = True
Ejemplo n.º 34
0
    def Reset(self):
        """Reset the cell to the previous value."""

        # Set the previous value.
        self.cell.SetValueString(str_to_gui(self.prev_val))

        # Set a flag for EndEdit to catch a reset.
        self.reset = True
Ejemplo n.º 35
0
    def UpdateChoices(self,
                      combo_choices=None,
                      combo_data=None,
                      combo_default=None):
        """Special wizard method for updating the list of choices in a ComboBox type element.

        @keyword combo_choices: The list of choices to present to the user.
        @type combo_choices:    list of str
        @keyword combo_data:    The data returned by a call to GetValue().  If supplied, it should be the same length at the combo_choices list.  If not supplied, the combo_choices list will be used for the returned data.
        @type combo_data:       list
        @keyword combo_default: The default value of the ComboBox.  This is only used if the element_type is set to 'combo'.
        @type combo_default:    str or None
        """

        # Store the current selection's client data to restore at the end.
        sel_index = self._field.GetSelection()
        if sel_index == wx.NOT_FOUND:
            sel = None
        else:
            sel = self._field.GetClientData(sel_index)

        # First clear all data.
        self.Clear()

        # Set the data if needed.
        if combo_data == None:
            combo_data = deepcopy(combo_choices)

        # Loop over the choices and data, adding both to the end.
        for i in range(len(combo_choices)):
            self._field.Insert(str_to_gui(combo_choices[i]), i, combo_data[i])

        # Set the default selection.
        if sel == None and combo_default != None:
            # Translate if needed.
            if combo_default in combo_choices:
                string = combo_default
                set_sel = True
            elif combo_default not in combo_data:
                string = combo_default
                set_sel = False
            else:
                string = combo_choices[combo_data.index(combo_default)]
                set_sel = True

            # Set the selection.
            if set_sel:
                self._field.SetStringSelection(string)

            # Set the value.
            else:
                self._field.SetValue(string)

        # Restore the selection.
        else:
            for j in range(self._field.GetCount()):
                if self._field.GetClientData(j) == sel:
                    self._field.SetSelection(j)
Ejemplo n.º 36
0
    def test_spectrum_read_intensities(self):
        """Test the operation of the spectrum.read_intensities user function GUI window."""

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

        # Set the y-value of a single pos, and check.
        uf.page.uf_args['file'].selection_win_show()
        uf.page.uf_args['file'].sel_win.SetValue('test_file')
        uf.page.uf_args['file'].selection_win_data()
        file = uf.page.uf_args['file'].GetValue()
        print("File names:  %s" % file)
        self.assert_(isinstance(file, str))
        self.assertEqual(file, 'test_file')

        # Set the file to nothing in the wizard, open the Sequence window, close the window, and check that None comes back.
        uf.page.uf_args['file'].SetValue(str_to_gui(''))
        uf.page.uf_args['file'].selection_win_show()
        uf.page.uf_args['file'].selection_win_data()
        file = uf.page.uf_args['file'].GetValue()
        print("File names:  %s" % file)
        self.assertEqual(file, None)

        # Set a valid file list in the wizard, open and close the Sequence window (twice), and check that the file comes back.
        uf.page.uf_args['file'].SetValue(str_to_gui("['test1', 'test2']"))
        uf.page.uf_args['file'].selection_win_show()
        uf.page.uf_args['file'].selection_win_data()
        uf.page.uf_args['file'].selection_win_show()
        uf.page.uf_args['file'].selection_win_data()
        file = uf.page.uf_args['file'].GetValue()
        print("File names:  %s" % file)
        self.assertEqual(len(file), 2)
        self.assertEqual(file[0], 'test1')
        self.assertEqual(file[1], 'test2')

        # Set the file to a number of invalid values, checking that they are ignored.
        for val in ["['1', '2', '3'", "['1'"]:
            uf.page.uf_args['file'].SetValue(str_to_gui(val))
            uf.page.uf_args['file'].selection_win_show()
            uf.page.uf_args['file'].selection_win_data()
            file = uf.page.uf_args['file'].GetValue()
            print("Invalid file: %s\nFile names:  %s" % (val, file))
            self.assertEqual(file, None)
Ejemplo n.º 37
0
    def test_spectrum_read_intensities(self):
        """Test the operation of the spectrum.read_intensities user function GUI window."""

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

        # Set the y-value of a single pos, and check.
        uf.page.uf_args['file'].selection_win_show()
        uf.page.uf_args['file'].sel_win.SetValue('test_file')
        uf.page.uf_args['file'].selection_win_data()
        file = uf.page.uf_args['file'].GetValue()
        print("File names:  %s" % file)
        self.assert_(isinstance(file, str))
        self.assertEqual(file, 'test_file')

        # Set the file to nothing in the wizard, open the Sequence window, close the window, and check that None comes back.
        uf.page.uf_args['file'].SetValue(str_to_gui(''))
        uf.page.uf_args['file'].selection_win_show()
        uf.page.uf_args['file'].selection_win_data()
        file = uf.page.uf_args['file'].GetValue()
        print("File names:  %s" % file)
        self.assertEqual(file, None)

        # Set a valid file list in the wizard, open and close the Sequence window (twice), and check that the file comes back.
        uf.page.uf_args['file'].SetValue(str_to_gui("['test1', 'test2']"))
        uf.page.uf_args['file'].selection_win_show()
        uf.page.uf_args['file'].selection_win_data()
        uf.page.uf_args['file'].selection_win_show()
        uf.page.uf_args['file'].selection_win_data()
        file = uf.page.uf_args['file'].GetValue()
        print("File names:  %s" % file)
        self.assertEqual(len(file), 2)
        self.assertEqual(file[0], 'test1')
        self.assertEqual(file[1], 'test2')

        # Set the file to a number of invalid values, checking that they are ignored.
        for val in ["['1', '2', '3'", "['1'"]:
            uf.page.uf_args['file'].SetValue(str_to_gui(val))
            uf.page.uf_args['file'].selection_win_show()
            uf.page.uf_args['file'].selection_win_data()
            file = uf.page.uf_args['file'].GetValue()
            print("Invalid file: %s\nFile names:  %s" % (val, file))
            self.assertEqual(file, None)
Ejemplo n.º 38
0
    def update_mf(self):
        """Update the model-free specific elements."""

        # The analysis key.
        key = self.analysis_key()
        if not key:
            return

        # Loaded a finished state, so fill all gauges and return.
        elif not key in status.auto_analysis and cdp_name() == 'final':
            wx.CallAfter(self.mc_gauge_mf.SetValue, 100)
            wx.CallAfter(self.progress_gauge_mf.SetValue, 100)
            wx.CallAfter(self.main_gauge.SetValue, 100)
            return

        # Nothing to do.
        if not key in status.auto_analysis:
            wx.CallAfter(self.mc_gauge_mf.SetValue, 0)
            wx.CallAfter(self.progress_gauge_mf.SetValue, 0)
            wx.CallAfter(self.main_gauge.SetValue, 0)
            return

        # Set the diffusion model.
        wx.CallAfter(self.global_model_mf.SetValue, str_to_gui(status.auto_analysis[key].diff_model))

        # Update the progress gauge for the local tm model.
        if status.auto_analysis[key].diff_model == 'local_tm':
            if status.auto_analysis[key].current_model:
                # Current model.
                no = int(status.auto_analysis[key].current_model[2:])

                # Total selected models.
                total_models = len(status.auto_analysis[key].local_tm_models)

                # Update the progress bar.
                percent = int(100 * no / float(total_models))
                wx.CallAfter(self.progress_gauge_mf.SetValue, percent)

        # Sphere to ellipsoid Models.
        elif status.auto_analysis[key].diff_model in ['sphere', 'prolate', 'oblate', 'ellipsoid']:
            # Check that the round has been set.
            if status.auto_analysis[key].round == None:
                wx.CallAfter(self.progress_gauge_mf.SetValue, 0)
            else:
                # The round as a percentage.
                percent = int(100 * (status.auto_analysis[key].round + 1) / (status.auto_analysis[key].max_iter + 1))

                # Update the progress bar.
                wx.CallAfter(self.progress_gauge_mf.SetValue, percent)

        # Monte Carlo simulations.
        if status.auto_analysis[key].mc_number:
            # The simulation number as a percentage.
            percent = int(100 * (status.auto_analysis[key].mc_number + 1) / cdp.sim_number)

            # Update the progress bar.
            wx.CallAfter(self.mc_gauge_mf.SetValue, percent)
Ejemplo n.º 39
0
    def SetValue(self, value):
        """Set up the list of file.

        @param value:   The list of values to add to the list.
        @type value:    list of str or None
        """

        # Set the value.
        self.field.SetValue(str_to_gui(value))
Ejemplo n.º 40
0
    def SetValue(self, value):
        """Set up the list of file.

        @param value:   The list of values to add to the list.
        @type value:    list of str or None
        """

        # Set the value.
        self.field.SetValue(str_to_gui(value))
Ejemplo n.º 41
0
    def SetValue(self, value):
        """Special method for setting the value of the GUI element.

        @param value:   The value to set.
        @type value:    str
        """

        # Convert and set the value for a TextCtrl.
        self._field.SetValue(str_to_gui(value))
Ejemplo n.º 42
0
    def SetValue(self, value):
        """Special method for setting the value of the GUI element.

        @param value:   The value to set.
        @type value:    str
        """

        # Convert and set the value for a TextCtrl.
        self._field.SetValue(str_to_gui(value))
Ejemplo n.º 43
0
    def update_data(self):
        """Method called from self.build_element_safe() to update the list data."""

        # 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]
                if dep_check.wx_classic:
                    self.element.InsertStringItem(i, str_to_gui(id))
                else:
                    self.element.InsertItem(i, str_to_gui(id))

                # Set the peak intensity types.
                if hasattr(cdp, 'exp_info') and hasattr(
                        cdp.exp_info, 'peak_intensity_type'
                ) and id in cdp.exp_info.peak_intensity_type:
                    if dep_check.wx_classic:
                        self.element.SetStringItem(
                            i, 1,
                            str_to_gui(cdp.exp_info.peak_intensity_type[id]))
                    else:
                        self.element.SetItem(
                            i, 1,
                            str_to_gui(cdp.exp_info.peak_intensity_type[id]))

                # Set the temperature calibration methods.
                if hasattr(cdp, 'exp_info') and hasattr(
                        cdp.exp_info, 'temp_calibration'
                ) and id in cdp.exp_info.temp_calibration:
                    if dep_check.wx_classic:
                        self.element.SetStringItem(
                            i, 2,
                            str_to_gui(cdp.exp_info.temp_calibration[id]))
                    else:
                        self.element.SetItem(
                            i, 2,
                            str_to_gui(cdp.exp_info.temp_calibration[id]))

                # Set the temperature control methods.
                if hasattr(cdp, 'exp_info') and hasattr(
                        cdp.exp_info,
                        'temp_control') and id in cdp.exp_info.temp_control:
                    if dep_check.wx_classic:
                        self.element.SetStringItem(
                            i, 3, str_to_gui(cdp.exp_info.temp_control[id]))
                    else:
                        self.element.SetItem(
                            i, 3, str_to_gui(cdp.exp_info.temp_control[id]))
Ejemplo n.º 44
0
    def update_data(self):
        """Method called from self.build_element_safe() to update the list data."""

        # Expand the number of rows to match the number of entries, and add the data.
        n = 0
        if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'software'):
            n = len(cdp.exp_info.software)
            for i in range(n):
                # Set the software name.
                self.element.InsertStringItem(i, str_to_gui(cdp.exp_info.software[i].name))
Ejemplo n.º 45
0
    def update_data(self):
        """Method called from self.build_element_safe() to update the list data."""

        # Expand the number of rows to match the number of entries, and add the data.
        n = 0
        if hasattr(cdp, "exp_info") and hasattr(cdp.exp_info, "citations"):
            n = len(cdp.exp_info.citations)
            for i in range(n):
                # Set the citation ID.
                self.element.InsertStringItem(i, str_to_gui(cdp.exp_info.citations[i].cite_id))
Ejemplo n.º 46
0
    def update_data(self):
        """Method called from self.build_element_safe() to update the list data."""

        # Expand the number of rows to match the number of entries, and add the data.
        n = 0
        if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'scripts'):
            n = len(cdp.exp_info.scripts)
            for i in range(n):
                # Set the scripts name.
                self.element.InsertStringItem(i, str_to_gui(cdp.exp_info.scripts[i].file))
Ejemplo n.º 47
0
    def UpdateChoices(self, combo_choices=None, combo_data=None, combo_default=None):
        """Special wizard method for updating the list of choices in a ComboBox type element.

        @keyword combo_choices: The list of choices to present to the user.
        @type combo_choices:    list of str
        @keyword combo_data:    The data returned by a call to GetValue().  If supplied, it should be the same length at the combo_choices list.  If not supplied, the combo_choices list will be used for the returned data.
        @type combo_data:       list
        @keyword combo_default: The default value of the ComboBox.  This is only used if the element_type is set to 'combo'.
        @type combo_default:    str or None
        """

        # Store the current selection's client data to restore at the end.
        sel_index = self._field.GetSelection()
        if sel_index == wx.NOT_FOUND:
            sel = None
        else:
            sel = self._field.GetClientData(sel_index)

        # First clear all data.
        self.Clear()

        # Set the data if needed.
        if combo_data == None:
            combo_data = deepcopy(combo_choices)

        # Loop over the choices and data, adding both to the end.
        for i in range(len(combo_choices)):
            self._field.Insert(str_to_gui(combo_choices[i]), i, combo_data[i])

        # Set the default selection.
        if sel == None and combo_default != None:
            # Translate if needed.
            if combo_default in combo_choices:
                string = combo_default
                set_sel = True
            elif combo_default not in combo_data:
                string = combo_default
                set_sel = False
            else:
                string = combo_choices[combo_data.index(combo_default)]
                set_sel = True

            # Set the selection.
            if set_sel:
                self._field.SetStringSelection(string)

            # Set the value.
            else:
                self._field.SetValue(string)

        # Restore the selection.
        else:
            for j in range(self._field.GetCount()):
                if self._field.GetClientData(j) == sel:
                    self._field.SetSelection(j)
Ejemplo n.º 48
0
    def exec_uf_pipe_create(self, pipe_name=None, pipe_type='mf'):
        """Execute the pipe.create user function via the GUI user function window.

        @keyword pipe_name:     The pipe_name argument of the pipe.create user function.
        @type pipe_name:        str
        @keyword pipe_type:     The pipe_type argument of the pipe.create user function.
        @type pipe_type:        str
        """

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

        # Set the arguments.
        uf.page.SetValue('pipe_name', str_to_gui(pipe_name))
        uf.page.SetValue('pipe_type', str_to_gui(pipe_type))

        # Execute.
        uf.wizard._go_next(None)
Ejemplo n.º 49
0
    def sync_ds(self, upload=False):
        """Synchronise the noe 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 frequency.
        if upload:
            self.data.frq = gui_to_str(self.field_nmr_frq.GetValue())
        else:
            self.field_nmr_frq.SetValue(str_to_gui(self.data.frq))

        # 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))
Ejemplo n.º 50
0
    def update_controller(self):
        """Update the relax controller."""

        # Set the current data pipe info.
        pipe = cdp_name()
        if pipe == None:
            pipe = ''
        wx.CallAfter(self.cdp.SetValue, str_to_gui(pipe))

        # Set the current GUI analysis info.
        name = self.gui.analysis.current_analysis_name()
        if name == None:
            name = ''
        wx.CallAfter(self.name.SetValue, str_to_gui(name))

        # The analysis type.
        type = self.gui.analysis.current_analysis_type()

        # Rx fitting auto-analysis.
        if type in ['R1', 'R2']:
            if status.show_gui:
                wx.CallAfter(self.panel_rx.Show)
            wx.CallAfter(self.update_rx)
        else:
            if status.show_gui:
                wx.CallAfter(self.panel_rx.Hide)

        # Model-free auto-analysis.
        if type == 'model-free':
            if status.show_gui:
                wx.CallAfter(self.panel_mf.Show)
            wx.CallAfter(self.update_mf)
        else:
            if status.show_gui:
                wx.CallAfter(self.panel_mf.Hide)

        # Update the main gauge.
        wx.CallAfter(self.update_gauge)

        # Re-layout the window.
        wx.CallAfter(self.main_panel.Layout)
Ejemplo n.º 51
0
    def noe_spectrum_type(self, index):
        """Add the NOE spectral type info to the element.

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

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

        # Append a column.
        self.element.InsertColumn(index, str_to_gui("NOE spectrum type"))

        # Translation table.
        table = {'sat': 'Saturated', 'ref': 'Reference'}

        # 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.spectrum_type:
                continue

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

        # Successful.
        return True
Ejemplo n.º 52
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]
                if dep_check.wx_classic:
                    self.element.InsertStringItem(i, str_to_gui(id))
                else:
                    self.element.InsertItem(i, str_to_gui(id))

                # Set the data types.
                if dep_check.wx_classic:
                    self.element.SetStringItem(
                        i, 1, str_to_gui(table[cdp.ri_type[id]]))
                else:
                    self.element.SetItem(i, 1,
                                         str_to_gui(table[cdp.ri_type[id]]))

                # Set the frequencies.
                if dep_check.wx_classic:
                    self.element.SetStringItem(
                        i, 2, float_to_gui(cdp.spectrometer_frq[id]))
                else:
                    self.element.SetItem(
                        i, 2, float_to_gui(cdp.spectrometer_frq[id]))
Ejemplo n.º 53
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)
Ejemplo n.º 54
0
    def mode_dialog(self, event=None):
        """The calculation mode selection.

        @keyword event: The wx event.
        @type event:    wx event
        """

        # Show the model selector window.
        if status.show_gui:
            self.mode_win.ShowModal()

        # Set the model.
        self.mode.SetValue(str_to_gui(self.mode_win.select))
Ejemplo n.º 55
0
    def test_r2eff_err_estimate(self):
        """Test U{task #7822:<https://web.archive.org/web/https://gna.org/task/?7822>}, Implement user function to estimate R2eff and associated errors for exponential curve fitting.."""

        # The paths to the data files.
        data_path = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'dispersion' + sep + 'Kjaergaard_et_al_2013' + 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 = data_path + '1_setup_r1rho_GUI.py'
        self._execute_uf(uf_name='script', file=file, dir=None)

        # De select spins
        self._execute_uf(uf_name='deselect.spin', spin_id=":1-100")
        self._execute_uf(uf_name='select.spin', spin_id=":52@N")

        # Deselect all but the few models.
        models = [MODEL_R2EFF, MODEL_NOREX, MODEL_DPL94]
        for i in range(len(analysis.model_field.models_stripped)):
            if analysis.model_field.models_stripped[i] in models:
                analysis.model_field.select[i] = True
            else:
                analysis.model_field.select[i] = False
        analysis.model_field.modify()

        # Set the grid search size and number of MC sims.
        analysis.grid_inc.SetValue(0)
        analysis.mc_sim_num.SetValue(3)
        analysis.exp_mc_sim_num.SetValue(-1)

        # Do fitting of R1.
        analysis.r1_fit.SetValue(bool(True))

        # 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()
Ejemplo n.º 56
0
    def update_grid_safe(self):
        """Update the grid with the pipe data."""

        # First freeze the grid, so that the GUI element doesn't update until the end.
        self.grid.Freeze()

        # Acquire the pipe lock.
        status.pipe_lock.acquire('pipe editor window')

        # Delete the rows, leaving a single row.
        self.grid.DeleteRows(numRows=self.grid.GetNumberRows()-1)

        # Clear the contents of the first row.
        for i in range(self.grid.GetNumberCols()):
            self.grid.SetCellValue(0, i, str_to_gui(""))

        # The data pipes.
        pipe_list = pipe_names()
        n = len(pipe_list)

        # Append the appropriate number of rows.
        if n >= 1:
            self.grid.AppendRows(numRows=n-1)

        # Loop over the data pipes.
        for i in range(n):
            # Set the pipe name.
            self.grid.SetCellValue(i, 0, str_to_gui(pipe_list[i]))

            # Set the pipe type.
            self.grid.SetCellValue(i, 1, str_to_gui(get_type(pipe_list[i])))

            # Set the pipe bundle.
            self.grid.SetCellValue(i, 2, str_to_gui(get_bundle(pipe_list[i])))

            # Set the current pipe.
            if pipe_list[i] == cdp_name():
                self.grid.SetCellValue(i, 3, str_to_gui("cdp"))

            # Set the tab the pipe belongs to.
            self.grid.SetCellValue(i, 4, str_to_gui(self.gui.analysis.page_name_from_bundle(get_bundle(pipe_list[i]))))

        # Set the grid properties once finalised.
        for i in range(self.grid.GetNumberRows()):
            # Row properties.
            self.grid.SetRowSize(i, 27)

            # Loop over the columns.
            for j in range(self.grid.GetNumberCols()):
                # Cell properties.
                self.grid.SetReadOnly(i, j)

        # Release the lock.
        status.pipe_lock.release('pipe editor window')

        # Unfreeze.
        self.grid.Thaw()
Ejemplo n.º 57
0
    def SetValue(self, key, value):
        """Special method for setting the value of the GUI element corresponding to the key.

        @param key:     The key corresponding to the desired GUI element.  This can be one of ['spin_id_col', 'mol_name_col', 'res_num_col', 'res_name_col', 'spin_num_col', 'spin_name_col', 'data_col', 'error_col', 'sep'].
        @type key:      str
        @param value:   The value that the specific GUI element's SetValue() method expects.
        @type value:    unknown
        """

        # The default GUI element.
        if self.element_type == 'default':
            # Get the element.
            obj = getattr(self, key)

            # Convert the data.
            if key == 'sep':
                value = str_to_gui(value)
            else:
                value = int_to_gui(value)

            # Set the value.
            obj.SetValue(value)

        # The mini GUI element.
        elif self.element_type == 'mini':
            # Get the current values.
            settings = self.GetValue()

            # Replace the value.
            settings[key] = value

            # Set the values.
            if self.data_cols:
                string = self.to_string(spin_id_col=settings['spin_id_col'], mol_name_col=settings['mol_name_col'], res_num_col=settings['res_num_col'], res_name_col=settings['res_name_col'], spin_num_col=settings['spin_num_col'], spin_name_col=settings['spin_name_col'], data_col=settings['data_col'], error_col=settings['error_col'], sep=settings['sep'])
            else:
                string = self.to_string(spin_id_col=settings['spin_id_col'], mol_name_col=settings['mol_name_col'], res_num_col=settings['res_num_col'], res_name_col=settings['res_name_col'], spin_num_col=settings['spin_num_col'], spin_name_col=settings['spin_name_col'], sep=settings['sep'])
            self.field.SetValue(str_to_gui(string))
Ejemplo n.º 58
0
    def select_mf(self, event):
        """NOE analysis selection.

        @param event:   The wx event.
        @type event:    wx event
        """

        # Toggle all buttons off.
        self.toggle(self.button_mf)

        # Update the analysis name.
        self.analysis_name.SetValue(str_to_gui('Model-free'))

        # Set the analysis type.
        self.parent.analysis_type = 'mf'
Ejemplo n.º 59
0
    def select_noe(self, event):
        """NOE analysis selection.

        @param event:   The wx event.
        @type event:    wx event
        """

        # Toggle all buttons off.
        self.toggle(self.button_noe)

        # Update the analysis name.
        self.analysis_name.SetValue(str_to_gui('Steady-state NOE'))

        # Set the analysis type.
        self.parent.analysis_type = 'noe'
Ejemplo n.º 60
0
    def select_r2(self, event):
        """NOE analysis selection.

        @param event:   The wx event.
        @type event:    wx event
        """

        # Toggle all buttons off.
        self.toggle(self.button_r2)

        # Update the analysis name.
        self.analysis_name.SetValue(str_to_gui("R2 relaxation"))

        # Set the analysis type.
        self.parent.analysis_type = 'r2'