mailr5868 - /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 - 19:48:
Author: bugman
Date: Sun Apr 20 19:48:10 2008
New Revision: 5868

URL: http://svn.gna.org/viewcvs/relax?rev=5868&view=rev
Log:
Created the Selection.contains_mol() method.

This is for testing if a molecule name, in string form, is contained in the 
selection object.


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=5868&r1=5867&r2=5868&view=diff
==============================================================================
--- 1.3/generic_fns/selection.py (original)
+++ 1.3/generic_fns/selection.py Sun Apr 20 19:48:10 2008
@@ -264,6 +264,29 @@
             warn(RelaxWarning("The spin identification string " + `spin_id` 
+ " is too complex for the selection object."))
 
 
+    def contains_mol(self, mol):
+        """Determine if the molecule name, in string form, is contained in 
this selection object.
+
+        @param molecule:    The name of the molecule.
+        @type molecule:     str or None
+        @return:            The answer of whether the molecule is contained 
withing the selection
+                            object.
+        @rtype:             bool
+        """
+
+        # The selection object is a union.
+        if self._union:
+            return self._union[0].cotains_mol(mol) or 
self._union[1].contains_mol(mol)
+
+        # The selection object is an intersection.
+        elif self._intersect:
+            return self._intersect[0].cotains_mol(mol) and 
self._intersect[1].contains_mol(mol)
+
+        # The check.
+        if mol in self.molecules:
+            return True
+
+
     def intersection(self, select_obj0, select_obj1):
         """Make this Selection object the intersection of two other 
Selection objects.
 




Related Messages


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