mailr6634 - /1.3/generic_fns/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 July 03, 2008 - 22:44:
Author: bugman
Date: Thu Jul  3 22:41:58 2008
New Revision: 6634

URL: http://svn.gna.org/viewcvs/relax?rev=6634&view=rev
Log:
Created the new function convert_from_global_index().

This converts the global index into the molecule, residue, and spin indecies.


Modified:
    1.3/generic_fns/mol_res_spin.py

Modified: 1.3/generic_fns/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/mol_res_spin.py?rev=6634&r1=6633&r2=6634&view=diff
==============================================================================
--- 1.3/generic_fns/mol_res_spin.py (original)
+++ 1.3/generic_fns/mol_res_spin.py Thu Jul  3 22:41:58 2008
@@ -836,6 +836,35 @@
 
     # Add the spin.
     res_to_cont.spin.add_item(spin_num=spin_num, spin_name=spin_name)
+
+
+def convert_from_global_index(global_index=None, pipe=None):
+    """Convert the global index into the molecule, residue, and spin 
indecies.
+
+    @param global_index:        The global spin index, spanning the molecule 
and residue containers.
+    @type global_index:         int
+    @param pipe:                The data pipe containing the spin.  Defaults 
to the current data
+                                pipe.
+    @type pipe:                 str
+    @return:                    The corresponding molecule, residue, and 
spin indecies.
+    @rtype:                     tuple of int
+    """
+
+    # The data pipe.
+    if pipe == None:
+        pipe = ds.current_pipe
+
+    # Test the data pipe.
+    pipes.test(pipe)
+
+    # Loop over the spins.
+    for mol_index, res_index, spin_index in spin_index_loop(pipe=pipe):
+        # Match to the global index.
+        if spin_num == global_index:
+            return mol_index, res_index, spin_index
+
+        # Increment the spin number.
+        spin_num = spin_num + 1
 
 
 def delete_molecule(mol_id=None):




Related Messages


Powered by MHonArc, Updated Thu Jul 03 23:00:22 2008