Example #1
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))
Example #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 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))
    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)
Example #4
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))
Example #5
0
    def action_relax_disp_spin_lock_offset(self, event=None, item=None):
        """Launch the relax_disp.spin_lock_offset user function.

        @keyword event: The wx event.
        @type event:    wx event
        @keyword item:  This is for debugging purposes only, to allow the GUI tests to select items without worrying about OS dependent wxPython bugs.
        @type item:     None or int
        """

        # The current selection.
        if item == None:
            item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # The offset.
        offset = None
        offset_flag = False
        if hasattr(cdp, 'spin_lock_offset') and id in cdp.spin_lock_offset:
            offset = cdp.spin_lock_offset[id]
            offset_flag = True

        # Launch the dialog.
        if offset_flag:
            uf_store['relax_disp.spin_lock_offset'](offset=offset, spectrum_id=id)
        else:
            uf_store['relax_disp.spin_lock_offset'](spectrum_id=id)
Example #6
0
    def action_relax_disp_spin_lock_offset(self, event=None, item=None):
        """Launch the relax_disp.spin_lock_offset user function.

        @keyword event: The wx event.
        @type event:    wx event
        @keyword item:  This is for debugging purposes only, to allow the GUI tests to select items without worrying about OS dependent wxPython bugs.
        @type item:     None or int
        """

        # The current selection.
        if item == None:
            item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # The offset.
        offset = None
        offset_flag = False
        if hasattr(cdp, 'spin_lock_offset') and id in cdp.spin_lock_offset:
            offset = cdp.spin_lock_offset[id]
            offset_flag = True

        # Launch the dialog.
        if offset_flag:
            uf_store['relax_disp.spin_lock_offset'](offset=offset,
                                                    spectrum_id=id)
        else:
            uf_store['relax_disp.spin_lock_offset'](spectrum_id=id)
Example #7
0
    def action_relax_fit_relax_time(self, event=None, item=None):
        """Launch the relax_fit.relax_time user function.

        @keyword event: The wx event.
        @type event:    wx event
        @keyword item:  This is for debugging purposes only, to allow the GUI tests to select items without worrying about OS dependent wxPython bugs.
        @type item:     None or int
        """

        # The current selection.
        if item == None:
            item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # The current time.
        time = None
        if hasattr(cdp, 'relax_times') and id in cdp.relax_times:
            time = cdp.relax_times[id]

        # Launch the dialog.
        if time == None:
            uf_store['relax_fit.relax_time'](spectrum_id=id)
        else:
            uf_store['relax_fit.relax_time'](time=time, spectrum_id=id)
Example #8
0
    def action_spectrum_error_analysis(self, event):
        """Launch the spectrum.error_analysis user function.

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

        # The first item selected.
        item = self.element.GetFirstSelected()

        # Loop over the additional selections.
        ids = []
        while True:
            # No selection.
            if item == -1:
                break

            # Add the ID string to the list.
            ids.append(gui_to_str(self.element.GetItemText(item)))

            # Get the next selected item.
            item = self.element.GetNextSelected(item)

        # No selected items.
        if not len(ids):
            ids = None

        # Launch the dialog.
        uf_store['spectrum.error_analysis'](subset=ids, wx_wizard_modal=True)

        # Display the relax controller, and go to the end of the log window.
        self.gui.show_controller(None)
        self.gui.controller.log_panel.on_goto_end(None)
Example #9
0
    def action_relax_disp_cpmg_setup(self, event=None, item=None):
        """Launch the relax_disp.cpmg_setup user function.

        @keyword event: The wx event.
        @type event:    wx event
        @keyword item:  This is for debugging purposes only, to allow the GUI tests to select items without worrying about OS dependent wxPython bugs.
        @type item:     None or int
        """

        # The current selection.
        if item == None:
            item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # The current frequency.
        frq = None
        frq_flag = False
        if hasattr(cdp, 'cpmg_frqs') and id in cdp.cpmg_frqs:
            frq = cdp.cpmg_frqs[id]
            frq_flag = True

        # The current ncyc_even flag.
        even = True
        even_flag = False
        if hasattr(cdp, 'ncyc_even') and id in cdp.ncyc_even:
            even = cdp.ncyc_even[id]
            even_flag = True

        # Launch the dialog.
        if frq_flag:
            uf_store['relax_disp.cpmg_setup'](spectrum_id=id, cpmg_frq=frq, ncyc_even=even)
        else:
            uf_store['relax_disp.cpmg_setup'](spectrum_id=id, ncyc_even=even)
Example #10
0
    def action_relax_data_temp_calibration(self, event):
        """Launch the relax_data.temp_calibration user function.

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

        # The current selection.
        item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # The current method.
        method = None
        if hasattr(cdp, 'exp_info') and hasattr(
                cdp.exp_info,
                'temp_calibration') and id in cdp.exp_info.temp_calibrations():
            method = cdp.exp_info.temp_calibration[id]

        # Launch the dialog.
        if method == None:
            uf_store['relax_data.temp_calibration'](wx_parent=self.parent,
                                                    ri_id=id)
        else:
            uf_store['relax_data.temp_calibration'](wx_parent=self.parent,
                                                    ri_id=id,
                                                    method=method)
