mailr16960 - in /branches/interatomic: ./ 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 June 19, 2012 - 16:06:
Author: bugman
Date: Tue Jun 19 16:06:57 2012
New Revision: 16960

URL: http://svn.gna.org/viewcvs/relax?rev=16960&view=rev
Log:
Merged revisions 16959 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r16959 | bugman | 2012-06-19 16:06:30 +0200 (Tue, 19 Jun 2012) | 5 lines
  
  Created the generic_fns.mol_res_spin.return_spin_indices() function to 
return the index triplet.
  
  This allows a spin ID to be converted into the molecule, residue and spin 
indices.
........

Modified:
    branches/interatomic/   (props changed)
    branches/interatomic/generic_fns/mol_res_spin.py

Propchange: branches/interatomic/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Jun 19 16:06:57 2012
@@ -1,1 +1,1 @@
-/trunk:1-16957
+/trunk:1-16959

Modified: branches/interatomic/generic_fns/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/interatomic/generic_fns/mol_res_spin.py?rev=16960&r1=16959&r2=16960&view=diff
==============================================================================
--- branches/interatomic/generic_fns/mol_res_spin.py (original)
+++ branches/interatomic/generic_fns/mol_res_spin.py Tue Jun 19 16:06:57 2012
@@ -2509,6 +2509,66 @@
 
         # Increment the spin number.
         spin_num = spin_num + 1
+
+
+def return_spin_indices(spin_id=None, pipe=None):
+    """Return the molecule, residue and spin indices corresponding to the 
given spin ID string.
+
+    @keyword spin_id:   The unique spin ID string.
+    @type spin_id:      str
+    @param pipe:        The data pipe containing the spin.  Defaults to the 
current data pipe.
+    @type pipe:         str
+    @return:            The molecule, residue and spin indices.
+    @rtype:             list of int
+    """
+
+    # The data pipe.
+    if pipe == None:
+        pipe = pipes.cdp_name()
+
+    # Get the data pipe.
+    dp = pipes.get_pipe(pipe)
+
+    # No spin ID, so switch to selection matching.
+    if not dp.mol.lookup_table.has_key(spin_id):
+        # Parse the selection string.
+        select_obj = Selection(selection)
+
+        # Loop over the molecules.
+        for i in range(len(dp.mol)):
+            # Skip the molecule if there is no match to the selection.
+            if dp.mol[i] not in select_obj:
+                continue
+
+            # The molecule index.
+            mol_index = i
+
+            # Loop over the residues.
+            for j in range(len(dp.mol[i].res)):
+                # Skip the residue if there is no match to the selection.
+                if dp.mol[i].res[j] not in select_obj:
+                    continue
+
+                # The residue index.
+                res_index = j
+
+                # Loop over the spins.
+                for k in range(len(dp.mol[i].res[j].spin)):
+                    # Skip the spin if there is no match to the selection.
+                    if dp.mol[i].res[j].spin[k] not in select_obj:
+                        continue
+
+                    # The spin index.
+                    spin_index = k
+
+                    # Found the spin, so terminate.
+                    break
+
+    # The indices from the look up table.
+    mol_index, res_index, spin_index = dp.mol.lookup_table[spin_id]
+
+    # Return the data.
+    return mol_index, res_index, spin_index
 
 
 def return_single_molecule_info(molecule_token):




Related Messages


Powered by MHonArc, Updated Tue Jun 19 16:40:02 2012