mailr17163 - /branches/interatomic/generic_fns/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 July 03, 2012 - 20:21:
Author: bugman
Date: Tue Jul  3 20:21:21 2012
New Revision: 17163

URL: http://svn.gna.org/viewcvs/relax?rev=17163&view=rev
Log:
A number of the generic_fns.mol_res_spin functions now accept the pipe 
argument.

These include name_spin(), set_spin_element(), and set_spin_isotope() and 
this allows the functions
to operate on any data pipe.


Modified:
    branches/interatomic/generic_fns/mol_res_spin.py

Modified: branches/interatomic/generic_fns/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/interatomic/generic_fns/mol_res_spin.py?rev=17163&r1=17162&r2=17163&view=diff
==============================================================================
--- branches/interatomic/generic_fns/mol_res_spin.py (original)
+++ branches/interatomic/generic_fns/mol_res_spin.py Tue Jul  3 20:21:21 2012
@@ -2185,22 +2185,31 @@
         status.spin_lock.release(sys._getframe().f_code.co_name)
 
 
-def name_spin(spin_id=None, name=None, force=False):
+def name_spin(spin_id=None, name=None, pipe=None, force=False):
     """Name the spins.
 
     @keyword spin_id:   The spin identification string.
     @type spin_id:      str
     @keyword name:      The new spin name.
     @type name:         str
+    @param pipe:        The data pipe to operate on.  Defaults to the 
current data pipe.
+    @type pipe:         str
     @keyword force:     A flag which if True will cause the named spin to be 
renamed.
     @type force:        bool
     """
+
+    # The data pipe.
+    if pipe == None:
+        pipe = pipes.cdp_name()
+
+    # Test the data pipe.
+    pipes.test(pipe)
 
     # Acquire the spin lock (data modifying function), and make sure it is 
finally released.
     status.spin_lock.acquire(sys._getframe().f_code.co_name)
     try:
         # Rename the matching spins.
-        for spin, id in spin_loop(spin_id, return_id=True):
+        for spin, id in spin_loop(spin_id, pipe=pipe, return_id=True):
             if spin.name and not force:
                 warn(RelaxWarning("The spin '%s' is already named.  Set the 
force flag to rename." % id))
             else:
@@ -2990,13 +2999,15 @@
     return True
 
 
-def set_spin_element(spin_id=None, element=None, force=False):
+def set_spin_element(spin_id=None, element=None, pipe=None, force=False):
     """Set the element type of the spins.
 
     @keyword spin_id:   The spin identification string.
     @type spin_id:      str
     @keyword element:   The IUPAC element name.
     @type element:      str
+    @param pipe:        The data pipe to operate on.  Defaults to the 
current data pipe.
+    @type pipe:         str
     @keyword force:     A flag which if True will cause the element to be 
changed.
     @type force:        bool
     """
@@ -3016,21 +3027,30 @@
     if element not in valid_names:
         raise(RelaxError("The element name '%s' is not valid and should be 
one of the IUPAC names %s." % (element, valid_names)))
 
+    # The data pipe.
+    if pipe == None:
+        pipe = pipes.cdp_name()
+
+    # Test the data pipe.
+    pipes.test(pipe)
+
     # Set the element name for the matching spins.
-    for spin, id in spin_loop(spin_id, return_id=True):
+    for spin, id in spin_loop(spin_id, pipe=pipe, return_id=True):
         if hasattr(spin, 'element') and spin.element and not force:
             warn(RelaxWarning("The element type of the spin '%s' is already 
set.  Set the force flag to True to rename." % id))
         else:
             spin.element = element
 
 
-def set_spin_isotope(spin_id=None, isotope=None, force=False):
+def set_spin_isotope(spin_id=None, isotope=None, pipe=None, force=False):
     """Set the nuclear isotope type of the spins.
 
     @keyword spin_id:   The spin identification string.
     @type spin_id:      str
     @keyword isotope:   The nuclear isotope type.
     @type isotope:      str
+    @param pipe:        The data pipe to operate on.  Defaults to the 
current data pipe.
+    @type pipe:         str
     @keyword force:     A flag which if True will cause the isotope type to 
be changed.
     @type force:        bool
     """
@@ -3053,8 +3073,15 @@
     if isotope not in supported_types:
         raise(RelaxError("The nuclear isotope type '%s' is currently not 
supported." % isotope))
 
+    # The data pipe.
+    if pipe == None:
+        pipe = pipes.cdp_name()
+
+    # Test the data pipe.
+    pipes.test(pipe)
+
     # Set the isotope type for the matching spins.
-    for spin, id in spin_loop(spin_id, return_id=True):
+    for spin, id in spin_loop(spin_id, pipe=pipe, return_id=True):
         if hasattr(spin, 'isotope') and spin.isotope and not force:
             warn(RelaxWarning("The nuclear isotope type of the spin '%s' is 
already set.  Change the force flag to True to reset." % id))
         else:




Related Messages


Powered by MHonArc, Updated Tue Jul 03 20:40:02 2012