Example #11
0
    def action_relax_data_peak_intensity_type(self, event):
        """Launch the relax_data.peak_intensity_type user function.

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

        # The current selection.
        item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # The current type.
        type = None
        if hasattr(cdp, 'exp_info') and hasattr(
                cdp.exp_info, 'peak_intensity_type'
        ) and id in cdp.exp_info.peak_intensity_type:
            type = cdp.exp_info.peak_intensity_type[id]

        # Launch the dialog.
        if type == None:
            uf_store['relax_data.peak_intensity_type'](wx_parent=self.parent,
                                                       ri_id=id)
        else:
            uf_store['relax_data.peak_intensity_type'](wx_parent=self.parent,
                                                       ri_id=id,
                                                       type=type)
Example #12
0
    def wizard_page_after_rmsd(self):
        """Set the page that comes after the spectrum.baseplane_rmsd page.

        @return:    The index of the next page.
        @rtype:     int
        """

        # Go to the spectrum.integration_points page.
        int_method = gui_to_str(self.page_intensity.uf_args['int_method'].GetValue())
        if int_method != 'height':
            return self.page_indices['pts']

        # Skip to the noe.spectrum_type page.
        elif self.noe_flag:
            return self.page_indices['spectrum_type']

        # Skip to the relax_fit.relax_time page.
        elif self.relax_fit_flag:
            return self.page_indices['relax_time']

        # Skip to the first dispersion page.
        elif self.relax_disp_flag:
            return self.page_indices['exp_type']

        # Nothing left, so run off the end.
        else:
            return self._num_pages + 1
Example #13
0
    def action_spectrum_error_analysis(self, event):
        """Launch the spectrum.error_analysis user function.

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

        # The first item selected.
        item = self.element.GetFirstSelected()

        # Loop over the additional selections.
        ids = []
        while True:
            # No selection.
            if item == -1:
                break

            # Add the ID string to the list.
            ids.append(gui_to_str(self.element.GetItemText(item)))

            # Get the next selected item.
            item = self.element.GetNextSelected(item)

        # No selected items.
        if not len(ids):
            ids = None

        # Launch the dialog.
        uf_store['spectrum.error_analysis'](subset=ids, wx_wizard_modal=True)

        # Display the relax controller, and go to the end of the log window.
        self.gui.show_controller(None)
        self.gui.controller.log_panel.on_goto_end(None)
Example #14
0
    def action_spectrometer_frq(self, event=None, item=None):
        """Launch the spectrometer.frequency user function.

        @keyword event: The wx event.
        @type event:    wx event
        @keyword item:  This is for debugging purposes only, to allow the GUI tests to select items without worrying about OS dependent wxPython bugs.
        @type item:     None or int
        """

        # The current selection.
        if item == None:
            item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # The current frequency.
        frq = None
        if hasattr(cdp, 'spectrometer_frq') and id in cdp.spectrometer_frq:
            frq = cdp.spectrometer_frq[id]

        # Launch the dialog.
        if frq == None:
            uf_store['spectrometer.frequency'](id=id)
        else:
            uf_store['spectrometer.frequency'](frq=frq, id=id)
