mailr9654 - /1.3/relax_io.py


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

Header


Content

Posted by edward on October 08, 2009 - 10:01:
Author: bugman
Date: Thu Oct  8 10:01:18 2009
New Revision: 9654

URL: http://svn.gna.org/viewcvs/relax?rev=9654&view=rev
Log:
Improvements to the read_spin_data() function.

The data checks now occur during the yield loop.  This allows for invalid 
lines to be skipped while
those with real data are used.


Modified:
    1.3/relax_io.py

Modified: 1.3/relax_io.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/relax_io.py?rev=9654&r1=9653&r2=9654&view=diff
==============================================================================
--- 1.3/relax_io.py (original)
+++ 1.3/relax_io.py Thu Oct  8 10:01:18 2009
@@ -542,39 +542,31 @@
     if not file_data:
         raise RelaxFileEmptyError
 
-    # Test the validity of the data.
-    if data_col or error_col:
-        missing = True
-        for line in file_data:
-            # Skip missing data.
-            if len(line) < min_col_num:
-                continue
-            elif data_col and line[data_col-1] == 'None':
+    # Yield the data, spin by spin.
+    missing_data = True
+    for line in file_data:
+        # Skip missing data.
+        if len(line) < min_col_num:
+            continue
+
+        # Skip invalid data.
+        if data_col or error_col:
+            if data_col and line[data_col-1] == 'None':
                 continue
             elif error_col and line[error_col-1] == 'None':
                 continue
 
-            # Validate the sequence.
-            try:
-                generic_fns.sequence.validate_sequence(line, 
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)
-            except RelaxInvalidSeqError, msg:
-                # Extract the message string, without the RelaxError bit.
-                string = msg.__str__()[12:-1]
-
-                # Give a warning.
-                warn(RelaxWarning(string))
-
-            # Right, data is OK and exists.
-            missing = False
-
-        # Hmmm, no data!
-        if missing:
-            raise RelaxError("No corresponding data could be found within 
the file.")
-
-    # Yield the data, spin by spin.
-    for line in file_data:
-        # Skip missing data.
-        if len(line) < min_col_num:
+        # Validate the sequence.
+        try:
+            generic_fns.sequence.validate_sequence(line, 
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)
+        except RelaxInvalidSeqError, msg:
+            # Extract the message string, without the RelaxError bit.
+            string = msg.__str__()[12:-1]
+
+            # Give a warning.
+            warn(RelaxWarning(string))
+
+            # Skip the line.
             continue
 
         # Generate the spin ID string.
@@ -590,6 +582,9 @@
         error = None
         if error_col:
             error = eval(line[error_col-1])
+
+        # Right, data is OK and exists.
+        missing_data = False
 
         # Yield the data.
         if data_col and error_col:
@@ -600,6 +595,10 @@
             yield [id, error]
         else:
             yield id
+
+    # Hmmm, no data!
+    if missing_data:
+        raise RelaxError("No corresponding data could be found within the 
file.")
 
 
 def strip(data):




Related Messages


Powered by MHonArc, Updated Thu Oct 08 10:40:02 2009