Package prompt :: Module unselect
[hide private]
[frames] | no frames]

Source Code for Module prompt.unselect

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003, 2004 Edward d'Auvergne                                  # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  import sys 
 24   
 25  import help 
 26   
 27   
28 -class Unselect:
29 - def __init__(self, relax):
30 # Help. 31 self.__relax_help__ = \ 32 """Class for unselecting residues.""" 33 34 # Add the generic help string. 35 self.__relax_help__ = self.__relax_help__ + "\n" + help.relax_class_help 36 37 # Place relax in the class namespace. 38 self.__relax__ = relax
39 40
41 - def all(self, run=None):
42 """Function for unselecting all residues. 43 44 Keyword Arguments 45 ~~~~~~~~~~~~~~~~~ 46 47 run: The name of the run(s). By supplying a single string, array of strings, or None, a 48 single run, multiple runs, or all runs will be selected respectively. 49 50 51 Examples 52 ~~~~~~~~ 53 54 To unselect all residues type: 55 56 relax> unselect.all() 57 58 59 To unselect all residues for the run 'srls_m1', type: 60 61 relax> select.all('srls_m1') 62 relax> select.all(run='srls_m1') 63 """ 64 65 # Function intro test. 66 if self.__relax__.interpreter.intro: 67 text = sys.ps3 + "unselect.all(" 68 text = text + "run=" + `run` + ")" 69 print text 70 71 # The run argument. 72 if run != None and type(run) != str and type(run) != list: 73 raise RelaxNoneStrListError, ('run', run) 74 if type(run) == list: 75 for i in xrange(len(run)): 76 if type(run[i]) != str: 77 raise RelaxListStrError, ('run', run) 78 79 # Execute the functional code. 80 self.__relax__.generic.selection.unsel_all(run=run)
81 82
83 - def read(self, run=None, file=None, dir=None, change_all=0, column=0):
84 """Function for unselecting the residues contained in a file. 85 86 Keyword Arguments 87 ~~~~~~~~~~~~~~~~~ 88 89 run: The name of the run(s). By supplying a single string, array of strings, or None, a 90 single run, multiple runs, or all runs will be selected respectively. 91 92 file: The name of the file containing the list of residues to unselect. 93 94 dir: The directory where the file is located. 95 96 change_all: A flag specifying if all other residues should be changed. 97 98 column: The column containing the residue numbers (defaulting to 0, the first column). 99 100 101 Description 102 ~~~~~~~~~~~ 103 104 Empty lines and lines beginning with a hash are ignored. 105 106 The 'change_all' flag argument default is zero meaning that all residues currently either 107 selected or unselected will remain that way. Setting the argument to 1 will cause all 108 residues not specified in the file to be selected. 109 110 111 Examples 112 ~~~~~~~~ 113 114 To unselect all overlapped residues in the file 'unresolved', type: 115 116 relax> unselect.read('noe', 'unresolved') 117 relax> unselect.read(run='noe', file='unresolved') 118 119 To unselect the residues in the second column of the relaxation data file 'r1.600' while 120 selecting all other residues, type one of: 121 122 relax> unselect.read('test', 'r1.600', change_all=1, column=1) 123 relax> unselect.read(run='test', file='r1.600', change_all=1, column=1) 124 """ 125 126 # Function intro test. 127 if self.__relax__.interpreter.intro: 128 text = sys.ps3 + "unselect.read(" 129 text = text + "run=" + `run` 130 text = text + ", file=" + `file` 131 text = text + ", dir=" + `dir` 132 text = text + ", change_all=" + `change_all` 133 text = text + ", column=" + `column` + ")" 134 print text 135 136 # The run argument. 137 if run != None and type(run) != str and type(run) != list: 138 raise RelaxNoneStrListError, ('run', run) 139 if type(run) == list: 140 for i in xrange(len(run)): 141 if type(run[i]) != str: 142 raise RelaxListStrError, ('run', run) 143 144 # File name. 145 if type(file) != str: 146 raise RelaxStrError, ('file name', file) 147 148 # Directory. 149 if dir != None and type(dir) != str: 150 raise RelaxNoneStrError, ('directory name', dir) 151 152 # Change all flag. 153 if type(change_all) != int or (change_all != 0 and change_all != 1): 154 raise RelaxBinError, ('change_all', change_all) 155 156 # The residue column. 157 if type(column) != int: 158 raise RelaxIntError, ('residue number column', column) 159 160 # Execute the functional code. 161 self.__relax__.generic.selection.unsel_read(run=run, file=file, dir=dir, change_all=change_all, column=column)
162 163
164 - def res(self, run=None, num=None, name=None, change_all=0):
165 """Function for unselecting specific residues. 166 167 Keyword Arguments 168 ~~~~~~~~~~~~~~~~~ 169 170 run: The name of the run(s). By supplying a single string, array of strings, or None, a 171 single run, multiple runs, or all runs will be selected respectively. 172 173 num: The residue number. 174 175 name: The residue name. 176 177 change_all: A flag specifying if all other residues should be changed. 178 179 180 Description 181 ~~~~~~~~~~~ 182 183 The residue number can be either an integer for unselecting a single residue or a python 184 regular expression, in string form, for unselecting multiple residues. For details about 185 using regular expression, see the python documentation for the module 're'. 186 187 The residue name argument must be a string. Regular expression is also allowed. 188 189 The 'change_all' flag argument default is zero meaning that all residues currently either 190 selected or unselected will remain that way. Setting the argument to 1 will cause all 191 residues not specified by 'num' or 'name' to become selected. 192 193 194 Examples 195 ~~~~~~~~ 196 197 To unselect all glycines for the run 'm5', type: 198 199 relax> unselect.res(run='m5', name='GLY|ALA') 200 relax> unselect.res(run='m5', name='[GA]L[YA]') 201 202 To unselect residue 12 MET type: 203 204 relax> unselect.res('m5', 12) 205 relax> unselect.res('m5', 12, 'MET') 206 relax> unselect.res('m5', '12') 207 relax> unselect.res('m5', '12', 'MET') 208 relax> unselect.res(run='m5', num='12', name='MET') 209 """ 210 211 # Function intro test. 212 if self.__relax__.interpreter.intro: 213 text = sys.ps3 + "unselect.res(" 214 text = text + "run=" + `run` 215 text = text + ", num=" + `num` 216 text = text + ", name=" + `name` 217 text = text + ", change_all=" + `change_all` + ")" 218 print text 219 220 # The run argument. 221 if run != None and type(run) != str and type(run) != list: 222 raise RelaxNoneStrListError, ('run', run) 223 if type(run) == list: 224 for i in xrange(len(run)): 225 if type(run[i]) != str: 226 raise RelaxListStrError, ('run', run) 227 228 # Residue number. 229 if num != None and type(num) != int and type(num) != str: 230 raise RelaxNoneIntStrError, ('residue number', num) 231 232 # Residue name. 233 if name != None and type(name) != str: 234 raise RelaxNoneStrError, ('residue name', name) 235 236 # Neither are given. 237 if num == None and name == None: 238 raise RelaxError, "At least one of the number or name arguments is required." 239 240 # Change all flag. 241 if type(change_all) != int or (change_all != 0 and change_all != 1): 242 raise RelaxBinError, ('change_all', change_all) 243 244 # Execute the functional code. 245 self.__relax__.generic.selection.unsel_res(run=run, num=num, name=name, change_all=change_all)
246 247
248 - def reverse(self, run=None):
249 """Function for the reversal of the residue selection. 250 251 Keyword Arguments 252 ~~~~~~~~~~~~~~~~~ 253 254 run: The name of the run(s). By supplying a single string, array of strings, or None, a 255 single run, multiple runs, or all runs will be selected respectively. 256 257 258 Examples 259 ~~~~~~~~ 260 261 To unselect all currently selected residues and select those which are unselected type: 262 263 relax> unselect.reverse() 264 """ 265 266 # Function intro test. 267 if self.__relax__.interpreter.intro: 268 text = sys.ps3 + "unselect.reverse(" 269 text = text + "run=" + `run` + ")" 270 print text 271 272 # The run argument. 273 if run != None and type(run) != str and type(run) != list: 274 raise RelaxNoneStrListError, ('run', run) 275 if type(run) == list: 276 for i in xrange(len(run)): 277 if type(run[i]) != str: 278 raise RelaxListStrError, ('run', run) 279 280 # Execute the functional code. 281 self.__relax__.generic.selection.reverse(run=run)
282