Example #15
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))
Example #16
0
    def wizard_page_after_rmsd(self):
        """Set the page that comes after the spectrum.baseplane_rmsd page.

        @return:    The index of the next page.
        @rtype:     int
        """

        # Go to the spectrum.integration_points page.
        int_method = gui_to_str(
            self.page_intensity.uf_args['int_method'].GetValue())
        if int_method != 'height':
            return self.page_indices['pts']

        # Skip to the noe.spectrum_type page.
        elif self.noe_flag:
            return self.page_indices['spectrum_type']

        # Skip to the relax_fit.relax_time page.
        elif self.relax_fit_flag:
            return self.page_indices['relax_time']

        # Skip to the first dispersion page.
        elif self.relax_disp_flag:
            return self.page_indices['exp_type']

        # Nothing left, so run off the end.
        else:
            return self._num_pages + 1
Example #17
0
    def action_molecule_type(self, event):
        """Launch the molecule.type user function.

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

        # The current selection.
        item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # The current type.
        type = None
        mol = return_molecule(id)
        if hasattr(mol, 'type') and mol.type != None:
            type = mol.type

        # Launch the dialog.
        if type == None:
            uf_store['molecule.type'](wx_parent=self.parent, mol_id=id)
        else:
            uf_store['molecule.type'](wx_parent=self.parent,
                                      mol_id=id,
                                      type=type)
Example #18
0
    def action_relax_fit_relax_time(self, event=None, item=None):
        """Launch the relax_fit.relax_time user function.

        @keyword event: The wx event.
        @type event:    wx event
        @keyword item:  This is for debugging purposes only, to allow the GUI tests to select items without worrying about OS dependent wxPython bugs.
        @type item:     None or int
        """

        # The current selection.
        if item == None:
            item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # The current time.
        time = None
        if hasattr(cdp, 'relax_times') and id in cdp.relax_times:
            time = cdp.relax_times[id]

        # Launch the dialog.
        if time == None:
            uf_store['relax_fit.relax_time'](spectrum_id=id)
        else:
            uf_store['relax_fit.relax_time'](time=time, spectrum_id=id)
Example #19
0
    def action_spectrum_replicated(self, event=None, item=None):
        """Launch the spectrum.replicated user function.

        @keyword event: The wx event.
        @type event:    wx event
        @keyword item:  This is for debugging purposes only, to allow the GUI tests to select items without worrying about OS dependent wxPython bugs.
        @type item:     None or int
        """

        # No elements in the list.
        if not self.element.GetItemCount():
            return

        # The current selection.
        if item == None:
            item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # The current replicates.
        replicates = replicated_ids(id)

        # Launch the dialog.
        if replicates == []:
            uf_store['spectrum.replicated'](spectrum_ids=id)
        else:
            uf_store['spectrum.replicated'](spectrum_ids=replicates)
Example #20
0
    def action_spectrometer_frq(self, event=None, item=None):
        """Launch the spectrometer.frequency user function.

        @keyword event: The wx event.
        @type event:    wx event
        @keyword item:  This is for debugging purposes only, to allow the GUI tests to select items without worrying about OS dependent wxPython bugs.
        @type item:     None or int
        """

        # The current selection.
        if item == None:
            item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # The current frequency.
        frq = None
        if hasattr(cdp, 'spectrometer_frq') and id in cdp.spectrometer_frq:
            frq = cdp.spectrometer_frq[id]

        # Launch the dialog.
        if frq == None:
            uf_store['spectrometer.frequency'](id=id)
        else:
            uf_store['spectrometer.frequency'](frq=frq, id=id)
Example #21
0
    def get_data(self):
        """Assemble and return the analysis type, analysis name, and pipe name.

        @return:    The analysis type, analysis name, data pipe name, data pipe bundle name, and list of user function on_execute methods.
        @rtype:     str, str, str, str, list of methods
        """

        # Get the data.
        analysis_type = gui_to_str(self.wizard.analysis_type)
        analysis_name = gui_to_str(self.new_page.analysis_name.GetValue())
        pipe_name = gui_to_str(self.pipe_page.pipe_name.GetValue())
        pipe_bundle = gui_to_str(self.pipe_page.pipe_bundle.GetValue())

        # The user function on_execute methods.
        uf_exec = []

        # Return it.
        return analysis_type, analysis_name, pipe_name, pipe_bundle, uf_exec
Example #22
0
    def GetValue(self):
        """Special method for returning the value of the GUI element.

        @return:    The string value.
        @rtype:     list of str
        """

        # Convert and return the value from a TextCtrl.
        return gui_to_str(self._field.GetValue())
Example #23
0
    def action_spin_spin_select(self, event):
        """Wrapper method.

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

        # Select the spin.
        self.gui.interpreter.queue('select.spin', spin_id=gui_to_str(self.info['id']), change_all=False)
