mailr11794 - in /branches/bieri_gui/gui_bieri/user_functions: molecule.py residue.py spin.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on December 13, 2010 - 23:45:
Author: bugman
Date: Mon Dec 13 23:45:59 2010
New Revision: 11794

URL: http://svn.gna.org/viewcvs/relax?rev=11794&view=rev
Log:
The molecule, residue, and spin user functions have been standardised on the 
Mol_res_spin base class.


Modified:
    branches/bieri_gui/gui_bieri/user_functions/molecule.py
    branches/bieri_gui/gui_bieri/user_functions/residue.py
    branches/bieri_gui/gui_bieri/user_functions/spin.py

Modified: branches/bieri_gui/gui_bieri/user_functions/molecule.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/user_functions/molecule.py?rev=11794&r1=11793&r2=11794&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/user_functions/molecule.py (original)
+++ branches/bieri_gui/gui_bieri/user_functions/molecule.py Mon Dec 13 
23:45:59 2010
@@ -27,7 +27,7 @@
 import wx
 
 # relax module imports.
-from generic_fns.mol_res_spin import ALLOWED_MOL_TYPES, molecule_loop
+from generic_fns.mol_res_spin import ALLOWED_MOL_TYPES, generate_spin_id, 
molecule_loop
 from generic_fns import pipes
 
 # GUI module imports.
@@ -57,14 +57,21 @@
         self._create_window.Show()
 
 
-    def delete(self, event):
+    def delete(self, event, mol_name=None):
         """The molecule.delete user function.
 
         @param event:   The wx event.
         @type event:    wx event
+        @param mol_name:    The starting molecule name.
+        @type mol_name:     str
         """
 
+        # Show the dialog.
         self._delete_window.Show()
+
+        # Default molecule name.
+        if mol_name:
+            self._delete_window.mol.SetValue(mol_name)
 
 
     def destroy(self):
@@ -95,7 +102,7 @@
         """
 
         # The molecule name input.
-        self.mol_name = self.input_field(sizer, "The name of the molecule:")
+        self.mol = self.input_field(sizer, "The name of the molecule:")
 
         # The type selection.
         self.mol_type = self.combo_box(sizer, "The type of molecule:", [''] 
+ ALLOWED_MOL_TYPES)
@@ -105,7 +112,7 @@
         """Execute the user function."""
 
         # Get the name and type.
-        mol_name = str(self.mol_name.GetValue())
+        mol_name = str(self.mol.GetValue())
         mol_type = str(self.mol_type.GetValue())
 
         # Set the name.
@@ -133,17 +140,17 @@
         """
 
         # The molecule selection.
-        self.mol_name = self.combo_box(sizer, "The molecule:", [])
+        self.mol = self.combo_box(sizer, "The molecule:", [])
 
 
     def execute(self):
         """Execute the user function."""
 
         # Get the name.
-        mol_name = str(self.mol_name.GetValue())
+        mol_name = str(self.mol.GetValue())
 
         # The molecule ID.
-        id = '#' + mol_name
+        id = generate_spin_id(mol_name=mol_name)
 
         # Delete the molecule.
         self.interpreter.molecule.delete(mol_id=id)
@@ -160,12 +167,12 @@
         """
 
         # Clear the previous data.
-        self.mol_name.Clear()
+        self.mol.Clear()
 
         # Clear the molecule name.
-        self.mol_name.SetValue('')
+        self.mol.SetValue('')
 
         # The list of molecule names.
         if pipes.cdp_name():
             for mol in molecule_loop():
-                self.mol_name.Append(mol.name)
+                self.mol.Append(mol.name)

Modified: branches/bieri_gui/gui_bieri/user_functions/residue.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/user_functions/residue.py?rev=11794&r1=11793&r2=11794&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/user_functions/residue.py (original)
+++ branches/bieri_gui/gui_bieri/user_functions/residue.py Mon Dec 13 
23:45:59 2010
@@ -28,12 +28,13 @@
 import wx
 
 # relax module imports.
-from generic_fns.mol_res_spin import molecule_loop, residue_loop
+from generic_fns.mol_res_spin import generate_spin_id, molecule_loop, 
residue_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
 
 
 # The container class.
@@ -44,28 +45,50 @@
         """Place all the GUI classes into this class for storage."""
 
         # The dialogs.
-        self._create_window = Add_window(self.gui, self.interpreter)
+        self._create_window = Create_window(self.gui, self.interpreter)
         self._delete_window = Delete_window(self.gui, self.interpreter)
 
 
-    def create(self, event):
+    def create(self, event, mol_name=None):
         """The residue.create user function.
 
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
+        @param event:       The wx event.
+        @type event:        wx event
+        @param mol_name:    The starting molecule name.
+        @type mol_name:     str
+        """
+
+        # Show the dialog.
         self._create_window.Show()
 
-
-    def delete(self, event):
+        # Default molecule name.
+        if mol_name:
+            self._create_window.mol.SetValue(mol_name)
+
+
+    def delete(self, event, mol_name=None, res_num=None, res_name=None):
         """The residue.delete user function.
 
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
+        @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
+        """
+
+        # Show the dialog.
         self._delete_window.Show()
+
+        # 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))
 
 
     def destroy(self):
@@ -76,7 +99,7 @@
 
 
 
-class Add_window(UF_window):
+class Create_window(UF_window, Mol_res_spin):
     """The residue.create() user function window."""
 
     # Some class variables.
@@ -149,7 +172,7 @@
 
 
 
-class Delete_window(UF_window):
+class Delete_window(UF_window, Mol_res_spin):
     """The residue.delete() user function window."""
 
     # Some class variables.
@@ -160,7 +183,6 @@
     main_text = 'This dialog allows you to delete residues from the relax 
data store.  The residue will be deleted from the current data pipe.'
     title = 'Residue deletion'
 
-
     def add_uf(self, sizer):
         """Add the residue specific GUI elements.
 
