mailr8470 - /1.3/generic_fns/mol_res_spin.py


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

Header


Content

Posted by edward on January 15, 2009 - 13:52:
Author: bugman
Date: Thu Jan 15 13:52:12 2009
New Revision: 8470

URL: http://svn.gna.org/viewcvs/relax?rev=8470&view=rev
Log:
Modified parse_token() to allow for '-' characters in molecule names (derived 
from file names, etc.)

Instead of throwing a RelaxError if an invalid range is found, it is assumed 
that the '-' character
does not signify a range and is treated as a string character which is part 
of the token.


Modified:
    1.3/generic_fns/mol_res_spin.py

Modified: 1.3/generic_fns/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/mol_res_spin.py?rev=8470&r1=8469&r2=8470&view=diff
==============================================================================
--- 1.3/generic_fns/mol_res_spin.py (original)
+++ 1.3/generic_fns/mol_res_spin.py Thu Jan 15 13:52:12 2009
@@ -1483,25 +1483,34 @@
                 indices.append(i)
 
         # Range.
+        valid_range = True
         if indices:
             # Invalid range element, only one range char '-' and one 
negative sign is allowed.
             if len(indices) > 2:
-                raise RelaxError, "The range element " + `element` + " is 
invalid."
+                print "The range element " + `element` + " is invalid.  
Assuming the '-' character does not specify a range."
+                valid_range = False
 
             # Convert the two numbers to integers.
             try:
                 start = int(element[:indices[0]])
                 end = int(element[indices[0]+1:])
             except ValueError:
-                raise RelaxError, "The range element " + `element` + " is 
invalid as either the start or end of the range are not integers."
+                print "The range element " + `element` + " is invalid as 
either the start or end of the range are not integers.  Assuming the '-' 
character does not specify a range."
+                valid_range = False
 
             # Test that the starting number is less than the end.
-            if start >= end:
-                raise RelaxError, "The starting number of the range element 
" + `element` + " needs to be less than the end number."
+            if valid_range and start >= end:
+                print "The starting number of the range element " + 
`element` + " needs to be less than the end number.  Assuming the '-' 
character does not specify a range."
+                valid_range = False
 
             # Create the range and append it to the list.
-            for i in range(start, end+1):
-                list.append(i)
+            if valid_range:
+                for i in range(start, end+1):
+                    list.append(i)
+
+            # Just append the string (even though it might be junk).
+            else:
+                list.append(element)
 
         # Number or name.
         else:




Related Messages


Powered by MHonArc, Updated Thu Jan 15 14:20:02 2009