Example #24
0
    def GetValue(self):
        """Return the file name.

        @return:    The file name.
        @rtype:     str
        """

        # Return the current value.
        return gui_to_str(self.field.GetValue())
Example #25
0
    def GetValue(self):
        """Return the file name.

        @return:    The file name.
        @rtype:     str
        """

        # Return the current value.
        return gui_to_str(self.field.GetValue())
Example #26
0
    def action_spin_spin_select(self, event):
        """Wrapper method.

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

        # Select the spin.
        self.gui.interpreter.queue('select.spin', spin_id=gui_to_str(self.info['id']), change_all=False)
Example #27
0
    def GetValue(self):
        """Special method for returning the value of the GUI element.

        @return:    The string value.
        @rtype:     list of str
        """

        # Convert and return the value from a TextCtrl.
        return gui_to_str(self._field.GetValue())
Example #28
0
    def open_result_file(self, event):
        """Open the results in the appropriate program.

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

        # Loop over all files.
        for i in range(self.file_list.GetItemCount()):
            # Not selected.
            if not self.file_list.IsSelected(i):
                continue

            # Get the type and file.
            type = self.file_data[i]
            file = gui_to_str(self.file_list.GetItem(i, 1).GetText())

            # Grace files.
            if type == 'grace':
                uf_store['grace.view'](file=file, wx_parent=self)

            # PyMOL macro files.
            elif type == 'pymol':
                uf_store['pymol.macro_run'](file=file, wx_parent=self)

            # Molmol macro files.
            elif type == 'molmol':
                uf_store['molmol.macro_run'](file=file, wx_parent=self)

            # Diffusion tensor PDB.
            elif type == 'diff_tensor_pdb':
                # Try and see if PyMOL is installed.
                if not interpreter.apply('pymol.view'):
                    return

                # Display the tensor.
                interpreter.apply('pymol.cartoon')
                interpreter.apply('pymol.tensor_pdb', file=file)

            # A special table.
            elif type == 'Table_of_Results':
                # The data.
                model_result = [
                    ds.relax_gui.table_residue, ds.relax_gui.table_model,
                    ds.relax_gui.table_s2, ds.relax_gui.table_rex,
                    ds.relax_gui.table_te
                ]

            # Text files.
            elif type == 'text':
                open_file(file, force_text=True)

            # Open all other files in which ever editor the platform decides on.
            else:
                open_file(file)
Example #29
0
    def GetValue(self):
        """Special method for returning the value of the GUI element.

        @return:    The spin ID value.
        @rtype:     str or None
        """

        # An element selected from the list.
        sel_index = self._field.GetSelection()
        if sel_index == wx.NOT_FOUND:
            value = None
        else:
            value = gui_to_str(self._field.GetClientData(sel_index))

        # A non-list value.
        if value == None:
            value = gui_to_str(self._field.GetValue())

        # Return the value.
        return value
Example #30
0
    def GetValue(self):
        """Special method for returning the value of the GUI element.

        @return:    The spin ID value.
        @rtype:     str or None
        """

        # An element selected from the list.
        sel_index = self._field.GetSelection()
        if sel_index == wx.NOT_FOUND:
            value = None
        else:
            value = gui_to_str(self._field.GetClientData(sel_index))

        # A non-list value.
        if value == None:
            value = gui_to_str(self._field.GetValue())

        # Return the value.
        return value