@@ -169,23 +191,25 @@
         """
 
         # The residue selection.
-        self.res_name = self.combo_box(sizer, "The residue:", [])
+        self.mol = self.combo_box(sizer, "The molecule:", [], 
self._update_residues)
+        self.res = self.combo_box(sizer, "The residue:", [])
 
 
     def execute(self):
         """Execute the user function."""
 
-        # Get the name.
-        res_name = str(self.res_name.GetValue())
-
         # The residue ID.
-        id = ':' + res_name
+        id = self._get_res_id()
+
+        # Nothing to do.
+        if not id:
+            return
 
         # Delete the residue.
         self.interpreter.residue.delete(res_id=id)
 
         # Update.
-        self.update(None)
+        self._update_residues(None)
 
 
     def update(self, event):
@@ -196,12 +220,14 @@
         """
 
         # Clear the previous data.
-        self.res_name.Clear()
-
-        # Clear the residue name.
-        self.res_name.SetValue('')
-
-        # The list of residue names.
+        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 res in res_loop():
-                self.res_name.Append(res.name)
+            for mol in molecule_loop():
+                self.mol.Append(mol.name)

Modified: branches/bieri_gui/gui_bieri/user_functions/spin.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/user_functions/spin.py?rev=11794&r1=11793&r2=11794&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/user_functions/spin.py (original)
+++ branches/bieri_gui/gui_bieri/user_functions/spin.py Mon Dec 13 23:45:59 
2010
@@ -34,6 +34,7 @@
 # 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
 
 
 # The container class.
@@ -44,28 +45,66 @@
         """Place all the GUI classes into this class for storage."""
 
         # The dialogs.
-        self._create_window = Add_window(self.gui, self.interpreter)
+        self._create_window = Create_window(self.gui, self.interpreter)
         self._delete_window = Delete_window(self.gui, self.interpreter)
 
 
-    def create(self, event):
+    def create(self, event, mol_name=None, res_num=None, res_name=None):
         """The spin.create user function.
 
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
+        @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
+        """
+
+        # Show the dialog.
         self._create_window.Show()
 
-
-    def delete(self, event):
+        # 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))
+
+
+    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 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
+        """
+
+        # Show the dialog.
         self._delete_window.Show()
+
+        # 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))
 
 
     def destroy(self):
@@ -76,7 +115,7 @@
 
 
 
-class Add_window(UF_window):
+class Create_window(UF_window, Mol_res_spin):
     """The spin.create() user function window."""
 
     # Some class variables.
@@ -87,26 +126,6 @@
     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'
 
-
-    def _update_residues(self, event):
-        """Update the residue combo box.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Clear the previous data.
-        self.res.Clear()
-
-        # Clear the text.
-        self.res.SetValue('')
-
-        # The list of residue names.
-        mol_id = '#' + str(self.mol.GetValue())
-        for res in residue_loop(mol_id):
-            self.res.Append("%s %s" % (res.num, res.name))
-
-
     def add_uf(self, sizer):
         """Add the spin specific GUI elements.
 
@@ -128,20 +147,13 @@
     def execute(self):
         """Execute the user function."""
 
-        # Get the spin info.
+        # Get the molecule info.
         mol_name = str(self.mol.GetValue())
         if mol_name == '':
             mol_name = None
 
         # The residue info.
-        res = str(self.res.GetValue())
-        res_num, res_name = split(res)
-        if res_name == '':
-            res_name = None
-        if res_num == '':
-            res_num = None
-        else:
-            res_num = int(res_num)
+        res_num, res_name = self._get_res_info()
 
         # The spin number.
         spin_num = str(self.spin_num.GetValue())
@@ -181,7 +193,7 @@
 
 
 
-class Delete_window(UF_window):
+class Delete_window(UF_window, Mol_res_spin):
     """The spin.delete() user function window."""
 
     # Some class variables.
@@ -200,24 +212,27 @@
         @type sizer:    wx.Sizer instance
         """
 
-        # The spin selection.
-        self.spin_name = self.combo_box(sizer, "The spin:", [])
+        # 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 name.
-        spin_name = str(self.spin_name.GetValue())
-
-        # The spin ID.
-        id = '@' + spin_name
+        # Get the spin ID.
+        id = self._get_spin_id()
+
+        # Nothing to do.
+        if not id:
+            return
 
         # Delete the spin.
         self.interpreter.spin.delete(spin_id=id)
 
-        # Update.
-        self.update(None)
+        # Update the spin list.
+        self._update_spins(None)
 
 
     def update(self, event):
@@ -228,12 +243,16 @@
         """
 
         # Clear the previous data.
-        self.spin_name.Clear()
-
-        # Clear the spin name.
-        self.spin_name.SetValue('')
-
-        # The list of spin names.
+        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 spin in spin_loop():
-                self.spin_name.Append(spin.name)
+            for mol in molecule_loop():
+                self.mol.Append(mol.name)




Related Messages


Powered by MHonArc, Updated Tue Dec 14 00:00:02 2010