mailr5850 - /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 April 20, 2008 - 17:53:
Author: bugman
Date: Sun Apr 20 17:53:45 2008
New Revision: 5850

URL: http://svn.gna.org/viewcvs/relax?rev=5850&view=rev
Log:
Split up the Selection.__contains__() method to allow for string comparisons 
as well.

The MoleculeContainer, ResidueContainer, and/or SpinContainer comparison has 
been shifted to the
method Selection.__contains_mol_res_spin_containers().


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=5850&r1=5849&r2=5850&view=diff
==============================================================================
--- 1.3/generic_fns/selection.py (original)
+++ 1.3/generic_fns/selection.py Sun Apr 20 17:53:45 2008
@@ -125,6 +125,26 @@
         elif self._intersect:
             return (obj in self._intersect[0]) and (obj in 
self._intersect[1])
 
+        # Simple spin identification string.
+        if type(obj) == str:
+            return self.__contains_spin_id(obj)
+
+        # Comparison of data containers to this selection object.
+        else:
+            return self.__contains_mol_res_spin_containers(obj)
+
+
+    def __contains_mol_res_spin_containers(self, obj):
+        """Are the MoleculeContainer, ResidueContainer, and/or SpinContainer 
in the selection.
+
+        @param obj:     The data object.  This can be a MoleculeContainer, 
ResidueContainer, or
+                        SpinContainer instance or a type of these instances. 
 If a tuple, only one
+                        type of object can be in the tuple.
+        @type obj:      instance or type of instances.
+        @return:        The answer of whether the objects are found within 
the selection object.
+        @rtype:         bool
+        """
+
         # Initialise the molecule, residue, and spin objects.
         mol = None
         res = None
@@ -166,6 +186,10 @@
 
                 # Unpack.
                 spin = obj[i]
+
+            # Unknown object (so return False).
+            else:
+                return False
 
         # Selection flags.
         select_mol = False




Related Messages


Powered by MHonArc, Updated Sun Apr 20 18:20:15 2008