Example #31
0
    def wizard_page_after_analysis(self):
        """Set the page after the data pipe setup.

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

        # The selected analysis.
        analysis_name = gui_to_str(self.new_page.analysis_name.GetValue())

        # Default to the second page.
        return 1
Example #32
0
    def open_result_file(self, event):
        """Open the results in the appropriate program.

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

        # Loop over all files.
        for i in range(self.file_list.GetItemCount()):
            # Not selected.
            if not self.file_list.IsSelected(i):
                continue

            # Get the type and file.
            type = self.file_data[i]
            file = gui_to_str(self.file_list.GetItem(i, 1).GetText())

            # Grace files.
            if type == 'grace':
                uf_store['grace.view'](file=file, wx_parent=self)

            # PyMOL macro files.
            elif type == 'pymol':
                uf_store['pymol.macro_run'](file=file, wx_parent=self)

            # Molmol macro files.
            elif type == 'molmol':
                uf_store['molmol.macro_run'](file=file, wx_parent=self)

            # Diffusion tensor PDB.
            elif type == 'diff_tensor_pdb':
                # Try and see if PyMOL is installed.
                if not interpreter.apply('pymol.view'):
                    return

                # Display the tensor.
                interpreter.apply('pymol.cartoon')
                interpreter.apply('pymol.tensor_pdb', file=file)

            # A special table.
            elif type == 'Table_of_Results':
                # The data.
                model_result = [ds.relax_gui.table_residue, ds.relax_gui.table_model, ds.relax_gui.table_s2, ds.relax_gui.table_rex, ds.relax_gui.table_te]

            # Text files.
            elif type == 'text':
                open_file(file, force_text=True)

            # Open all other files in which ever editor the platform decides on.
            else:
                open_file(file)
Example #33
0
    def menu(self, event):
        """The pop up menu.

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

        # Get the row.
        row = event.GetRow()

        # Get the name of the data pipe.
        self.selected_pipe = gui_to_str(self.grid.GetCellValue(row, 0))

        # No data pipe.
        if not self.selected_pipe:
            return

        # The pipe type and bundle.
        pipe_type = get_type(self.selected_pipe)
        pipe_bundle = get_bundle(self.selected_pipe)

        # Initialise the menu.
        menu = wx.Menu()
        items = []

        # Menu entry:  add the data pipe to a bundle.
        if not pipe_bundle:
            items.append(build_menu_item(menu, parent=self, text="&Add the pipe to a bundle", icon=fetch_icon("relax.pipe_bundle"), fn=self.pipe_bundle))

        # Menu entry:  delete the data pipe.
        items.append(build_menu_item(menu, parent=self, text="&Delete the pipe", icon=fetch_icon('oxygen.actions.list-remove', "16x16"), fn=self.pipe_delete))
 
        # Menu entry:  switch to this data pipe.
        items.append(build_menu_item(menu, parent=self, text="&Switch to this pipe", icon=fetch_icon('oxygen.actions.system-switch-user', "16x16"), fn=self.pipe_switch))
 
        # Menu entry:  new auto-analysis tab.
        if pipe_bundle and self.gui.analysis.page_index_from_bundle(pipe_bundle) == None and pipe_type in ['noe', 'r1', 'r2', 'mf', 'relax_disp']:
            items.append(build_menu_item(menu, parent=self, text="&Associate with a new auto-analysis", icon=fetch_icon('oxygen.actions.document-new', "16x16"), fn=self.associate_auto))
 
        # Set up the entries.
        for item in items:
            menu.AppendItem(item)
            if status.exec_lock.locked():
                item.Enable(False)

        # Show the menu.
        if status.show_gui:
            self.PopupMenu(menu)

        # Kill the menu once done.
        menu.Destroy()
Example #34
0
    def action_residue_residue_select(self, event):
        """Wrapper method.

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

        # Ask if this should be done.
        msg = "Are you sure you would like to select all spins of this residue?"
        if status.show_gui and Question(msg, parent=self.gui.spin_viewer, default=False).ShowModal() == wx.ID_NO:
            return

        # Select the residue.
        self.gui.interpreter.queue('select.spin', spin_id=gui_to_str(self.info['id']), change_all=False)
