mailr5140 - /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 22, 2008 - 18:17:
Author: bugman
Date: Sat Mar 22 18:17:32 2008
New Revision: 5140

URL: http://svn.gna.org/viewcvs/relax?rev=5140&view=rev
Log:
Created a new function count_selected_spins() for counting selected spins.


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=5140&r1=5139&r2=5140&view=diff
==============================================================================
--- 1.3/generic_fns/selection.py (original)
+++ 1.3/generic_fns/selection.py Sat Mar 22 18:17:32 2008
@@ -171,6 +171,35 @@
         self._union = (select_obj0, select_obj1)
 
 
+def count_selected_spins(selection=None):
+    """Function for counting the number of spins for which there is data and 
which are selected.
+
+    @param selection:   The selection string.
+    @type selection:    str
+    @return:            The number of non-empty selected spins.
+    @rtype:             int
+    """
+
+    # No data, hence no spins.
+    if not exists_mol_res_spin_data():
+        return 0
+
+    # Init.
+    spin_num = 0
+
+    # Spin loop.
+    for spin in spin_loop(selection):
+        # Skip deselected spins.
+        if not spin.select:
+            continue
+
+        # Increment the spin number.
+        spin_num = spin_num + 1
+
+    # Return the number of spins.
+    return spin_num
+
+
 def count_spins(selection=None):
     """Function for counting the number of spins for which there is data.
 




Related Messages


Powered by MHonArc, Updated Sat Mar 22 18:40:15 2008