Author: bugman Date: Thu Dec 7 07:17:29 2006 New Revision: 2924 URL: http://svn.gna.org/viewcvs/relax?rev=2924&view=rev Log: You can now specify a different column for residue numbers in the selection user functions. This affects both the 'select.read()' and 'unselect.read()' user functions. Modified: 1.3/generic_fns/selection.py 1.3/prompt/select.py 1.3/prompt/unselect.py Modified: 1.3/generic_fns/selection.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/selection.py?rev=2924&r1=2923&r2=2924&view=diff ============================================================================== --- 1.3/generic_fns/selection.py (original) +++ 1.3/generic_fns/selection.py Thu Dec 7 07:17:29 2006 @@ -93,7 +93,7 @@ select = [] for i in xrange(len(file_data)): try: - select.append(int(file_data[i][0])) + select.append(int(file_data[i][column])) except: raise RelaxError, "Improperly formatted file." @@ -217,7 +217,7 @@ self.relax.data.res[self.run][i].select = 0 - def unsel_read(self, run=None, file=None, dir=None, change_all=None): + def unsel_read(self, run=None, file=None, dir=None, change_all=None, column=None): """Function for unselecting the residues contained in a file.""" # Extract the data from the file. @@ -230,7 +230,7 @@ unselect = [] for i in xrange(len(file_data)): try: - unselect.append(int(file_data[i][0])) + unselect.append(int(file_data[i][column])) except: raise RelaxError, "Improperly formatted file." Modified: 1.3/prompt/select.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/select.py?rev=2924&r1=2923&r2=2924&view=diff ============================================================================== --- 1.3/prompt/select.py (original) +++ 1.3/prompt/select.py Thu Dec 7 07:17:29 2006 @@ -80,7 +80,7 @@ self.__relax__.generic.selection.sel_all(run=run) - def read(self, run=None, file=None, dir=None, change_all=0): + def read(self, run=None, file=None, dir=None, change_all=0, column=0): """Function for selecting the residues contained in a file. Keyword Arguments @@ -94,14 +94,14 @@ dir: The directory where the file is located. change_all: A flag specifying if all other residues should be changed. + + column: The column containing the residue numbers (defaulting to 0, the first column). Description ~~~~~~~~~~~ - The file must contain one residue number per line. The number is taken as the first column - of the file and all other columns are ignored. Empty lines and lines beginning with a hash - are ignored. + Empty lines and lines beginning with a hash are ignored. The 'change_all' flag argument default is zero meaning that all residues currently either selected or unselected will remain that way. Setting the argument to 1 will cause all @@ -111,10 +111,16 @@ Examples ~~~~~~~~ - To select all residues in the file 'isolated_peaks', type: + To select all residues in the file 'isolated_peaks', type one of: relax> select.read('noe', 'isolated_peaks') relax> select.read(run='noe', file='isolated_peaks') + + To select the residues in the second column of the relaxation data file 'r1.600' while + deselecting all other residues, type one of: + + relax> select.read('test', 'r1.600', change_all=1, column=1) + relax> select.read(run='test', file='r1.600', change_all=1, column=1) """ # Function intro test. @@ -123,7 +129,8 @@ text = text + "run=" + `run` text = text + ", file=" + `file` text = text + ", dir=" + `dir` - text = text + ", change_all=" + `change_all` + ")" + text = text + ", change_all=" + `change_all` + text = text + ", column=" + `column` + ")" print text # The run argument. @@ -146,8 +153,12 @@ if type(change_all) != int or (change_all != 0 and change_all != 1): raise RelaxBinError, ('change_all', change_all) - # Execute the functional code. - self.__relax__.generic.selection.sel_read(run=run, file=file, dir=dir, change_all=change_all) + # The residue column. + if type(column) != int: + raise RelaxIntError, ('residue number column', column) + + # Execute the functional code. + self.__relax__.generic.selection.sel_read(run=run, file=file, dir=dir, change_all=change_all, column=column) def res(self, run=None, num=None, name=None, change_all=0): Modified: 1.3/prompt/unselect.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/unselect.py?rev=2924&r1=2923&r2=2924&view=diff ============================================================================== --- 1.3/prompt/unselect.py (original) +++ 1.3/prompt/unselect.py Thu Dec 7 07:17:29 2006 @@ -80,7 +80,7 @@ self.__relax__.generic.selection.unsel_all(run=run) - def read(self, run=None, file=None, dir=None, change_all=0): + def read(self, run=None, file=None, dir=None, change_all=0, column=0): """Function for unselecting the residues contained in a file. Keyword Arguments @@ -94,14 +94,14 @@ dir: The directory where the file is located. change_all: A flag specifying if all other residues should be changed. + + column: The column containing the residue numbers (defaulting to 0, the first column). Description ~~~~~~~~~~~ - The file must contain one residue number per line. The number is taken as the first column - of the file and all other columns are ignored. Empty lines and lines beginning with a hash - are ignored. + Empty lines and lines beginning with a hash are ignored. The 'change_all' flag argument default is zero meaning that all residues currently either selected or unselected will remain that way. Setting the argument to 1 will cause all @@ -115,6 +115,12 @@ relax> unselect.read('noe', 'unresolved') relax> unselect.read(run='noe', file='unresolved') + + To unselect the residues in the second column of the relaxation data file 'r1.600' while + selecting all other residues, type one of: + + relax> unselect.read('test', 'r1.600', change_all=1, column=1) + relax> unselect.read(run='test', file='r1.600', change_all=1, column=1) """ # Function intro test. @@ -123,7 +129,8 @@ text = text + "run=" + `run` text = text + ", file=" + `file` text = text + ", dir=" + `dir` - text = text + ", change_all=" + `change_all` + ")" + text = text + ", change_all=" + `change_all` + text = text + ", column=" + `column` + ")" print text # The run argument. @@ -146,8 +153,12 @@ if type(change_all) != int or (change_all != 0 and change_all != 1): raise RelaxBinError, ('change_all', change_all) - # Execute the functional code. - self.__relax__.generic.selection.unsel_read(run=run, file=file, dir=dir, change_all=change_all) + # The residue column. + if type(column) != int: + raise RelaxIntError, ('residue number column', column) + + # Execute the functional code. + self.__relax__.generic.selection.unsel_read(run=run, file=file, dir=dir, change_all=change_all, column=column) def res(self, run=None, num=None, name=None, change_all=0):