Example #35
0
    def action_spin_spin_delete(self, event):
        """Wrapper method.

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

        # Ask if this should be done.
        msg = "Are you sure you would like to delete this spin?  This only affects the spin data, all structural data will remain.  This operation cannot be undone."
        if status.show_gui and Question(msg, parent=self.gui.spin_viewer, default=False, size=(400, 170)).ShowModal() == wx.ID_NO:
            return

        # Delete the spin.
        self.gui.interpreter.queue('spin.delete', gui_to_str(self.info['id']))
Example #36
0
    def GetValue(self):
        """Return the free file format settings as a keyword dictionary.

        @return:    The dictionary of free file format settings.
        @rtype:     dict
        """

        # Initialise.
        settings = {}

        # The default GUI element.
        if self.element_type == 'default':
            # Get the column numbers.
            settings['spin_id_col'] = gui_to_int(self.spin_id_col.GetValue())
            settings['mol_name_col'] = gui_to_int(self.mol_name_col.GetValue())
            settings['res_num_col'] = gui_to_int(self.res_num_col.GetValue())
            settings['res_name_col'] = gui_to_int(self.res_name_col.GetValue())
            settings['spin_num_col'] = gui_to_int(self.spin_num_col.GetValue())
            settings['spin_name_col'] = gui_to_int(
                self.spin_name_col.GetValue())
            if self.data_cols:
                settings['data_col'] = gui_to_int(self.data_col.GetValue())
                settings['error_col'] = gui_to_int(self.error_col.GetValue())

            # The column separator.
            settings['sep'] = str(self.sep.GetValue())
            if settings['sep'] == 'white space':
                settings['sep'] = None

        # The mini GUI element.
        elif self.element_type == 'mini':
            # Convert the values.
            values = self.from_string(string=gui_to_str(self.field.GetValue()))

            # Store them.
            settings['spin_id_col'] = values[0]
            settings['mol_name_col'] = values[1]
            settings['res_num_col'] = values[2]
            settings['res_name_col'] = values[3]
            settings['spin_num_col'] = values[4]
            settings['spin_name_col'] = values[5]
            if self.data_cols:
                settings['data_col'] = values[6]
                settings['error_col'] = values[7]
                settings['sep'] = values[8]
            else:
                settings['sep'] = values[6]

        # Return the settings.
        return settings
Example #37
0
    def action_residue_residue_select(self, event):
        """Wrapper method.

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

        # Ask if this should be done.
        msg = "Are you sure you would like to select all spins of this residue?"
        if status.show_gui and Question(msg, parent=self.gui.spin_viewer, default=False).ShowModal() == wx.ID_NO:
            return

        # Select the residue.
        self.gui.interpreter.queue('select.spin', spin_id=gui_to_str(self.info['id']), change_all=False)
