mailr19403 - /trunk/pipe_control/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 08, 2013 - 16:46:
Author: bugman
Date: Mon Apr  8 16:46:14 2013
New Revision: 19403

URL: http://svn.gna.org/viewcvs/relax?rev=19403&view=rev
Log:
Created the pipe_control.mol_res_spin.count_max_spins_per_residue() function.

This will be used by the plotting module to determine if more than one spin 
per residue exists.


Modified:
    trunk/pipe_control/mol_res_spin.py

Modified: trunk/pipe_control/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/mol_res_spin.py?rev=19403&r1=19402&r2=19403&view=diff
==============================================================================
--- trunk/pipe_control/mol_res_spin.py (original)
+++ trunk/pipe_control/mol_res_spin.py Mon Apr  8 16:46:14 2013
@@ -415,6 +415,54 @@
     # Release the lock.
     finally:
         status.spin_lock.release(sys._getframe().f_code.co_name)
+
+
+def count_max_spins_per_residue(pipe=None, skip_desel=True):
+    """Determine the maximum number of spins present per residue.
+
+    @keyword pipe:          The data pipe containing the spin.  Defaults to 
the current data pipe.
+    @type pipe:             str
+    @keyword skip_desel:    A flag which if true will cause deselected spins 
to be skipped in the count.
+    @type skip_desel:       bool
+    @return:                The number of non-empty spins.
+    @rtype:                 int
+    """
+
+    # The data pipe.
+    if pipe == None:
+        pipe = pipes.cdp_name()
+
+    # Test the data pipe.
+    pipes.test(pipe)
+
+    # No data, hence no spins.
+    if not exists_mol_res_spin_data(pipe=pipe):
+        return 0
+
+    # Init.
+    max_num = 0
+
+    # Loop over the molecules.
+    for mol in dp.mol:
+        # Loop over the residues.
+        for res in mol.res:
+            # Initialise the counter.
+            spin_num = 0
+
+            # Loop over the spins.
+            for spin in res.spin:
+                # Skip deselected spins.
+                if skip_desel and not spin.select:
+                    continue
+
+                # Increment the spin number.
+                spin_num = spin_num + 1
+
+            # The maximum number.
+            max_num = max(max_num, spin_num)
+
+    # Return the maximum number of spins.
+    return spin_num
 
 
 def count_molecules(selection=None, pipe=None):




Related Messages


Powered by MHonArc, Updated Mon Apr 08 17:00:02 2013