Author: bugman Date: Thu May 22 12:32:29 2008 New Revision: 6239 URL: http://svn.gna.org/viewcvs/relax?rev=6239&view=rev Log: Added the boolean arg to the desel_spin() 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=6239&r1=6238&r2=6239&view=diff ============================================================================== --- 1.3/generic_fns/selection.py (original) +++ 1.3/generic_fns/selection.py Thu May 22 12:32:29 2008 @@ -139,13 +139,19 @@ spin.select = False -def desel_spin(spin_id=None, change_all=None): +def desel_spin(spin_id=None, boolean='AND', change_all=False): """Deselect 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 selected. + file to be selected. Only the boolean operator 'AND' 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. @@ -159,14 +165,33 @@ if not exists_mol_res_spin_data(): raise RelaxNoSequenceError - # First select all spins if desired. + # First select all spins if the change_all flag is set. if change_all: for spin in spin_loop(): spin.select = True - # Then deselect the desired spins. + # Loop over the specified spins. for spin in spin_loop(spin_id): - spin.select = False + # Deselect just the specified residues. + if change_all: + spin.select = False + + # Boolean selections. + else: + if boolean == 'OR': + spin.select = spin.select or False + elif boolean == 'NOR': + spin.select = not (spin.select or False) + elif boolean == 'AND': + spin.select = spin.select and False + elif boolean == 'NAND': + spin.select = not (spin.select and False) + elif boolean == 'XOR': + spin.select = not (spin.select and False) and (spin.select or False) + elif boolean == 'XNOR': + spin.select = (spin.select and False) or not (spin.select or False) + else: + raise RelaxError, "Unknown boolean operator " + `boolean` def reverse(spin_id=None):