mailr3473 - /1.3/generic_fns/selection.py


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

Header


Content

Posted by edward on November 11, 2007 - 12:37:
Author: bugman
Date: Sun Nov 11 12:37:50 2007
New Revision: 3473

URL: http://svn.gna.org/viewcvs/relax?rev=3473&view=rev
Log:
Added the function generic_fns.selection.return_single_spin_info().


Modified:
    1.3/generic_fns/selection.py

Modified: 1.3/generic_fns/selection.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/selection.py?rev=3473&r1=3472&r2=3473&view=diff
==============================================================================
--- 1.3/generic_fns/selection.py (original)
+++ 1.3/generic_fns/selection.py Sun Nov 11 12:37:50 2007
@@ -609,6 +609,40 @@
     return res_num, res_name
 
 
+def return_single_spin_info(spin_token):
+    """Return the single spin number and name corresponding to the spin 
token.
+
+    @param spin_token:  The spin identification string.
+    @type spin_token:   str
+    @return:            A tuple containing the spin number and the spin name.
+    @rtype:             (int, str)
+    """
+
+    # Parse the spin token for renaming and renumbering.
+    spin_info = parse_token(spin_token)
+
+    # Determine the spin number and name.
+    spin_num = None
+    spin_name = None
+    for info in spin_info:
+        # A spin name identifier.
+        if type(info) == str:
+            if spin_name == None:
+                spin_name = info
+            else:
+                raise RelaxError, "The spin identifier " + `spin_token` + " 
does not correspond to a single spin."
+
+        # A spin number identifier.
+        if type(info) == int:
+            if spin_num == None:
+                spin_num = info
+            else:
+                raise RelaxError, "The spin identifier " + `spin_token` + " 
does not correspond to a single spin."
+
+    # Return the spin number and name.
+    return spin_num, spin_name
+
+
 def reverse(selection=None):
     """Function for the reversal of the spin system selection."""
 




Related Messages


Powered by MHonArc, Updated Sun Nov 11 13:00:16 2007