Author: bugman Date: Thu Jul 14 16:21:41 2011 New Revision: 13623 URL: http://svn.gna.org/viewcvs/relax?rev=13623&view=rev Log: Implemented the noe user function GUI pages and menu entries. Added: branches/gui_testing/gui/user_functions/noe.py - copied, changed from r13607, branches/gui_testing/gui/user_functions/relax_data.py Modified: branches/gui_testing/gui/menu.py branches/gui_testing/gui/user_functions/__init__.py Modified: branches/gui_testing/gui/menu.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/menu.py?rev=13623&r1=13622&r2=13623&view=diff ============================================================================== --- branches/gui_testing/gui/menu.py (original) +++ branches/gui_testing/gui/menu.py Thu Jul 14 16:21:41 2011 @@ -211,6 +211,10 @@ [wx.NewId(), "crea&te", paths.icon_16x16.add, self.gui.user_functions.molecule.create], [wx.NewId(), "&delete", paths.icon_16x16.remove, self.gui.user_functions.molecule.delete] ]], + [wx.NewId(), "&noe", None, None, [ + [wx.NewId(), "&read_restraints", paths.icon_16x16.open, self.gui.user_functions.noe.read_restraints], + [wx.NewId(), "&spectrum_type", None, self.gui.user_functions.noe.spectrum_type] + ]], [wx.NewId(), "&pipe", paths.icon_16x16.pipe, None, [ [wx.NewId(), "©", paths.icon_16x16.copy, self.gui.user_functions.pipes.copy], [wx.NewId(), "crea&te", paths.icon_16x16.add, self.gui.user_functions.pipes.create], Modified: branches/gui_testing/gui/user_functions/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/user_functions/__init__.py?rev=13623&r1=13622&r2=13623&view=diff ============================================================================== --- branches/gui_testing/gui/user_functions/__init__.py (original) +++ branches/gui_testing/gui/user_functions/__init__.py Thu Jul 14 16:21:41 2011 @@ -29,6 +29,7 @@ # GUI module imports. from deselect import Deselect from molecule import Molecule +from noe import Noe from pipes import Pipes from residue import Residue from relax_data import Relax_data @@ -45,6 +46,7 @@ __all__ = ['base', 'deselect', 'molecule', + 'noe', 'pipes', 'residue', 'relax_data', @@ -72,6 +74,7 @@ # The user functions. self.deselect = Deselect(self.gui) self.molecule = Molecule(self.gui) + self.noe = Noe(self.gui) self.pipes = Pipes(self.gui) self.residue = Residue(self.gui) self.relax_data = Relax_data(self.gui) @@ -90,6 +93,7 @@ # Send the commands onwards to the user function classes. self.deselect.destroy() self.molecule.destroy() + self.noe.destroy() self.pipes.destroy() self.residue.destroy() self.relax_data.destroy() Copied: branches/gui_testing/gui/user_functions/noe.py (from r13607, branches/gui_testing/gui/user_functions/relax_data.py) URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/user_functions/noe.py?p2=branches/gui_testing/gui/user_functions/noe.py&p1=branches/gui_testing/gui/user_functions/relax_data.py&r1=13607&r2=13623&rev=13623&view=diff ============================================================================== --- branches/gui_testing/gui/user_functions/relax_data.py (original) +++ branches/gui_testing/gui/user_functions/noe.py Thu Jul 14 16:21:41 2011 @@ -21,9 +21,10 @@ ############################################################################### # Module docstring. -"""The relaxation data user function GUI elements.""" +"""The noe user function GUI elements.""" # Python module imports. +from os import sep from string import split # relax module imports. @@ -31,127 +32,76 @@ # GUI module imports. from base import UF_base, UF_page -from gui.paths import WIZARD_IMAGE_PATH +from gui.paths import ANALYSIS_IMAGE_PATH from gui.misc import gui_to_float, gui_to_int, gui_to_str from gui.wizard import Wiz_window # The container class. -class Relax_data(UF_base): +class Noe(UF_base): """The container class for holding all GUI elements.""" - def delete(self, event): - """The relax_data.delete user function. + def read_restraints(self, event): + """The noe.read_restraints user function. @param event: The wx event. @type event: wx event """ # Execute the wizard. - wizard = Wiz_window(size_x=700, size_y=400, title=self.get_title('relax_data', 'delete')) - page = Delete_page(wizard, self.gui) + wizard = Wiz_window(size_x=800, size_y=600, title=self.get_title('noe', 'read_restraints')) + page = Read_restraints_page(wizard, self.gui) wizard.add_page(page) wizard.run() - def read(self, event): - """The relax_data.read user function. + def spectrum_type(self, event): + """The noe.spectrum_type user function. @param event: The wx event. @type event: wx event """ # Execute the wizard. - wizard = Wiz_window(size_x=1000, size_y=800, title=self.get_title('relax_data', 'read')) - page = Read_page(wizard, self.gui) + wizard = Wiz_window(size_x=800, size_y=600, title=self.get_title('noe', 'spectrum_type')) + page = Spectrum_type_page(wizard, self.gui) wizard.add_page(page) wizard.run() -class Delete_page(UF_page): - """The relax_data.read() user function page.""" +class Read_restraints_page(UF_page): + """The noe.read_restraints() user function page.""" # Some class variables. - image_path = WIZARD_IMAGE_PATH + 'fid.png' - uf_path = ['relax_data', 'delete'] + image_path = ANALYSIS_IMAGE_PATH + 'noe_200x200.png' + uf_path = ['noe', 'read_restraints'] def add_contents(self, sizer): - """Add the relaxation data deletion specific GUI elements. - - @param sizer: A sizer object. - @type sizer: wx.Sizer instance - """ - - # The ID. - self.ri_id = self.combo_box(sizer, "The relaxation data ID:", tooltip=self.uf._doc_args_dict['ri_id']) - - - def on_execute(self): - """Execute the user function.""" - - # The labels and frq. - ri_id = gui_to_str(self.ri_id.GetValue()) - - # Read the relaxation data. - self.gui.interpreter.relax_data.delete(ri_id=ri_id) - - - def on_display(self): - """Clear previous data and update the label lists.""" - - # Clear the previous data. - self.ri_id.Clear() - - # No data, so don't try to fill the combo boxes. - if not hasattr(cdp, 'ri_ids'): - return - - # The relaxation data IDs. - for i in range(len(cdp.ri_ids)): - self.ri_id.Append(cdp.ri_ids[i]) - - - -class Read_page(UF_page): - """The relax_data.read() user function page.""" - - # Some class variables. - desc_height = 180 - image_path = WIZARD_IMAGE_PATH + 'fid.png' - uf_path = ['relax_data', 'read'] - - def add_contents(self, sizer): - """Add the relaxation data reading specific GUI elements. + """Add the page specific GUI elements. @param sizer: A sizer object. @type sizer: wx.Sizer instance """ # Add a file selection. - self.file = self.file_selection(sizer, "The relaxation data file:", title="Relaxation data file selection", tooltip=self.uf._doc_args_dict['file']) + self.file = self.file_selection(sizer, "The restraint file:", title="Restraint file selection", tooltip=self.uf._doc_args_dict['file']) - # The labels. - self.ri_id = self.input_field(sizer, "The relaxation data ID:", tooltip=self.uf._doc_args_dict['ri_id']) - self.ri_type = self.combo_box(sizer, "The relaxation data type:", choices=['R1', 'R2', 'NOE'], tooltip=self.uf._doc_args_dict['ri_type']) + # The columns. + self.proton1_col = self.input_field(sizer, "The 1st proton column:", tooltip=self.uf._doc_args_dict['proton1_col']) + self.proton2_col = self.input_field(sizer, "The 2nd proton column:", tooltip=self.uf._doc_args_dict['proton2_col']) + self.lower_col = self.input_field(sizer, "The lower bound column:", tooltip=self.uf._doc_args_dict['lower_col']) + self.upper_col = self.input_field(sizer, "The upper bound column:", tooltip=self.uf._doc_args_dict['upper_col']) - # The frequency. - self.frq = self.input_field(sizer, "The proton frequency in Hz:", tooltip=self.uf._doc_args_dict['frq']) + # The column separator. + self.sep = self.combo_box(sizer, "Column separator:", ["white space", ",", ";", ":", ""], read_only=False) - # The spin ID restriction. - self.spin_id = self.spin_id_element(sizer, desc="Restrict data loading to certain spins:") - - # The parameter file settings. - self.free_file_format(sizer, data_cols=True, padding=5, spacer=0) + # Spacing. + sizer.AddStretchSpacer() def on_execute(self): """Execute the user function.""" - - # The labels and frq. - ri_id = gui_to_str(self.ri_id.GetValue()) - ri_type = gui_to_str(self.ri_type.GetValue()) - frq = gui_to_float(self.frq.GetValue()) # The file name. file = gui_to_str(self.file.GetValue()) @@ -161,22 +111,70 @@ return # Get the column numbers. - spin_id_col = gui_to_int(self.spin_id_col.GetValue()) - mol_name_col = gui_to_int(self.mol_name_col.GetValue()) - res_num_col = gui_to_int(self.res_num_col.GetValue()) - res_name_col = gui_to_int(self.res_name_col.GetValue()) - spin_num_col = gui_to_int(self.spin_num_col.GetValue()) - spin_name_col = gui_to_int(self.spin_name_col.GetValue()) - data_col = gui_to_int(self.data_col.GetValue()) - err_col = gui_to_int(self.err_col.GetValue()) + proton1_col = gui_to_int(self.proton1_col.GetValue()) + proton2_col = gui_to_int(self.proton2_col.GetValue()) + lower_col = gui_to_int(self.lower_col.GetValue()) + upper_col = gui_to_int(self.upper_col.GetValue()) # The column separator. sep = str(self.sep.GetValue()) if sep == 'white space': sep = None - # The spin ID. - spin_id = gui_to_str(self.spin_id.GetValue()) + # Read the NOESY data. + self.gui.interpreter.noe.read_restraints(file=file, proton1_col=proton1_col, proton2_col=proton2_col, lower_col=lower_col, upper_col=upper_col, sep=sep) + + + +class Spectrum_type_page(UF_page): + """The noe.spectrum_type() user function page.""" + + # Some class variables. + image_path = ANALYSIS_IMAGE_PATH + 'noe_200x200.png' + uf_path = ['noe', 'spectrum_type'] + + def add_contents(self, sizer): + """Add the page specific GUI elements. + + @param sizer: A sizer object. + @type sizer: wx.Sizer instance + """ + + # The spectrum type. + self.spectrum_type = self.combo_box(sizer, "The spectrum type:", tooltip=self.uf._doc_args_dict['spectrum_type'], choices=['Saturated spectrum', 'Reference spectrum']) + self.spectrum_type.SetClientData(0, 'sat') + self.spectrum_type.SetClientData(1, 'ref') + + # The spectrum ID. + self.spectrum_id = self.combo_box(sizer, "The spectrum ID:", tooltip=self.uf._doc_args_dict['spectrum_id']) + + # Spacing. + sizer.AddStretchSpacer() + + + def on_execute(self): + """Execute the user function.""" + + # The values. + spectrum_type = gui_to_str(self.spectrum_type.GetClientData(self.spectrum_type.GetSelection())) + + # The spectrum ID. + spectrum_id = gui_to_str(self.spectrum_id.GetValue()) # Read the relaxation data. - self.gui.interpreter.relax_data.read(ri_id=ri_id, ri_type=ri_type, frq=frq, file=file, spin_id_col=spin_id_col, mol_name_col=mol_name_col, res_num_col=res_num_col, res_name_col=res_name_col, spin_num_col=spin_num_col, spin_name_col=spin_name_col, data_col=data_col, error_col=err_col, sep=sep, spin_id=spin_id) + self.gui.interpreter.noe.spectrum_type(spectrum_type=spectrum_type, spectrum_id=spectrum_id) + + + def on_display(self): + """Clear previous data and update the spectrum ID list.""" + + # Clear the previous data. + self.spectrum_id.Clear() + + # No data, so don't try to fill the combo box. + if not hasattr(cdp, 'spectrum_ids'): + return + + # The spectrum IDs. + for i in range(len(cdp.spectrum_ids)): + self.spectrum_id.Append(cdp.spectrum_ids[i])