Example #38
0
    def action_spin_spin_delete(self, event):
        """Wrapper method.

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

        # Ask if this should be done.
        msg = "Are you sure you would like to delete this spin?  This only affects the spin data, all structural data will remain.  This operation cannot be undone."
        if status.show_gui and Question(msg, parent=self.gui.spin_viewer, default=False, size=(400, 170)).ShowModal() == wx.ID_NO:
            return

        # Delete the spin.
        self.gui.interpreter.queue('spin.delete', gui_to_str(self.info['id']))
    def GetValue(self):
        """Return the free file format settings as a keyword dictionary.

        @return:    The dictionary of free file format settings.
        @rtype:     dict
        """

        # Initialise.
        settings = {}

        # The default GUI element.
        if self.element_type == 'default':
            # Get the column numbers.
            settings['spin_id_col'] =   gui_to_int(self.spin_id_col.GetValue())
            settings['mol_name_col'] =  gui_to_int(self.mol_name_col.GetValue())
            settings['res_num_col'] =   gui_to_int(self.res_num_col.GetValue())
            settings['res_name_col'] =  gui_to_int(self.res_name_col.GetValue())
            settings['spin_num_col'] =  gui_to_int(self.spin_num_col.GetValue())
            settings['spin_name_col'] = gui_to_int(self.spin_name_col.GetValue())
            if self.data_cols:
                settings['data_col'] =  gui_to_int(self.data_col.GetValue())
                settings['error_col'] = gui_to_int(self.error_col.GetValue())

            # The column separator.
            settings['sep'] = str(self.sep.GetValue())
            if settings['sep'] == 'white space':
                settings['sep'] = None

        # The mini GUI element.
        elif self.element_type == 'mini':
            # Convert the values.
            values = self.from_string(string=gui_to_str(self.field.GetValue()))

            # Store them.
            settings['spin_id_col'] = values[0]
            settings['mol_name_col'] = values[1]
            settings['res_num_col'] = values[2]
            settings['res_name_col'] = values[3]
            settings['spin_num_col'] = values[4]
            settings['spin_name_col'] = values[5]
            if self.data_cols:
                settings['data_col'] = values[6]
                settings['error_col'] = values[7]
                settings['sep'] = values[8]
            else:
                settings['sep'] = values[6]

        # Return the settings.
        return settings
Example #40
0
    def action_relax_data_display(self, event):
        """Launch the relax_data.display user function.

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

        # The current selection.
        item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # Launch the dialog.
        uf_store['relax_data.display'](wx_parent=self.parent, ri_id=id)
Example #41
0
    def action_molecule_name(self, event):
        """Launch the molecule.name user function.

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

        # The current selection.
        item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # Launch the dialog.
        uf_store['molecule.name'](wx_parent=self.parent, mol_id=id)
Example #42
0
    def action_molecule_name(self, event):
        """Launch the molecule.name user function.

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

        # The current selection.
        item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # Launch the dialog.
        uf_store['molecule.name'](wx_parent=self.parent, mol_id=id)
Example #43
0
    def get_path(self):
        """Return the selected path.

        @return:        The name of the selected path.
        @rtype:         str
        """

        # The path.
        path = gui_to_str(self.GetPath())

        # Change the current working directory.
        chdir(path)

        # Return the path.
        return path
Example #44
0
    def action_spectrum_integration_points(self, event):
        """Launch the spectrum.integration_points user function.

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

        # The current selection.
        item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # Launch the dialog.
        uf_store['spectrum.integration_points'](spectrum_id=id)
Example #45
0
    def action_relax_data_display(self, event):
        """Launch the relax_data.display user function.

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

        # The current selection.
        item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # Launch the dialog.
        uf_store['relax_data.display'](wx_parent=self.parent, ri_id=id)
Example #46
0
    def action_spectrum_integration_points(self, event):
        """Launch the spectrum.integration_points user function.

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

        # The current selection.
        item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # Launch the dialog.
        uf_store['spectrum.integration_points'](spectrum_id=id)
Example #47
0
    def get_path(self):
        """Return the selected path.

        @return:        The name of the selected path.
        @rtype:         str
        """

        # The path.
        path = gui_to_str(self.GetPath())

        # Change the current working directory.
        chdir(path)

        # Return the path.
        return path
Example #48
0
    def preview_file(self, event=None):
        """Preview a file.

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

        # The file name.
        file = gui_to_str(self._field.GetValue())

        # No file, so do nothing.
        if file == None:
            return

        # Open the file as text.
        open_file(file, force_text=True)
