1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import sys
24
25 import help
26
27
29 __boolean_doc = """
30 Boolean operators
31 ~~~~~~~~~~~~~~~~~
32
33 The 'boolean' keyword argument can be used to change how spin systems are selected. The
34 allowed values are: 'OR', 'NOR', 'AND', 'NAND', 'XOR', 'XNOR'. The following table details
35 how the selections will occur for the different boolean operators.
36 __________________________________________________________
37 | | | | | | | | | | |
38 | Spin system | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
39 |____________________|___|___|___|___|___|___|___|___|___|
40 | | | | | | | | | | |
41 | Original selection | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 1 |
42 | | | | | | | | | | |
43 | New selection | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
44 |____________________|___|___|___|___|___|___|___|___|___|
45 | | | | | | | | | | |
46 | OR | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 |
47 | | | | | | | | | | |
48 | NOR | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
49 | | | | | | | | | | |
50 | AND | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
51 | | | | | | | | | | |
52 | NAND | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
53 | | | | | | | | | | |
54 | XOR | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
55 | | | | | | | | | | |
56 | XNOR | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 1 | 0 |
57 |____________________|___|___|___|___|___|___|___|___|___|
58 """
59
60
62
63 self.__relax_help__ = \
64 """Class for selecting residues."""
65
66
67 self.__relax_help__ = self.__relax_help__ + "\n" + help.relax_class_help
68
69
70 self.__relax__ = relax
71
72
73 - def all(self, run=None):
74 """Function for selecting all residues.
75
76 Keyword Arguments
77 ~~~~~~~~~~~~~~~~~
78
79 run: The name of the run(s). By supplying a single string, array of strings, or None, a
80 single run, multiple runs, or all runs will be selected respectively.
81
82
83 Examples
84 ~~~~~~~~
85
86 To select all residues for all runs type:
87
88 relax> select.all()
89
90
91 To select all residues for the run 'srls_m1', type:
92
93 relax> select.all('srls_m1')
94 relax> select.all(run='srls_m1')
95 """
96
97
98 if self.__relax__.interpreter.intro:
99 text = sys.ps3 + "select.all("
100 text = text + "run=" + `run` + ")"
101 print text
102
103
104 if run != None and type(run) != str and type(run) != list:
105 raise RelaxNoneStrListError, ('run', run)
106 if type(run) == list:
107 for i in xrange(len(run)):
108 if type(run[i]) != str:
109 raise RelaxListStrError, ('run', run)
110
111
112 self.__relax__.generic.selection.sel_all(run=run)
113
114
115 - def read(self, run=None, file=None, dir=None, boolean='OR', change_all=0, column=0):
116 """Function for selecting the residues contained in a file.
117
118 Keyword Arguments
119 ~~~~~~~~~~~~~~~~~
120
121 run: The name of the run(s). By supplying a single string, array of strings, or None, a
122 single run, multiple runs, or all runs will be selected respectively.
123
124 file: The name of the file containing the list of residues to select.
125
126 dir: The directory where the file is located.
127
128 boolean: The boolean operator specifying how residues should be selected.
129
130 change_all: A flag specifying if all other residues should be changed.
131
132 column: The column containing the residue numbers (defaulting to 0, the first column).
133
134
135 Description
136 ~~~~~~~~~~~
137
138 Empty lines and lines beginning with a hash are ignored.
139
140 The 'change_all' flag argument default is zero meaning that all residues currently either
141 selected or unselected will remain that way. Setting the argument to 1 will cause all
142 residues not specified in the file to be unselected.
143
144
145 Examples
146 ~~~~~~~~
147
148 To select all residues in the file 'isolated_peaks', type one of:
149
150 relax> select.read('noe', 'isolated_peaks')
151 relax> select.read(run='noe', file='isolated_peaks')
152
153 To select the residues in the second column of the relaxation data file 'r1.600' while
154 deselecting all other residues, type one of:
155
156 relax> select.read('test', 'r1.600', change_all=1, column=1)
157 relax> select.read(run='test', file='r1.600', change_all=1, column=1)
158 """
159
160
161 if self.__relax__.interpreter.intro:
162 text = sys.ps3 + "select.read("
163 text = text + "run=" + `run`
164 text = text + ", file=" + `file`
165 text = text + ", dir=" + `dir`
166 text = text + ", boolean=" + `boolean`
167 text = text + ", change_all=" + `change_all`
168 text = text + ", column=" + `column` + ")"
169 print text
170
171
172 if run != None and type(run) != str and type(run) != list:
173 raise RelaxNoneStrListError, ('run', run)
174 if type(run) == list:
175 for i in xrange(len(run)):
176 if type(run[i]) != str:
177 raise RelaxListStrError, ('run', run)
178
179
180 if type(file) != str:
181 raise RelaxStrError, ('file name', file)
182
183
184 if dir != None and type(dir) != str:
185 raise RelaxNoneStrError, ('directory name', dir)
186
187
188 if type(boolean) != str:
189 raise RelaxStrError, ('boolean operator', boolean)
190
191
192 if type(change_all) != int or (change_all != 0 and change_all != 1):
193 raise RelaxBinError, ('change_all', change_all)
194
195
196 if type(column) != int:
197 raise RelaxIntError, ('residue number column', column)
198
199
200 self.__relax__.generic.selection.sel_read(run=run, file=file, dir=dir, boolean=boolean, change_all=change_all, column=column)
201
202
203 - def res(self, run=None, num=None, name=None, boolean='OR', change_all=0):
204 """Function for selecting specific residues.
205
206 Keyword Arguments
207 ~~~~~~~~~~~~~~~~~
208
209 run: The name of the run(s). By supplying a single string, array of strings, or None, a
210 single run, multiple runs, or all runs will be selected respectively.
211
212 num: The residue number.
213
214 name: The residue name.
215
216 boolean: The boolean operator specifying how residues should be selected.
217
218 change_all: A flag specifying if all other residues should be changed.
219
220
221 Description
222 ~~~~~~~~~~~
223
224 The residue number can be either an integer for selecting a single residue or a python
225 regular expression, in string form, for selecting multiple residues. For details about
226 using regular expression, see the python documentation for the module 're'.
227
228 The residue name argument must be a string. Regular expression is also allowed.
229
230 The 'change_all' flag argument default is zero meaning that all residues currently either
231 selected or unselected will remain that way. Setting the argument to 1 will cause all
232 residues not specified by 'num' or 'name' to become unselected.
233
234
235 Examples
236 ~~~~~~~~
237
238 To select only glycines and alanines for the run 'm3', assuming they have been loaded with
239 the names GLY and ALA, type:
240
241 relax> select.res(run='m3', name='GLY|ALA', change_all=1)
242 relax> select.res(run='m3', name='[GA]L[YA]', change_all=1)
243
244 To select residue 5 CYS in addition to the currently selected residues, type:
245
246 relax> select.res('m3', 5)
247 relax> select.res('m3', 5, 'CYS')
248 relax> select.res('m3', '5')
249 relax> select.res('m3', '5', 'CYS')
250 relax> select.res(run='m3', num='5', name='CYS')
251 """
252
253
254 if self.__relax__.interpreter.intro:
255 text = sys.ps3 + "select.res("
256 text = text + "run=" + `run`
257 text = text + ", num=" + `num`
258 text = text + ", name=" + `name`
259 text = text + ", boolean=" + `boolean`
260 text = text + ", change_all=" + `change_all` + ")"
261 print text
262
263
264 if run != None and type(run) != str and type(run) != list:
265 raise RelaxNoneStrListError, ('run', run)
266 if type(run) == list:
267 for i in xrange(len(run)):
268 if type(run[i]) != str:
269 raise RelaxListStrError, ('run', run)
270
271
272 if num != None and type(num) != int and type(num) != str:
273 raise RelaxNoneIntStrError, ('residue number', num)
274
275
276 if name != None and type(name) != str:
277 raise RelaxNoneStrError, ('residue name', name)
278
279
280 if num == None and name == None:
281 raise RelaxError, "At least one of the number or name arguments is required."
282
283
284 if type(boolean) != str:
285 raise RelaxStrError, ('boolean operator', boolean)
286
287
288 if type(change_all) != int or (change_all != 0 and change_all != 1):
289 raise RelaxBinError, ('change_all', change_all)
290
291
292 self.__relax__.generic.selection.sel_res(run=run, num=num, name=name, boolean=boolean, change_all=change_all)
293
294
296 """Function for the reversal of the residue selection.
297
298 Keyword Arguments
299 ~~~~~~~~~~~~~~~~~
300
301 run: The name of the run(s). By supplying a single string, array of strings, or None, a
302 single run, multiple runs, or all runs will be selected respectively.
303
304
305 Examples
306 ~~~~~~~~
307
308 To unselect all currently selected residues and select those which are unselected type:
309
310 relax> select.reverse()
311 """
312
313
314 if self.__relax__.interpreter.intro:
315 text = sys.ps3 + "select.reverse("
316 text = text + "run=" + `run` + ")"
317 print text
318
319
320 if run != None and type(run) != str and type(run) != list:
321 raise RelaxNoneStrListError, ('run', run)
322 if type(run) == list:
323 for i in xrange(len(run)):
324 if type(run[i]) != str:
325 raise RelaxListStrError, ('run', run)
326
327
328 self.__relax__.generic.selection.reverse(run=run)
329
330
331
332
333
334
335
336 read.__doc__ = read.__doc__ + "\n\n" + __boolean_doc + "\n"
337