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):
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 99 Description 100 ~~~~~~~~~~~ 101 102 The file must contain one residue number per line. The number is taken as the first column 103 of the file and all other columns are ignored. Empty lines and lines beginning with a hash 104 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 120 # Function intro test. 121 if self.__relax__.interpreter.intro: 122 text = sys.ps3 + "unselect.read(" 123 text = text + "run=" + `run` 124 text = text + ", file=" + `file` 125 text = text + ", dir=" + `dir` 126 text = text + ", change_all=" + `change_all` + ")" 127 print text 128 129 # The run argument. 130 if run != None and type(run) != str and type(run) != list: 131 raise RelaxNoneStrListError, ('run', run) 132 if type(run) == list: 133 for i in xrange(len(run)): 134 if type(run[i]) != str: 135 raise RelaxListStrError, ('run', run) 136 137 # File name. 138 if type(file) != str: 139 raise RelaxStrError, ('file name', file) 140 141 # Directory. 142 if dir != None and type(dir) != str: 143 raise RelaxNoneStrError, ('directory name', dir) 144 145 # Change all flag. 146 if type(change_all) != int or (change_all != 0 and change_all != 1): 147 raise RelaxBinError, ('change_all', change_all) 148 149 # Execute the functional code. 150 self.__relax__.generic.selection.unsel_read(run=run, file=file, dir=dir, change_all=change_all)
151 152
153 - def res(self, run=None, num=None, name=None, change_all=0):
154 """Function for unselecting specific residues. 155 156 Keyword Arguments 157 ~~~~~~~~~~~~~~~~~ 158 159 run: The name of the run(s). By supplying a single string, array of strings, or None, a 160 single run, multiple runs, or all runs will be selected respectively. 161 162 num: The residue number. 163 164 name: The residue name. 165 166 change_all: A flag specifying if all other residues should be changed. 167 168 169 Description 170 ~~~~~~~~~~~ 171 172 The residue number can be either an integer for unselecting a single residue or a python 173 regular expression, in string form, for unselecting multiple residues. For details about 174 using regular expression, see the python documentation for the module 're'. 175 176 The residue name argument must be a string. Regular expression is also allowed. 177 178 The 'change_all' flag argument default is zero meaning that all residues currently either 179 selected or unselected will remain that way. Setting the argument to 1 will cause all 180 residues not specified by 'num' or 'name' to become selected. 181 182 183 Examples 184 ~~~~~~~~ 185 186 To unselect all glycines for the run 'm5', type: 187 188 relax> unselect.res(run='m5', name='GLY|ALA') 189 relax> unselect.res(run='m5', name='[GA]L[YA]') 190 191 To unselect residue 12 MET type: 192 193 relax> unselect.res('m5', 12) 194 relax> unselect.res('m5', 12, 'MET') 195 relax> unselect.res('m5', '12') 196 relax> unselect.res('m5', '12', 'MET') 197 relax> unselect.res(run='m5', num='12', name='MET') 198 """ 199 200 # Function intro test. 201 if self.__relax__.interpreter.intro: 202 text = sys.ps3 + "unselect.res(" 203 text = text + "run=" + `run` 204 text = text + ", num=" + `num` 205 text = text + ", name=" + `name` 206 text = text + ", change_all=" + `change_all` + ")" 207 print text 208 209 # The run argument. 210 if run != None and type(run) != str and type(run) != list: 211 raise RelaxNoneStrListError, ('run', run) 212 if type(run) == list: 213 for i in xrange(len(run)): 214 if type(run[i]) != str: 215 raise RelaxListStrError, ('run', run) 216 217 # Residue number. 218 if num != None and type(num) != int and type(num) != str: 219 raise RelaxNoneIntStrError, ('residue number', num) 220 221 # Residue name. 222 if name != None and type(name) != str: 223 raise RelaxNoneStrError, ('residue name', name) 224 225 # Neither are given. 226 if num == None and name == None: 227 raise RelaxError, "At least one of the number or name arguments is required." 228 229 # Change all flag. 230 if type(change_all) != int or (change_all != 0 and change_all != 1): 231 raise RelaxBinError, ('change_all', change_all) 232 233 # Execute the functional code. 234 self.__relax__.generic.selection.unsel_res(run=run, num=num, name=name, change_all=change_all)
235 236
237 - def reverse(self, run=None):
238 """Function for the reversal of the residue selection. 239 240 Keyword Arguments 241 ~~~~~~~~~~~~~~~~~ 242 243 run: The name of the run(s). By supplying a single string, array of strings, or None, a 244 single run, multiple runs, or all runs will be selected respectively. 245 246 247 Examples 248 ~~~~~~~~ 249 250 To unselect all currently selected residues and select those which are unselected type: 251 252 relax> unselect.reverse() 253 """ 254 255 # Function intro test. 256 if self.__relax__.interpreter.intro: 257 text = sys.ps3 + "unselect.reverse(" 258 text = text + "run=" + `run` + ")" 259 print text 260 261 # The run argument. 262 if run != None and type(run) != str and type(run) != list: 263 raise RelaxNoneStrListError, ('run', run) 264 if type(run) == list: 265 for i in xrange(len(run)): 266 if type(run[i]) != str: 267 raise RelaxListStrError, ('run', run) 268 269 # Execute the functional code. 270 self.__relax__.generic.selection.reverse(run=run)
271