Example #49
0
    def preview_file(self, event=None):
        """Preview a file.

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

        # The file name.
        file = gui_to_str(self._field.GetValue())

        # No file, so do nothing.
        if file == None:
            return

        # Open the file as text.
        open_file(file, force_text=True)
Example #50
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()
Example #51
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()
Example #52
0
    def GetValue(self):
        """Special method for returning the value of the GUI element.

        @return:    The string value.
        @rtype:     list of str
        """

        # The value.
        value = self._field.GetValue()

        # Handle single values.
        value_set = False
        try:
            # Convert.
            value = gui_to_str(value)

            # Check that the conversion was successful.
            if value == None and self.can_be_none:
                value_set = True
            else:
                if value[0] != '[':
                    value_set = True
        except:
            pass

        # Convert to a list, handling bad user behaviour.
        if not value_set:
            try:
                value = gui_to_list(value)

            # Set the value to None or an empty sequence.
            except:
                if self.can_be_none:
                    value = None
                else:
                    value = []

        # Convert sequences to single values as needed.
        if isinstance(value, list) and len(value) == 1:
            value = value[0]

        # Handle empty list and tuple values.
        if len(value) == 0:
            return None

        # Return the value.
        return value
Example #53
0
    def GetValue(self):
        """Special method for returning the value of the GUI element.

        @return:    The string value.
        @rtype:     list of str
        """

        # The value.
        value = self._field.GetValue()

        # Handle single values.
        value_set = False
        try:
            # Convert.
            value = gui_to_str(value)

            # Check that the conversion was successful.
            if value == None and self.can_be_none:
                value_set = True
            else:
                if value[0] != '[':
                    value_set = True
        except:
            pass

        # Convert to a list, handling bad user behaviour.
        if not value_set:
            try:
                value = gui_to_list(value)

            # Set the value to None or an empty sequence.
            except:
                if self.can_be_none:
                    value = None
                else:
                    value = []

        # Convert sequences to single values as needed.
        if isinstance(value, list) and len(value) == 1:
            value = value[0]

        # Handle empty list and tuple values.
        if len(value) == 0:
            return None

        # Return the value.
        return value
Example #54
0
    def assemble_data(self):
        """Assemble the data required for the auto-analysis.

        See the docstring for auto_analyses.relax_fit for details.  All data is taken from the relax data store, so data upload from the GUI to there must have been previously performed.

        @return:    A container with all the data required for the auto-analysis.
        @rtype:     class instance, list of str
        """

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

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

        # The frequency.
        frq = gui_to_str(self.field_nmr_frq.GetValue())
        if frq == None:
            missing.append('NMR frequency')

        # File root.
        data.file_root = '%s.%s' % (self.analysis_type, frq)

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

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

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

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

        # Results directory.
        data.save_dir = self.data.save_dir

        # Return the container and list of missing data.
        return data, missing
Example #55
0
    def assemble_data(self):
        """Assemble the data required for the auto-analysis.

        See the docstring for auto_analyses.relax_fit for details.  All data is taken from the relax data store, so data upload from the GUI to there must have been previously performed.

        @return:    A container with all the data required for the auto-analysis.
        @rtype:     class instance, list of str
        """

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

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

        # The frequency.
        frq = gui_to_str(self.field_nmr_frq.GetValue())
        if frq == None:
            missing.append('NMR frequency')

        # File root.
        data.file_root = '%s.%s' % (self.analysis_type, frq)

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

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

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

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

        # Results directory.
        data.save_dir = self.data.save_dir

        # Return the container and list of missing data.
        return data, missing
Example #56
0
    def action_spectrum_delete(self, event):
        """Launch the spectrum.delete user function.

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

        # The current selection.
        item = self.element.GetFirstSelected()

        # No selection.
        if item == -1:
            id = None

        # Selected item.
        else:
            # The spectrum ID.
            id = gui_to_str(self.element.GetItemText(item))

        # Launch the dialog.
        uf_store['spectrum.delete'](spectrum_id=id)
Example #57
0
    def action_spectrum_replicated(self, event):
        """Launch the spectrum.replicated user function.

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

        # The current selection.
        item = self.element.GetFirstSelected()

        # The spectrum ID.
        id = gui_to_str(self.element.GetItemText(item))

        # The current replicates.
        replicates = replicated_ids(id)

        # Launch the dialog.
        if replicates == []:
            uf_store['spectrum.replicated'](spectrum_ids=id)
        else:
            uf_store['spectrum.replicated'](spectrum_ids=replicates)
Example #58
0
    def action_spectrum_delete(self, event):
        """Launch the spectrum.delete user function.

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

        # The current selection.
        item = self.element.GetFirstSelected()

        # No selection.
        if item == -1:
            id = None

        # Selected item.
        else:
            # The spectrum ID.
            id = gui_to_str(self.element.GetItemText(item))

        # Launch the dialog.
        uf_store['spectrum.delete'](spectrum_id=id)