mailr3223 - /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 March 19, 2007 - 06:21:
Author: bugman
Date: Mon Mar 19 06:20:44 2007
New Revision: 3223

URL: http://svn.gna.org/viewcvs/relax?rev=3223&view=rev
Log:
Wrote the molecule_loop() generator function for looping over and returning 
molecule containers.

The full generator function is generic_fns.selection.molecule_loop().

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=3223&r1=3222&r2=3223&view=diff
==============================================================================
--- 1.3/generic_fns/selection.py (original)
+++ 1.3/generic_fns/selection.py Mon Mar 19 06:20:44 2007
@@ -26,7 +26,7 @@
 
 # relax module imports.
 from data import Data as relax_data_store
-from relax_errors import RelaxError, RelaxNoRunError, RelaxNoSequenceError, 
RelaxRegExpError
+from relax_errors import RelaxError, RelaxNoRunError, RelaxNoSequenceError, 
RelaxRegExpError, RelaxResSelectDisallowError, RelaxSpinSelectDisallowError
 
 
 
@@ -181,7 +181,33 @@
 
 
 def molecule_loop(selection):
+    """Generator function for looping over all the molecules of the given 
selection.
+
+    @param selection:   The molecule selection identifier.
+    @type selection:    str
+    @return:            The molecule specific data container.
+    @rtype:             instance of the MoleculeContainer class.
+    """
+
+    # Split up the selection string.
+    mol_token, res_token, spin_token = tokenise(selection)
+
+    # Disallowed selections.
+    if res_token:
+        raise RelaxResSelectDisallowError
+    if spin_token:
+        raise RelaxSpinSelectDisallowError
+
+    # Parse the token.
+    molecules = parse_token(mol_token)
+
+    # Loop over the molecules.
     for mol in relax_data_store[relax_data_store.current_pipe].mol:
+        # Skip the molecule if there is no match to the selection.
+        if mol_token and mol.name not in molecules:
+            continue
+
+        # Yield the molecule data container.
         yield mol
 
 




Related Messages


Powered by MHonArc, Updated Mon Mar 19 06:40:17 2007