mailr12169 - /branches/bieri_gui/gui_bieri/user_functions/mol_res_spin.py


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

Header


Content

Posted by edward on January 05, 2011 - 17:06:
Author: bugman
Date: Wed Jan  5 17:06:09 2011
New Revision: 12169

URL: http://svn.gna.org/viewcvs/relax?rev=12169&view=rev
Log:
The _get_spin_id() and _get_spin_info() methods can now handle suffixes for 
the spin names.

This allows self.spin, self.spin_from, etc. to be used.


Modified:
    branches/bieri_gui/gui_bieri/user_functions/mol_res_spin.py

Modified: branches/bieri_gui/gui_bieri/user_functions/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/user_functions/mol_res_spin.py?rev=12169&r1=12168&r2=12169&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/user_functions/mol_res_spin.py (original)
+++ branches/bieri_gui/gui_bieri/user_functions/mol_res_spin.py Wed Jan  5 
17:06:09 2011
@@ -108,19 +108,26 @@
         return res_num, res_name
 
 
-    def _get_spin_id(self):
-        """Generate the spin ID from the molecule, residue, and spin 
selection."""
+    def _get_spin_id(self, suffix=''):
+        """Generate the spin ID from the molecule, residue, and spin 
selection.
+
+        @keyword suffix:    The suffix to be added to the spin data 
structure name.
+        @type suffix:       str
+        @return:            The spin ID string.
+        @rtype:             str
+        """
 
         # The molecule name.
-        mol_name = str(self.mol.GetValue())
+        obj = getattr(self, 'mol'+suffix)
+        mol_name = str(obj.GetValue())
         if mol_name == '':
             mol_name = None
 
         # The residue info.
-        res_num, res_name = self._get_res_info()
+        res_num, res_name = self._get_res_info(suffix=suffix)
 
         # The spin info.
-        spin_info = self._get_spin_info()
+        spin_info = self._get_spin_info(suffix=suffix)
         if not spin_info:
             return
         spin_num, spin_name = spin_info
@@ -129,30 +136,45 @@
         return generate_spin_id(mol_name=mol_name, res_num=res_num, 
res_name=res_name, spin_num=spin_num, spin_name=spin_name)
 
 
-    def _get_spin_info(self):
+    def _get_spin_info(self, suffix=''):
         """Extract the spin info from the spin selection.
 
-        @return:    The spin number and name from the spin selection 
self.spin.
-        @rtype:     int, str
-        """
-
-        # The spin info.
-        spin = str(self.spin.GetValue())
-
-        # Nothing.
-        if spin == '':
-            return
-
-        # Split.
-        spin_num, spin_name = split(spin)
-
-        # Convert.
-        if spin_name == '':
-            spin_name = None
-        if spin_num == '':
-            spin_num = None
+        @keyword suffix:    The suffix to be added to the spin data 
structure name.
+        @type suffix:       str
+        @return:            The spin number and name from the spin selection 
self.spin.
+        @rtype:             int, str
+        """
+
+        # Single spin object.
+        if hasattr(self, 'spin'+suffix):
+            # The spin info.
+            obj = getattr(self, 'spin'+suffix)
+            spin = str(obj.GetValue())
+
+            # Nothing.
+            if spin == '':
+                return
+
+            # Split.
+            spin_num, spin_name = split(spin)
+
+            # Convert.
+            if spin_name == '':
+                spin_name = None
+            if spin_num == '':
+                spin_num = None
+            else:
+                spin_num = int(spin_num)
+
+        # 2 objects.
         else:
-            spin_num = int(spin_num)
+            # The spin number.
+            obj = getattr(self, 'spin_num'+suffix)
+            spin_num = gui_to_int(obj.GetValue())
+
+            # The spin name.
+            obj = getattr(self, 'spin_name'+suffix)
+            spin_name = gui_to_str(obj.GetValue())
 
         # Return the number and name.
         return spin_num, spin_name




Related Messages


Powered by MHonArc, Updated Wed Jan 05 17:20:02 2011