mailr2799 - /1.3/generic_fns/intensity.py


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

Header


Content

Posted by edward . dauvergne on November 10, 2006 - 08:19:
Author: bugman
Date: Fri Nov 10 08:18:32 2006
New Revision: 2799

URL: http://svn.gna.org/viewcvs/relax?rev=2799&view=rev
Log:
Fix for bug #7676 (https://gna.org/bugs/?7676).

This bug was reported by Stephen Headey <s dot j dot headey at massey dot ac 
dot nz>.  The issue was
originally reported at 
https://mail.gna.org/public/relax-users/2006-11/msg00003.html (Message-id:
<59ADAF5CA6A8FC4C889BD4097D912BB1072D330D@xxxxxxxxxxxxxxxxxxxxxx>).  Together 
with r2798
(https://mail.gna.org/public/relax-commits/2006-11/msg00096.html) which fixed 
the issue of not
having 2 header lines, this gives more flexibility in reading XEasy text 
files.

The function 'self.det_dimensions()' has been added to determine which of w1 
or w2 is the proton
dimension.  The intensity reading function 'self.intensity_xeasy()' then uses 
this info to return
the correct proton and heteronucleus names for the given data line.


Modified:
    1.3/generic_fns/intensity.py

Modified: 1.3/generic_fns/intensity.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/intensity.py?rev=2799&r1=2798&r2=2799&view=diff
==============================================================================
--- 1.3/generic_fns/intensity.py (original)
+++ 1.3/generic_fns/intensity.py Fri Nov 10 08:18:32 2006
@@ -29,6 +29,40 @@
         self.relax = relax
 
 
+    def det_dimensions(self):
+        """Determine which are the proton and heteronuclei dimensions of the 
XEasy text file.
+
+        @return:    None
+        """
+
+        # Loop over the lines of the file until the proton and heteronucleus 
is reached.
+        for i in xrange(len(self.file_data)):
+            # Extract the data.
+            res_num, w1_name, w2_name, intensity = 
self.intensity(self.file_data[i])
+
+            # Proton in w1, heteronucleus in w2.
+            if w1_name == self.proton and w2_name == self.heteronuc:
+                # Set the proton dimension.
+                self.H_dim = 'w1'
+
+                # Print out.
+                print "The proton dimension is w1"
+
+                # Don't continue (waste of time).
+                break
+
+            # Heteronucleus in w1, proton in w2.
+            if w1_name == self.heteronuc and w2_name == self.proton:
+                # Set the proton dimension.
+                self.H_dim = 'w2'
+
+                # Print out.
+                print "The proton dimension is w2"
+
+                # Don't continue (waste of time).
+                break
+
+
     def intensity_sparky(self, line):
         """Function for returning relevant data from the Sparky peak 
intensity line.
 
@@ -80,8 +114,12 @@
             raise RelaxError, "Improperly formatted XEasy file."
 
         # Nuclei names.
-        x_name = line[7]
-        h_name = line[4]
+        if self.H_dim == 'w1':
+            h_name = line[4]
+            x_name = line[7]
+        else:
+            x_name = line[4]
+            h_name = line[7]
 
         # Intensity (located in column 10).
         try:
@@ -90,7 +128,7 @@
             raise RelaxError, "The peak intensity value " + `intensity` + " 
from the line " + `line` + " is invalid."
 
         # Return the data.
-        return res_num, x_name, h_name, intensity
+        return res_num, h_name, x_name, intensity
 
 
     def number_of_header_lines(self):
@@ -146,13 +184,22 @@
 
         # Sparky.
         if self.format == 'sparky':
+            # Print out.
             print "Sparky formatted data file.\n"
+
+            # Set the intensity reading function.
             self.intensity = self.intensity_sparky
 
         # XEasy.
         elif self.format == 'xeasy':
+            # Print out.
             print "XEasy formatted data file.\n"
+
+            # Set the intensity reading function.
             self.intensity = self.intensity_xeasy
+
+            # Set the default proton dimension.
+            self.H_dim = 'w1'
 
         # Test if the run exists.
         if not self.run in self.relax.data.run_names:
@@ -175,14 +222,18 @@
         # Strip the data.
         self.file_data = self.relax.IO.strip(self.file_data)
 
+        # Determine the proton and heteronucleus dimensions in the XEasy 
text file.
+        if self.format == 'xeasy':
+            self.det_dimensions()
+
         # Loop over the peak intensity data.
         for i in xrange(len(self.file_data)):
             # Extract the data.
-            res_num, X_name, H_name, intensity = 
self.intensity(self.file_data[i])
+            res_num, H_name, X_name, intensity = 
self.intensity(self.file_data[i])
 
             # Skip data.
             if X_name != self.heteronuc or H_name != self.proton:
-                print "Skipping the data: " + `self.file_data[i]`
+                warn(RelaxWarning("Proton and heteronucleus names do not 
match, skipping the data %s: " % `self.file_data[i]`))
                 continue
 
             # Find the index of self.relax.data.res[self.run] which 
corresponds to res_num.
@@ -192,7 +243,7 @@
                     index = j
                     break
             if index == None:
-                print "Skipping the data: " + `self.file_data[i]`
+                warn(RelaxWarning("Cannot find residue number %s within the 
sequence." % res_num))
                 continue
 
             # Remap the data structure 
'self.relax.data.res[self.run][index]'.




Related Messages


Powered by MHonArc, Updated Fri Nov 10 08:40:06 2006