mailr7206 - /branches/rdc_analysis/generic_fns/pcs.py


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

Header


Content

Posted by edward on August 17, 2008 - 19:24:
Author: bugman
Date: Sun Aug 17 19:10:17 2008
New Revision: 7206

URL: http://svn.gna.org/viewcvs/relax?rev=7206&view=rev
Log:
Try 2:  PCS errors in a file separate from the data can now be read.

This matches the changes for the RDC at r7202, and is what r7204 should have 
been.


Modified:
    branches/rdc_analysis/generic_fns/pcs.py

Modified: branches/rdc_analysis/generic_fns/pcs.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/rdc_analysis/generic_fns/pcs.py?rev=7206&r1=7205&r2=7206&view=diff
==============================================================================
--- branches/rdc_analysis/generic_fns/pcs.py (original)
+++ branches/rdc_analysis/generic_fns/pcs.py Sun Aug 17 19:10:17 2008
@@ -596,7 +596,7 @@
     @type spin_name_col:    int or None
     @param spin_num_col:    The column containing the spin number 
information.
     @type spin_num_col:     int or None
-    @param sep:             The column seperator which, if None, defaults to 
whitespace.
+    @param sep:             The column separator which, if None, defaults to 
whitespace.
     @type sep:              str or None
     """
 
@@ -611,8 +611,12 @@
     cdp = ds[ds.current_pipe]
 
     # Test if PCS data corresponding to 'id' already exists.
-    if hasattr(cdp, 'pcs_ids') and id in cdp.pcs_ids:
+    if data_col != None and hasattr(cdp, 'pcs_ids') and id in cdp.pcs_ids:
         raise RelaxPCSError, id
+
+    # Either the data or error column must be supplied.
+    if data_col == None and error_col == None:
+        raise RelaxError, "One of either the data or error column must be 
supplied."
 
     # Minimum number of columns.
     min_col_num = max(mol_name_col, res_num_col, res_name_col, spin_num_col, 
spin_name_col, data_col, error_col)
@@ -626,7 +630,10 @@
         header_lines = 0
         for i in xrange(len(file_data)):
             try:
-                float(file_data[i][data_col])
+                if data_col != None:
+                    float(file_data[i][data_col])
+                else:
+                    float(file_data[i][error_col])
             except:
                 header_lines = header_lines + 1
             else:
@@ -643,9 +650,9 @@
             # Skip missing data.
             if len(file_data[i]) <= min_col_num:
                 continue
-            elif file_data[i][data_col] == 'None':
+            elif data_col != None and file_data[i][data_col] == 'None':
                 continue
-            elif error_col and file_data[i][error_col] == 'None':
+            elif error_col != None and file_data[i][error_col] == 'None':
                 continue
 
             # Test that the data are numbers.
@@ -654,8 +661,9 @@
                     int(file_data[i][res_num_col])
                 if spin_num_col != None:
                     int(file_data[i][spin_num_col])
-                float(file_data[i][data_col])
-                if error_col:
+                if data_col != None:
+                    float(file_data[i][data_col])
+                if error_col != None:
                     float(file_data[i][error_col])
             except ValueError:
                 raise RelaxError, "The PCS data in the line " + 
`file_data[i]` + " is invalid."
@@ -685,9 +693,16 @@
         id = generate_spin_id_data_array(data=file_data[i], 
mol_name_col=mol_name_col, res_num_col=res_num_col, 
res_name_col=res_name_col, spin_num_col=spin_num_col, 
spin_name_col=spin_name_col)
 
         # Convert the data.
-        value = eval(file_data[i][data_col])
-        if error_col:
+        value = None
+        if data_col != None:
+            value = eval(file_data[i][data_col])
+        error = None
+        if error_col != None:
             error = eval(file_data[i][error_col])
+
+        # Test the error value (cannot be 0.0).
+        if error == 0.0:
+            raise RelaxError, "An invalid error value of zero has been 
encountered."
 
         # Get the corresponding spin container.
         spin = return_spin(id)
@@ -695,12 +710,21 @@
             raise RelaxNoSpinError, id
 
         # Add the data.
-        if not hasattr(spin, 'pcs'):
-            spin.pcs = []
-        spin.pcs.append(value)
-        if error_col:
+        if data_col != None:
+            # Initialise.
+            if not hasattr(spin, 'pcs'):
+                spin.pcs = []
+
+            # Append the value.
+            spin.pcs.append(value)
+
+        # Add the error.
+        if error_col != None:
+            # Initialise.
             if not hasattr(spin, 'pcs_err'):
                 spin.pcs_err = []
+
+            # Append the error.
             spin.pcs_err.append(error)
 
 




Related Messages


Powered by MHonArc, Updated Sun Aug 17 19:40:18 2008