mailr13769 - /branches/gui_testing/generic_fns/spectrum.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on July 20, 2011 - 11:38:
Author: bugman
Date: Wed Jul 20 11:38:40 2011
New Revision: 13769

URL: http://svn.gna.org/viewcvs/relax?rev=13769&view=rev
Log:
Created generic_fns.spectrum.replicated_ids() to create a list of replicated 
spectrum IDs.

A spectrum ID is given, and all spectra which are replicates of it will be 
returned as a list.


Modified:
    branches/gui_testing/generic_fns/spectrum.py

Modified: branches/gui_testing/generic_fns/spectrum.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/generic_fns/spectrum.py?rev=13769&r1=13768&r2=13769&view=diff
==============================================================================
--- branches/gui_testing/generic_fns/spectrum.py (original)
+++ branches/gui_testing/generic_fns/spectrum.py Wed Jul 20 11:38:40 2011
@@ -1124,3 +1124,46 @@
 
     # Return the dictionary.
     return repl
+
+
+def replicated_ids(spectrum_id):
+    """Create and return a list of spectra ID which are replicates of the 
given ID.
+
+    @param spectrum_id: The spectrum ID to find all the replicates of.
+    @type spectrum_id:  str
+    @return:            The list of spectrum IDs which are replicates of 
spectrum_id.
+    @rtype:             list of str
+    """
+
+    # Initialise the ID list.
+    repl = []
+
+    # Loop over the replicate lists.
+    for i in range(len(cdp.replicates)):
+        # The spectrum ID is in the list.
+        if spectrum_id in cdp.replicates[i]:
+            # Loop over the inner list.
+            for j in range(len(cdp.replicates[i])):
+                # Spectrum ID match.
+                if spectrum_id == cdp.replicates[i][j]:
+                    continue
+
+                # Append the replicated ID.
+                repl.append(cdp.replicates[i][j])
+
+    # Sort the list.
+    repl.sort()
+
+    # Remove duplicates (backward).
+    id = repl[-1]
+    for i in range(len(repl)-2, -1, -1):
+        # Duplicate.
+        if id == repl[i]:
+            del repl[i]
+
+        # Unique.
+        else:
+            id = repl[i]
+
+    # Return the list.
+    return repl




Related Messages


Powered by MHonArc, Updated Wed Jul 20 11:40:01 2011