mailr5472 - /1.3/data/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 April 09, 2008 - 10:49:
Author: bugman
Date: Wed Apr  9 10:49:36 2008
New Revision: 5472

URL: http://svn.gna.org/viewcvs/relax?rev=5472&view=rev
Log:
Created the SpinContainer.is_empty() method.

The molecule, residue, spin object stack in the relax data store is being 
modified, expect massive
breakages until this is resolved!


Modified:
    1.3/data/mol_res_spin.py

Modified: 1.3/data/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/data/mol_res_spin.py?rev=5472&r1=5471&r2=5472&view=diff
==============================================================================
--- 1.3/data/mol_res_spin.py (original)
+++ 1.3/data/mol_res_spin.py Wed Apr  9 10:49:36 2008
@@ -76,6 +76,39 @@
         return text
 
 
+    def is_empty(self):
+        """Method for testing if this SpinContainer object is empty.
+
+        @return:    True if this container is empty and the spin number and 
name have not been set,
+                    False otherwise.
+        @rtype:     bool
+        """
+
+        # The spin number or spin name has been set.
+        if self.num != None or self.name != None:
+            return False
+
+        # An object has been added to the container.
+        for name in dir(self):
+            # Skip the objects initialised in __init__().
+            if name == 'num' or name == 'name' or name == 'select':
+                continue
+
+            # Skip the SpinContainer methods.
+            if name == 'is_empty':
+                continue
+
+            # Skip special objects.
+            if match("^__", name):
+                continue
+
+            # An object has been added.
+            return False
+
+        # The SpinContainer is unmodified.
+        return True
+
+
 class SpinList(list):
     """List type data container for spin system specific data."""
 
@@ -114,7 +147,7 @@
                 raise RelaxError, "The spin number '" + `spin_num` + "' 
already exists."
 
         # If no spin data exists, replace the empty first spin with this 
spin.
-        if self[0].num == None and self[0].name == None and len(self) == 1:
+        if len(self) == 1 and self[0].is_empty():
             self[0].num = spin_num
             self[0].name = spin_name
             self[0].select = select




Related Messages


Powered by MHonArc, Updated Wed Apr 09 11:00:26 2008