mailr6236 - /1.3/generic_fns/selection.py


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

Header


Content

Posted by edward on May 22, 2008 - 12:24:
Author: bugman
Date: Thu May 22 12:24:13 2008
New Revision: 6236

URL: http://svn.gna.org/viewcvs/relax?rev=6236&view=rev
Log:
Fixes for the sel_read() function.


Modified:
    1.3/generic_fns/selection.py

Modified: 1.3/generic_fns/selection.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/selection.py?rev=6236&r1=6235&r2=6236&view=diff
==============================================================================
--- 1.3/generic_fns/selection.py (original)
+++ 1.3/generic_fns/selection.py Thu May 22 12:24:13 2008
@@ -241,9 +241,12 @@
     @type sep:                      str or None
     @param boolean:                 The boolean operator used to select the 
spin systems with.  It
                                     can be one of 'OR', 'NOR', 'AND', 
'NAND', 'XOR', or 'XNOR'.
+                                    This will be ignored if the change_all 
flag is set.
     @type boolean:                  str
     @keyword change_all:            A flag which if True will cause all 
spins not specified in the
-                                    file to be selected.
+                                    file to be selected.  Only the boolean 
operator 'OR' is
+                                    compatible with this flag set to True 
(all others will be
+                                    ignored).
     @type change_all:               bool
     @raises RelaxNoPipeError:       If the current data pipe does not exist.
     @raises RelaxNoSequenceError:   If no molecule/residue/spins sequence 
data exists.
@@ -280,64 +283,17 @@
     # Minimum number of columns.
     min_col_num = max(mol_name_col, res_num_col, res_name_col, spin_num_col, 
spin_name_col)
 
-    # Loop over the spins.
-    for spin, mol_name, res_num, res_name in spin_loop(full_info=True):
-        # The spin system is in the file.
-        flag = spin_in_list(file_data, 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, mol_name=mol_name, 
res_num=res_num, res_name=res_name, spin_num=spin.num, spin_name=spin.name)
-
-        # Skip spins not the file.
-        if not change_all and not flag:
-            continue
-
-        # Boolean selections.
-        if boolean == 'OR':
-            spin.select = spin.select or flag
-        elif boolean == 'NOR':
-            spin.select = not (spin.select or flag)
-        elif boolean == 'AND':
-            spin.select = spin.select and flag
-        elif boolean == 'NAND':
-            spin.select = not (spin.select and flag)
-        elif boolean == 'XOR':
-            spin.select = not (spin.select and flag) and (spin.select or 
flag)
-        elif boolean == 'XNOR':
-            spin.select = (spin.select and flag) or not (spin.select or flag)
-        else:
-            raise RelaxError, "Unknown boolean operator " + `boolean`
-
-
-def sel_spin(spin_id=None, boolean='OR', change_all=False):
-    """Select specific spins.
-
-    @keyword spin_id:               The spin identification string.
-    @type spin_id:                  str or None
-    @param boolean:                 The boolean operator used to select the 
spin systems with.  It
-                                    can be one of 'OR', 'NOR', 'AND', 
'NAND', 'XOR', or 'XNOR'.
-                                    This will be ignored if the change_all 
flag is set.
-    @type boolean:                  str
-    @keyword change_all:            A flag which if True will cause all 
spins not specified in the
-                                    file to be deselected.  Only the boolean 
operator 'OR' is
-                                    compatible with this flag set to True 
(all others will be
-                                    ignored).
-    @type change_all:               bool
-    """
-
-    # Test if the current data pipe exists.
-    if not relax_data_store.current_pipe:
-        raise RelaxNoPipeError
-
-    # Test if sequence data is loaded.
-    if not exists_mol_res_spin_data():
-        raise RelaxNoSequenceError
-
     # First deselect all spins if the change_all flag is set.
     if change_all:
         # Loop over all spins.
         for spin in spin_loop():
             spin.select = False
 
-    # Loop over the specified spins.
-    for spin in spin_loop(spin_id):
+    # Loop over all spins.
+    for spin, mol_name, res_num, res_name in spin_loop(full_info=True):
+        # Skip spins not the file.
+        if not spin_in_list(file_data, 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, mol_name=mol_name, 
res_num=res_num, res_name=res_name, spin_num=spin.num, spin_name=spin.name)
+
         # Select just the specified residues.
         if change_all:
             spin.select = True
@@ -358,3 +314,59 @@
                 spin.select = (spin.select and True) or not (spin.select or 
True)
             else:
                 raise RelaxError, "Unknown boolean operator " + `boolean`
+
+
+def sel_spin(spin_id=None, boolean='OR', change_all=False):
+    """Select specific spins.
+
+    @keyword spin_id:               The spin identification string.
+    @type spin_id:                  str or None
+    @param boolean:                 The boolean operator used to select the 
spin systems with.  It
+                                    can be one of 'OR', 'NOR', 'AND', 
'NAND', 'XOR', or 'XNOR'.
+                                    This will be ignored if the change_all 
flag is set.
+    @type boolean:                  str
+    @keyword change_all:            A flag which if True will cause all 
spins not specified in the
+                                    file to be deselected.  Only the boolean 
operator 'OR' is
+                                    compatible with this flag set to True 
(all others will be
+                                    ignored).
+    @type change_all:               bool
+    @raises RelaxNoPipeError:       If the current data pipe does not exist.
+    @raises RelaxNoSequenceError:   If no molecule/residue/spins sequence 
data exists.
+    """
+
+    # Test if the current data pipe exists.
+    if not relax_data_store.current_pipe:
+        raise RelaxNoPipeError
+
+    # Test if sequence data is loaded.
+    if not exists_mol_res_spin_data():
+        raise RelaxNoSequenceError
+
+    # First deselect all spins if the change_all flag is set.
+    if change_all:
+        # Loop over all spins.
+        for spin in spin_loop():
+            spin.select = False
+
+    # Loop over the specified spins.
+    for spin in spin_loop(spin_id):
+        # Select just the specified residues.
+        if change_all:
+            spin.select = True
+
+        # Boolean selections.
+        else:
+            if boolean == 'OR':
+                spin.select = spin.select or True
+            elif boolean == 'NOR':
+                spin.select = not (spin.select or True)
+            elif boolean == 'AND':
+                spin.select = spin.select and True
+            elif boolean == 'NAND':
+                spin.select = not (spin.select and True)
+            elif boolean == 'XOR':
+                spin.select = not (spin.select and True) and (spin.select or 
True)
+            elif boolean == 'XNOR':
+                spin.select = (spin.select and True) or not (spin.select or 
True)
+            else:
+                raise RelaxError, "Unknown boolean operator " + `boolean`




Related Messages


Powered by MHonArc, Updated Thu May 22 12:40:16 2008