mailr16916 - in /trunk: generic_fns/mol_res_spin.py test_suite/unit_tests/_generic_fns/test_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 June 14, 2012 - 17:38:
Author: bugman
Date: Thu Jun 14 17:38:57 2012
New Revision: 16916

URL: http://svn.gna.org/viewcvs/relax?rev=16916&view=rev
Log:
Renamed return_spin_from_id() to return_spin(), and return_spin() to 
return_spin_from_selection().

This shaves off a number of seconds from the system test - the look up table 
speed ups will come
with support in the other mol_res_spin module functions.


Modified:
    trunk/generic_fns/mol_res_spin.py
    trunk/test_suite/unit_tests/_generic_fns/test_mol_res_spin.py

Modified: trunk/generic_fns/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/generic_fns/mol_res_spin.py?rev=16916&r1=16915&r2=16916&view=diff
==============================================================================
--- trunk/generic_fns/mol_res_spin.py (original)
+++ trunk/generic_fns/mol_res_spin.py Thu Jun 14 17:38:57 2012
@@ -2363,7 +2363,41 @@
         return res_container
 
 
-def return_spin(selection=None, pipe=None, full_info=False):
+def return_spin(spin_id=None, pipe=None, full_info=False):
+    """Return the spin data container corresponding to the given spin ID 
string.
+
+    @keyword spin_id:   The unique spin ID string.
+    @type spin_id:      str
+    @param pipe:        The data pipe containing the spin.  Defaults to the 
current data pipe.
+    @type pipe:         str
+    @param full_info:   A flag specifying if the amount of information to be 
returned.  If false, only the data container is returned.  If true, the 
molecule name, residue number, and residue name is additionally returned.
+    @type full_info:    boolean
+    @return:            The spin system specific data container and, if 
full_info=True, the molecule name, residue number, and residue name.
+    @rtype:             SpinContainer instance or tuple of (str, int, str, 
SpinContainer instance)
+    """
+
+    # The data pipe.
+    if pipe == None:
+        pipe = pipes.cdp_name()
+
+    # Get the data pipe.
+    dp = pipes.get_pipe(pipe)
+
+    # No spin ID, so switch to selection matching.
+    if not dp.mol.lookup_table.has_key(spin_id):
+        return return_spin_from_selection(selection=spin_id, pipe=pipe, 
full_info=full_info)
+
+    # The indices from the look up table.
+    mol_index, res_index, spin_index = dp.mol.lookup_table[spin_id]
+
+    # Return the data.
+    if full_info:
+        return dp.mol[mol_index].name, dp.mol[mol_index].res[res_index].num, 
dp.mol[mol_index].res[res_index].name, 
dp.mol[mol_index].res[res_index].spin[spin_index]
+    else:
+        return dp.mol[mol_index].res[res_index].spin[spin_index]
+
+
+def return_spin_from_selection(selection=None, pipe=None, full_info=False):
     """Function for returning the spin data container of the given selection.
 
     If more than one selection is given, then the boolean AND operation will 
be used to pull out the spin.
@@ -2430,41 +2464,6 @@
         return mol_container.name, res_container.num, res_container.name, 
spin_container
     else:
         return spin_container
-
-
-def return_spin_from_id(spin_id=None, pipe=None, full_info=False):
-    """Return the spin data container corresponding to the given spin ID 
string.
-
-    @keyword spin_id:   The unique spin ID string.
-    @type spin_id:      str
-    @param pipe:        The data pipe containing the spin.  Defaults to the 
current data pipe.
-    @type pipe:         str
-    @param full_info:   A flag specifying if the amount of information to be 
returned.  If false, only the data container is returned.  If true, the 
molecule name, residue number, and residue name is additionally returned.
-    @type full_info:    boolean
-    @return:            The spin system specific data container and, if 
full_info=True, the molecule name, residue number, and residue name.
-    @rtype:             SpinContainer instance or tuple of (str, int, str, 
SpinContainer instance)
-    """
-
-    # The data pipe.
-    if pipe == None:
-        pipe = pipes.cdp_name()
-
-    # Get the data pipe.
-    dp = pipes.get_pipe(pipe)
-
-    # No spin ID, so switch to selection matching.
-    if not dp.mol.lookup_table.has_key(spin_id):
-        return return_spin_from_selection(selection=spin_id, pipe=pipe, 
full_info=full_info)
-
-    # The indices from the look up table.
-    mol_index, res_index, spin_index = dp.mol.lookup_table[spin_id]
-
-    # Return the data.
-    if full_info:
-        return dp.mol[mol_index].name, dp.mol[mol_index].res[res_index].num, 
dp.mol[mol_index].res[res_index].name, 
dp.mol[mol_index].res[res_index].spin[spin_index]
-    else:
-        return dp.mol[mol_index].res[res_index].spin[spin_index]
-
 
 
 def return_spin_from_index(global_index=None, pipe=None, 
return_spin_id=False):

Modified: trunk/test_suite/unit_tests/_generic_fns/test_mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/test_suite/unit_tests/_generic_fns/test_mol_res_spin.py?rev=16916&r1=16915&r2=16916&view=diff
==============================================================================
--- trunk/test_suite/unit_tests/_generic_fns/test_mol_res_spin.py (original)
+++ trunk/test_suite/unit_tests/_generic_fns/test_mol_res_spin.py Thu Jun 14 
17:38:57 2012
@@ -1150,10 +1150,10 @@
 
         # Ask for a few spins.
         spin1 = mol_res_spin.return_spin(':1')
-        spin2 = mol_res_spin.return_spin(selection=':2')
-        spin3 = mol_res_spin.return_spin(selection=':4', pipe='orig')
-        spin4 = mol_res_spin.return_spin(selection='#RNA:-5@N5', pipe='orig')
-        spin5 = mol_res_spin.return_spin(selection=':-4@2H', pipe='orig')
+        spin2 = mol_res_spin.return_spin(spin_id=':2')
+        spin3 = mol_res_spin.return_spin(spin_id=':4', pipe='orig')
+        spin4 = mol_res_spin.return_spin(spin_id='#RNA:-5@N5', pipe='orig')
+        spin5 = mol_res_spin.return_spin(spin_id=':-4@2H', pipe='orig')
 
         # Test the data of spin 1.
         self.assertNotEqual(spin1, None)
@@ -1188,7 +1188,7 @@
         """
 
         # Try to get a spin from a missing data pipe.
-        self.assertRaises(RelaxNoPipeError, mol_res_spin.return_spin, 
selection=':2', pipe='new')
+        self.assertRaises(RelaxNoPipeError, mol_res_spin.return_spin, 
spin_id=':2', pipe='new')
 
 
     def test_spin_loop(self):




Related Messages


Powered by MHonArc, Updated Sun Jun 17 09:20:02 2012