Author: bugman Date: Mon Mar 19 06:19:33 2007 New Revision: 3221 URL: http://svn.gna.org/viewcvs/relax?rev=3221&view=rev Log: Fixed the select.reverse() user function. The generic_fns.selection.reverse() function still does not work as the spin_loop() function needs to be implemented. Modified: 1.3/generic_fns/selection.py 1.3/prompt/select.py Modified: 1.3/generic_fns/selection.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/selection.py?rev=3221&r1=3220&r2=3221&view=diff ============================================================================== --- 1.3/generic_fns/selection.py (original) +++ 1.3/generic_fns/selection.py Mon Mar 19 06:19:33 2007 @@ -189,32 +189,16 @@ return [] -def reverse(self, run=None): - """Function for the reversal of residue selection.""" - - # Create the list of runs. - self.runs = self.relax.generic.runs.list_of_runs(run) - - # Loop over the runs. - for self.run in self.runs: - # Test if the run exists. - if not self.run in relax_data_store.run_names: - raise RelaxNoRunError, 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 and reverse the selection flag. - 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] - - # Reverse the selection. - if data.select: - data.select = 0 - else: - data.select = 1 +def reverse(selection=None): + """Function for the reversal of the spin system selection.""" + + # Loop over the spin systems and reverse the selection flag. + for spin in spin_loop(selection): + # Reverse the selection. + if spin.select: + spin.select = 0 + else: + spin.select = 1 def sel_all(self, run=None): Modified: 1.3/prompt/select.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/select.py?rev=3221&r1=3220&r2=3221&view=diff ============================================================================== --- 1.3/prompt/select.py (original) +++ 1.3/prompt/select.py Mon Mar 19 06:19:33 2007 @@ -20,10 +20,13 @@ # # ############################################################################### +# Python module imports. import sys +# relax module imports. import help from relax_errors import RelaxBinError, RelaxError, RelaxIntError, RelaxListStrError, RelaxNoneIntStrError, RelaxNoneStrError, RelaxNoneStrListError, RelaxStrError +from generic_fns.selection import reverse class Select: @@ -293,20 +296,27 @@ self.__relax__.generic.selection.sel_res(run=run, num=num, name=name, boolean=boolean, change_all=change_all) - def reverse(self, run=None): - """Function for the reversal of the residue selection. + def reverse(self, selection=None): + """Function for the reversal of the spin system selection for the given spins. Keyword Arguments ~~~~~~~~~~~~~~~~~ - run: The name of the run(s). By supplying a single string, array of strings, or None, a - single run, multiple runs, or all runs will be selected respectively. + selection: The selection string identifying the molecules, residues, and spins to reverse + the selection of. + + + Description + ~~~~~~~~~~~ + + If the selection argument is left on the default of None, then the selection status of all + spin systems of the current data pipe will be reversed. Examples ~~~~~~~~ - To unselect all currently selected residues and select those which are unselected type: + To deselect all currently selected residues and select those which are deselected type: relax> select.reverse() """ @@ -314,19 +324,15 @@ # Function intro test. if self.__relax__.interpreter.intro: text = sys.ps3 + "select.reverse(" - text = text + "run=" + `run` + ")" + text = text + "selection=" + `selection` + ")" print text - # The run argument. - if run != None and type(run) != str and type(run) != list: - raise RelaxNoneStrListError, ('run', run) - if type(run) == list: - for i in xrange(len(run)): - if type(run[i]) != str: - raise RelaxListStrError, ('run', run) + # The selection argument. + if selection != None and type(selection) != str: + raise RelaxNoneStrError, ('selection', selection) # Execute the functional code. - self.__relax__.generic.selection.reverse(run=run) + reverse(selection=selection)