Author: bugman Date: Wed May 7 17:08:49 2008 New Revision: 6133 URL: http://svn.gna.org/viewcvs/relax?rev=6133&view=rev Log: Updated the desel_spin() function to the new design. 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=6133&r1=6132&r2=6133&view=diff ============================================================================== --- 1.3/generic_fns/selection.py (original) +++ 1.3/generic_fns/selection.py Wed May 7 17:08:49 2008 @@ -133,68 +133,32 @@ spin.select = 0 -def desel_res(self, run=None, num=None, name=None, change_all=None): - """Function for deselecting specific residues.""" - - # Test if the residue number is a valid regular expression. - if type(num) == str: - try: - compile(num) - except: - raise RelaxRegExpError, ('residue number', num) - - # Test if the residue name is a valid regular expression. - if name: - try: - compile(name) - except: - raise RelaxRegExpError, ('residue name', name) - - # Create the list of runs. - self.runs = self.relax.generic.runs.list_of_runs(run) - - # Loop over the runs. - no_match = 1 - for self.run in self.runs: - # Test if the run exists. - if not self.run in relax_data_store.run_names: - raise RelaxNoPipeError, self.run - - # Test if sequence data is loaded. - if not len(relax_data_store.res[self.run]): - raise RelaxNoSequenceError, self.run - - # Loop over the sequence. - for i in xrange(len(relax_data_store.res[self.run])): - # Remap the data structure 'relax_data_store.res[self.run][i]'. - data = relax_data_store.res[self.run][i] - - # Select all residues. - if change_all: - data.select = 1 - - # Skip the residue if there is no match to 'num'. - if type(num) == int: - if not data.num == num: - continue - if type(num) == str: - if not match(num, `data.num`): - continue - - # Skip the residue if there is no match to 'name'. - if name != None: - if not match(name, data.name): - continue - - # Deselect the residue. - data.select = 0 - - # Match flag. - no_match = 0 - - # No residue matched. - if no_match: - print "No residues match." +def desel_spin(spin_id=None, change_all=None): + """Deselect specific spins. + + @keyword spin_id: The spin identification string. + @type spin_id: str or None + @keyword change_all: A flag which if True will cause all spins not specified in the file to + be selected. + @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 select all spins if desired. + if change_all: + for spin in spin_loop(): + spin.select = 1 + + # Then deselect the desired spins. + for spin in spin_loop(spin_id): + spin.select = 0 def reverse(selection=None):