mailr14546 - /1.3/generic_fns/sequence.py


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

Header


Content

Posted by edward on August 31, 2011 - 14:38:
Author: bugman
Date: Wed Aug 31 14:38:28 2011
New Revision: 14546

URL: http://svn.gna.org/viewcvs/relax?rev=14546&view=rev
Log:
Clean up and fixes for the generic_fns.sequence.validate_sequence() fn.


Modified:
    1.3/generic_fns/sequence.py

Modified: 1.3/generic_fns/sequence.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/sequence.py?rev=14546&r1=14545&r2=14546&view=diff
==============================================================================
--- 1.3/generic_fns/sequence.py (original)
+++ 1.3/generic_fns/sequence.py Wed Aug 31 14:38:28 2011
@@ -22,6 +22,9 @@
 
 # Module docstring.
 """Module for handling the molecule, residue, and spin sequence."""
+
+# Python module imports
+from types import IntType, NoneType
 
 # relax module imports.
 from generic_fns.mol_res_spin import count_molecules, count_residues, 
count_spins, exists_mol_res_spin_data, generate_spin_id, return_molecule, 
return_residue, return_spin, spin_id_to_data_list, spin_loop
@@ -330,72 +333,60 @@
 
     # Spin ID.
     if spin_id_col:
-        try:
-            data[spin_id_col-1]
-        except IndexError:
+        if len(data) < spin_id_col:
             raise RelaxInvalidSeqError(data, "the Spin ID data is missing")
 
     # Molecule name data.
     if mol_name_col:
-        try:
-            data[mol_name_col-1]
-        except IndexError:
+        if len(data) < mol_name_col:
             raise RelaxInvalidSeqError(data, "the molecule name data is 
missing")
 
     # Residue number data.
     if res_num_col:
         # No data in column.
-        try:
-            data[res_num_col-1]
-        except IndexError:
+        if len(data) < res_num_col:
             raise RelaxInvalidSeqError(data, "the residue number data is 
missing")
 
         # Bad data in column.
         try:
-            int(data[res_num_col-1])
+            res_num = eval(data[res_num_col-1])
+            if not (isinstance(res_num, NoneType) or isinstance(res_num, 
IntType)):
+                raise ValueError
         except ValueError:
             raise RelaxInvalidSeqError(data, "the residue number data is 
invalid")
 
     # Residue name data.
     if res_name_col:
-        try:
-            data[res_name_col-1]
-        except IndexError:
+        if len(data) < res_name_col:
             raise RelaxInvalidSeqError(data, "the residue name data is 
missing")
 
     # Spin number data.
     if spin_num_col:
         # No data in column.
-        try:
-            data[spin_num_col-1]
-        except IndexError:
+        if len(data) < spin_num_col:
             raise RelaxInvalidSeqError(data, "the spin number data is 
missing")
 
         # Bad data in column.
         try:
-            int(data[spin_num_col-1])
+            res_num = eval(data[res_num_col-1])
+            if not (isinstance(res_num, NoneType) or isinstance(res_num, 
IntType)):
+                raise ValueError
         except ValueError:
             raise RelaxInvalidSeqError(data, "the spin number data is 
invalid")
 
     # Spin name data.
     if spin_name_col:
-        try:
-            data[spin_name_col-1]
-        except IndexError:
+        if len(data) < spin_name_col:
             raise RelaxInvalidSeqError(data, "the spin name data is missing")
 
     # Data.
     if data_col:
-        try:
-            data[data_col-1]
-        except IndexError:
+        if len(data) < data_col:
             raise RelaxInvalidSeqError(data, "the data is missing")
 
     # Errors
     if error_col:
-        try:
-            data[error_col-1]
-        except IndexError:
+        if len(data) < error_col:
             raise RelaxInvalidSeqError(data, "the error data is missing")
 
 




Related Messages


Powered by MHonArc, Updated Wed Aug 31 15:00:03 2011