Author: bugman Date: Thu Dec 30 13:00:19 2010 New Revision: 12035 URL: http://svn.gna.org/viewcvs/relax?rev=12035&view=rev Log: Added the sequence.read user function window and menu entries. Added: branches/bieri_gui/gui_bieri/user_functions/sequence.py - copied, changed from r12018, branches/bieri_gui/gui_bieri/user_functions/spin.py Modified: branches/bieri_gui/gui_bieri/menu.py branches/bieri_gui/gui_bieri/user_functions/__init__.py Modified: branches/bieri_gui/gui_bieri/menu.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/menu.py?rev=12035&r1=12034&r2=12035&view=diff ============================================================================== --- branches/bieri_gui/gui_bieri/menu.py (original) +++ branches/bieri_gui/gui_bieri/menu.py Thu Dec 30 13:00:19 2010 @@ -205,7 +205,10 @@ [wx.NewId(), "&create", paths.icon_16x16.add, self.gui.user_functions.residue.create], [wx.NewId(), "&delete", paths.icon_16x16.remove, self.gui.user_functions.residue.delete] ]], - [wx.NewId(), "&script", paths.icon_16x16.uf_script, self.gui.user_functions.script.run, []], + [wx.NewId(), "s&cript", paths.icon_16x16.uf_script, self.gui.user_functions.script.run, []], + [wx.NewId(), "se&quence", paths.icon_16x16.sequence, None, [ + [wx.NewId(), "&read", paths.icon_16x16.open, self.gui.user_functions.sequence.read] + ]], [wx.NewId(), "&spin", paths.icon_16x16.spin, None, [ [wx.NewId(), "&create", paths.icon_16x16.add, self.gui.user_functions.spin.create], [wx.NewId(), "&delete", paths.icon_16x16.remove, self.gui.user_functions.spin.delete] Modified: branches/bieri_gui/gui_bieri/user_functions/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/user_functions/__init__.py?rev=12035&r1=12034&r2=12035&view=diff ============================================================================== --- branches/bieri_gui/gui_bieri/user_functions/__init__.py (original) +++ branches/bieri_gui/gui_bieri/user_functions/__init__.py Thu Dec 30 13:00:19 2010 @@ -31,6 +31,7 @@ from pipes import Pipes from residue import Residue from script import Script +from sequence import Sequence from spin import Spin @@ -40,6 +41,7 @@ 'pipes', 'residue', 'script', + 'sequence', 'spin'] @@ -62,6 +64,7 @@ self.pipes = Pipes(self.gui, self.interpreter) self.residue = Residue(self.gui, self.interpreter) self.script = Script(self.gui, self.interpreter) + self.sequence = Sequence(self.gui, self.interpreter) self.spin = Spin(self.gui, self.interpreter) @@ -72,4 +75,5 @@ self.molecule.destroy() self.pipes.destroy() self.residue.destroy() + self.sequence.destroy() self.spin.destroy() Copied: branches/bieri_gui/gui_bieri/user_functions/sequence.py (from r12018, branches/bieri_gui/gui_bieri/user_functions/spin.py) URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/user_functions/sequence.py?p2=branches/bieri_gui/gui_bieri/user_functions/sequence.py&p1=branches/bieri_gui/gui_bieri/user_functions/spin.py&r1=12018&r2=12035&rev=12035&view=diff ============================================================================== --- branches/bieri_gui/gui_bieri/user_functions/spin.py (original) +++ branches/bieri_gui/gui_bieri/user_functions/sequence.py Thu Dec 30 13:00:19 2010 @@ -21,235 +21,97 @@ ############################################################################### # Module docstring. -"""The spin user function GUI elements.""" +"""The sequence user function GUI elements.""" # Python module imports. from string import split import wx # relax module imports. -from generic_fns.mol_res_spin import molecule_loop, residue_loop, spin_loop from generic_fns import pipes # GUI module imports. from base import UF_base, UF_window from gui_bieri.paths import WIZARD_IMAGE_PATH -from gui_bieri.user_functions.mol_res_spin import Mol_res_spin +from gui_bieri.misc import gui_to_int, gui_to_str # The container class. -class Spin(UF_base): +class Sequence(UF_base): """The container class for holding all GUI elements.""" - def create(self, event, mol_name=None, res_num=None, res_name=None): - """The spin.create user function. + def read(self, event): + """The sequence.delete user function. @param event: The wx event. @type event: wx event - @param mol_name: The starting molecule name. - @type mol_name: str - @param res_num: The starting residue number. - @type res_num: str - @param res_name: The starting residue name. - @type res_name: str """ # Initialise the dialog. - self._create_window = Create_window(self.gui, self.interpreter) + self._read_window = Read_window(self.gui, self.interpreter) # Show the dialog. - self._create_window.ShowModal() - - # Default molecule name. - if mol_name: - self._create_window.mol.SetValue(mol_name) - - # Default residue. - if res_num or res_name: - self._create_window.res.SetValue("%s %s" % (res_num, res_name)) + self._read_window.ShowModal() # Destroy. - self._create_window.Destroy() - - - def delete(self, event, mol_name=None, res_num=None, res_name=None, spin_num=None, spin_name=None): - """The spin.delete user function. - - @param event: The wx event. - @type event: wx event - @param mol_name: The starting molecule name. - @type mol_name: str - @param res_num: The starting residue number. - @type res_num: str - @param res_name: The starting residue name. - @type res_name: str - @param spin_num: The starting spin number. - @type spin_num: str - @param spin_name: The starting spin name. - @type spin_name: str - """ - - # Initialise the dialog. - self._delete_window = Delete_window(self.gui, self.interpreter) - - # Show the dialog. - self._delete_window.ShowModal() - - # Default molecule name. - if mol_name: - self._delete_window.mol.SetValue(mol_name) - - # Default residue. - if res_num or res_name: - self._delete_window.res.SetValue("%s %s" % (res_num, res_name)) - - # Default spin. - if spin_num or spin_name: - self._delete_window.spin.SetValue("%s %s" % (spin_num, spin_name)) - - # Destroy. - self._delete_window.Destroy() + self._read_window.Destroy() -class Create_window(UF_window, Mol_res_spin): - """The spin.create() user function window.""" +class Read_window(UF_window): + """The sequence.delete() user function window.""" # Some class variables. - size_x = 600 - size_y = 400 - frame_title = 'Add a spin' - image_path = WIZARD_IMAGE_PATH + 'spin.png' - main_text = 'This dialog allows you to add new spins to the relax data store. The spin will be added to the current data pipe.' - title = 'Addition of new spins' + size_x = 800 + size_y = 600 + frame_title = 'Read the spin sequence from a file' + image_path = WIZARD_IMAGE_PATH + 'sequence.png' + main_text = 'This dialog allows you to read the molecule, residue, and spin information from a file.' + title = 'Sequence reading' + def add_uf(self, sizer): - """Add the spin specific GUI elements. + """Add the sequence specific GUI elements. @param sizer: A sizer object. @type sizer: wx.Sizer instance """ - # Molecule and residue selections. - self.mol = self.combo_box(sizer, "The molecule:", [], self._update_residues) - self.res = self.combo_box(sizer, "The residue:", []) + # Add a file selection. + self.file = self.file_selection(sizer, "The sequence file:") - # The spin name input. - self.spin_name = self.input_field(sizer, "The name of the spin:") + # The parameter file settings. + self.spin_id_col, self.mol_name_col, self.res_num_col, self.res_name_col, self.spin_num_col, self.spin_name_col, self.sep = self.free_file_format(sizer) - # The type selection. - self.spin_num = self.input_field(sizer, "The spin number:") + # The spin ID restriction. + self.spin_id = self.input_field(sizer, "Restrict data loading to certain spins:", tooltip="This must be a valid spin ID. Multiple spins can be selected using ranges, the '|' operator, residue ranges, etc.") def execute(self): """Execute the user function.""" - # Get the molecule info. - mol_name = str(self.mol.GetValue()) - if mol_name == '': - mol_name = None + # The file name. + file = gui_to_str(self.file.GetValue()) - # The residue info. - res_num, res_name = self._get_res_info() - - # The spin number. - spin_num = str(self.spin_num.GetValue()) - if spin_num == '': - spin_num = None - else: - spin_num = int(spin_num) - - # The spin name. - spin_name = str(self.spin_name.GetValue()) - if spin_num == '': - spin_num = None - - # Set the name. - self.interpreter.spin.create(spin_name=spin_name, spin_num=spin_num, res_name=res_name, res_num=res_num, mol_name=mol_name) - - - def update(self, event): - """Update the UI. - - @param event: The wx event. - @type event: wx event - """ - - # Clear the previous data. - self.mol.Clear() - self.res.Clear() - - # Clear the text. - self.mol.SetValue('') - self.res.SetValue('') - - # The list of molecule names. - if pipes.cdp_name(): - for mol in molecule_loop(): - self.mol.Append(mol.name) - - - -class Delete_window(UF_window, Mol_res_spin): - """The spin.delete() user function window.""" - - # Some class variables. - size_x = 600 - size_y = 400 - frame_title = 'Delete a spin' - image_path = WIZARD_IMAGE_PATH + 'spin.png' - main_text = 'This dialog allows you to delete spins from the relax data store. The spin will be deleted from the current data pipe.' - title = 'Spin deletion' - - - def add_uf(self, sizer): - """Add the spin specific GUI elements. - - @param sizer: A sizer object. - @type sizer: wx.Sizer instance - """ - - # Molecule, residue and spin selections. - self.mol = self.combo_box(sizer, "The molecule:", [], self._update_residues) - self.res = self.combo_box(sizer, "The residue:", [], self._update_spins) - self.spin = self.combo_box(sizer, "The spin:", []) - - - def execute(self): - """Execute the user function.""" - - # Get the spin ID. - id = self._get_spin_id() - - # Nothing to do. - if not id: + # No file. + if not file: return - # Delete the spin. - self.interpreter.spin.delete(spin_id=id) + # 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()) - # Update the spin list. - self._update_spins(None) + # 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()) - def update(self, event): - """Update the UI. - - @param event: The wx event. - @type event: wx event - """ - - # Clear the previous data. - self.mol.Clear() - self.res.Clear() - self.spin.Clear() - - # Clear the text. - self.mol.SetValue('') - self.res.SetValue('') - self.spin.SetValue('') - - # The list of molecule names. - if pipes.cdp_name(): - for mol in molecule_loop(): - self.mol.Append(mol.name) + # Read the sequence. + self.interpreter.sequence.read(file=file, dir=dir, 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, sep=sep, spin_id=spin_id)