mailr5614 - in /1.2: ./ generic_fns/palmer.py


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

Header


Content

Posted by edward on April 13, 2008 - 11:18:
Author: bugman
Date: Sun Apr 13 11:18:10 2008
New Revision: 5614

URL: http://svn.gna.org/viewcvs/relax?rev=5614&view=rev
Log:
Merged revisions 5611-5612 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3

........
  r5611 | bugman | 2008-04-13 11:04:28 +0200 (Sun, 13 Apr 2008) | 6 lines
  
  Fix for bug #11483 (https://gna.org/bugs/?11483).
  
  The get_mf_data() method has been expanded to handle both Modelfree4 mfout 
column fusion bugs.  This
  method should now be much more robust for parsing the mfout file.
........
  r5612 | bugman | 2008-04-13 11:06:36 +0200 (Sun, 13 Apr 2008) | 3 lines
  
  Removed some code for handling corrupt mfout files which was made redundant 
by the bug fix in r5611.
........

Modified:
    1.2/   (props changed)
    1.2/generic_fns/palmer.py

Propchange: 1.2/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Apr 13 11:18:10 2008
@@ -1,1 +1,1 @@
-/1.3:1-2505,2941,2947,2950,2974,2976,2979,2984,2988,3076,3083-3084,3087,3117,3299,3309,3312,3314,3318,3345,3372,4145,4473,4476,4939,5117,5255,5396-5398,5462-5465
+/1.3:1-2505,2941,2947,2950,2974,2976,2979,2984,2988,3076,3083-3084,3087,3117,3299,3309,3312,3314,3318,3345,3372,4145,4473,4476,4939,5117,5255,5396-5398,5462-5465,5611-5612

Modified: 1.2/generic_fns/palmer.py
URL: 
http://svn.gna.org/viewcvs/relax/1.2/generic_fns/palmer.py?rev=5614&r1=5613&r2=5614&view=diff
==============================================================================
--- 1.2/generic_fns/palmer.py (original)
+++ 1.2/generic_fns/palmer.py Sun Apr 13 11:18:10 2008
@@ -23,7 +23,7 @@
 from math import pi
 from os import F_OK, P_WAIT, access, chdir, chmod, getcwd, listdir, remove, 
system
 from re import match, search
-from string import split
+from string import count, find, split
 
 # UNIX only functions from the os module (Modelfree4 only runs under UNIX 
anyway).
 try:
@@ -565,13 +565,8 @@
             # Get the Rex data.
             if 'Rex' in data.params:
                 data.rex, data.rex_err = self.get_mf_data(self.mfout_Rex_pos 
+ pos)
-                try:
-                    data.rex = data.rex / (2.0 * pi * data.frq[0])**2
-                    data.rex_err = data.rex_err / (2.0 * pi * data.frq[0])**2
-                except TypeError:
-                    # Bug in Modelfree4's mfout output file (fusion of 
columns).
-                    data.rex = None
-                    data_rex_err = None
+                data.rex = data.rex / (2.0 * pi * data.frq[0])**2
+                data.rex_err = data.rex_err / (2.0 * pi * data.frq[0])**2
 
             # Get the chi-squared data.
             if not sims:
@@ -587,23 +582,78 @@
 
 
     def get_mf_data(self, pos):
-        """Extract the model-free data from the given position of the mfout 
file."""
+        """Extract the model-free data from the given position of the mfout 
file.
+
+        This method is designed to catch a number of bugs in Modelfree4's 
mfout file.
+
+        The first bug is the presence of a series of '*' characters causing 
a fusion of two columns.
+        This is handled by splitting by the '*' char and then returning the 
first element.
+
+        The second bug is when the floating point number is too big to fit 
into Modelfree4's string
+        format limit of 15.3f.  This results in a results line such as:
+
+        246      10000.00019682363392.000    1          0.000          0.000 
         0.000          0.000
+
+        This is caught by scanning for two '.' characters in the column, and 
handled by assuming
+        that every floating point number will have three decimal characters.
+
+        @param pos:     The mfout line position.
+        @type pos:      int
+        @return:        The value and error.
+        @rtype:         tuple of 2 floats
+        """
 
         # Split the line up.
         row = split(self.mfout_lines[pos])
 
-        # Attempt to extract the value and error.
-        try:
-            # Catch a series of '*' joining two columns.
-            val = split(row[1], '*')
-            err = split(row[4], '*')
-
-            # Return the value and error.
-            return float(val[0]), float(err[0])
-
-        # Otherwise, there is no data???
-        except:
-            return None, None
+        # The value and error, assuming a bug free mfout file.
+        val = row[1]
+        err = row[4]
+
+        # The Modelfree4 '*' column fusion bug.
+        if search('*', val) or search('*', err):
+            # Split by the '*' character.
+            val_row = split(val, '*')
+            err_row = split(err, '*')
+
+            # The value and error (the first elements).
+            val = val_row[0]
+            err = err_row[0]
+
+        # The Modelfree4 large float column fusion bug.
+        new_row = []
+        fused = False
+        for element in row:
+            # Count the number of '.' characters.
+            num = count(element, '.')
+
+            # Catch two or more '.' characters.
+            if num > 1:
+                # Set the fused flag.
+                fused = True
+
+                # Loop over each fused number.
+                for i in xrange(num):
+                    # Find the index of the first '.'.
+                    index = find(element, '.')
+
+                    # The first number (index + decimal point + 3 decimal 
chars).
+                    new_row.append(element[0:index+4])
+
+                    # Strip the first number from the element for the next 
loop iteration.
+                    element = element[index+4:]
+
+            # Otherwise the column element is fine.
+            else:
+                new_row.append(element)
+
+        # Bug has been caught.
+        if fused:
+            val = new_row[1]
+            err = new_row[4]
+
+        # Return the value and error, as floats.
+        return float(val), float(err)
 
 
     def line_positions(self):




Related Messages


Powered by MHonArc, Updated Sun Apr 13 12:00:19 2008