mailr8052 - /branches/spectral_errors/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 November 28, 2008 - 10:48:
Author: bugman
Date: Fri Nov 28 10:48:35 2008
New Revision: 8052

URL: http://svn.gna.org/viewcvs/relax?rev=8052&view=rev
Log:
Implemented the replicated() function.


Modified:
    branches/spectral_errors/generic_fns/spectrum.py

Modified: branches/spectral_errors/generic_fns/spectrum.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/spectral_errors/generic_fns/spectrum.py?rev=8052&r1=8051&r2=8052&view=diff
==============================================================================
--- branches/spectral_errors/generic_fns/spectrum.py (original)
+++ branches/spectral_errors/generic_fns/spectrum.py Fri Nov 28 10:48:35 2008
@@ -142,7 +142,7 @@
 
     # Test the spectrum id string.
     if spectrum_id not in cdp.spectrum_ids:
-        raise RelaxError, "The peak intensities corresponding to the 
spectrum id '%s' does not exist." % spectrum_id
+        raise RelaxError, "The peak intensities corresponding to the 
spectrum id '%s' do not exist." % spectrum_id
 
     # The spectrum id index.
     spect_index = cdp.spectrum_ids.index(spectrum_id)
@@ -631,3 +631,48 @@
 
         # Add the data.
         spin.intensities.append(intensity)
+
+
+def replicated(spectrum_ids=None):
+    """Set which spectra are replicates.
+
+    @keyword spectrum_ids:  A list of spectrum ids corresponding to 
replicated spectra.
+    @type spectrum_ids:     list of str
+    """
+
+    # Test if the current pipe exists
+    pipes.test()
+
+    # Get the current data pipe.
+    cdp = pipes.get_pipe()
+
+    # Test if spectra have been loaded.
+    if not hasattr(cdp, 'spectrum_ids'):
+        raise RelaxError, "No spectra have been loaded therefore replicates 
cannot be specified."
+
+    # Test the spectrum id strings.
+    for spectrum_id in spectrum_ids:
+        if spectrum_id not in cdp.spectrum_ids:
+            raise RelaxError, "The peak intensities corresponding to the 
spectrum id '%s' do not exist." % spectrum_id
+
+    # Initialise.
+    if not hasattr(cdp, 'replicates'):
+        cdp.replicates = []
+
+    # Check if the spectrum id is already in the list.
+    for i in xrange(len(cdp.replicates)):
+        found = False
+        for j in xrange(len(spectrum_ids)):
+            if spectrum_ids[j] in cdp.replicates[i]:
+                found = True
+                spectrum_ids.pop(j)
+
+        # Add the remaining replicates to the list and quit this function.
+        if found:
+            cdp.replicates[i] = cdp.replicates[i] + spectrum_ids
+            print cdp.replicates
+            return
+
+    # Set the replicates.
+    cdp.replicates.append(spectrum_ids)
+    print cdp.replicates




Related Messages


Powered by MHonArc, Updated Fri Nov 28 11:00:05 2008