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
30
31 self.__relax_help__ = \
32 """Class for selecting residues."""
33
34
35 self.__relax_help__ = self.__relax_help__ + "\n" + help.relax_class_help
36
37
38 self.__relax__ = relax
39
40
41 - def all(self, run=None):
42 """Function for selecting 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 select all residues for all runs type:
55
56 relax> select.all()
57
58
59 To select 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
66 if self.__relax__.interpreter.intro:
67 text = sys.ps3 + "select.all("
68 text = text + "run=" + `run` + ")"
69 print text
70
71
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
80 self.__relax__.generic.selection.sel_all(run=run)
81
82
83 - def read(self, run=None, file=None, dir=None, change_all=0):
84 """Function for selecting 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 select.
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 unselected.
109
110
111 Examples
112 ~~~~~~~~
113
114 To select all residues in the file 'isolated_peaks', type:
115
116 relax> select.read('noe', 'isolated_peaks')
117 relax> select.read(run='noe', file='isolated_peaks')
118 """
119
120
121 if self.__relax__.interpreter.intro:
122 text = sys.ps3 + "select.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
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
138 if type(file) != str:
139 raise RelaxStrError, ('file name', file)
140
141
142 if dir != None and type(dir) != str:
143 raise RelaxNoneStrError, ('directory name', dir)
144
145
146 if type(change_all) != int or (change_all != 0 and change_all != 1):
147 raise RelaxBinError, ('change_all', change_all)
148
149
150 self.__relax__.generic.selection.sel_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 selecting 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 selecting a single residue or a python
173 regular expression, in string form, for selecting 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 unselected.
181
182
183 Examples
184 ~~~~~~~~
185
186 To select only glycines and alanines for the run 'm3', assuming they have been loaded with
187 the names GLY and ALA, type:
188
189 relax> select.res(run='m3', name='GLY|ALA', change_all=1)
190 relax> select.res(run='m3', name='[GA]L[YA]', change_all=1)
191
192 To select residue 5 CYS in addition to the currently selected residues, type:
193
194 relax> select.res('m3', 5)
195 relax> select.res('m3', 5, 'CYS')
196 relax> select.res('m3', '5')
197 relax> select.res('m3', '5', 'CYS')
198 relax> select.res(run='m3', num='5', name='CYS')
199 """
200
201
202 if self.__relax__.interpreter.intro:
203 text = sys.ps3 + "select.res("
204 text = text + "run=" + `run`
205 text = text + ", num=" + `num`
206 text = text + ", name=" + `name`
207 text = text + ", change_all=" + `change_all` + ")"
208 print text
209
210
211 if run != None and type(run) != str and type(run) != list:
212 raise RelaxNoneStrListError, ('run', run)
213 if type(run) == list:
214 for i in xrange(len(run)):
215 if type(run[i]) != str:
216 raise RelaxListStrError, ('run', run)
217
218
219 if num != None and type(num) != int and type(num) != str:
220 raise RelaxNoneIntStrError, ('residue number', num)
221
222
223 if name != None and type(name) != str:
224 raise RelaxNoneStrError, ('residue name', name)
225
226
227 if num == None and name == None:
228 raise RelaxError, "At least one of the number or name arguments is required."
229
230
231 if type(change_all) != int or (change_all != 0 and change_all != 1):
232 raise RelaxBinError, ('change_all', change_all)
233
234
235 self.__relax__.generic.selection.sel_res(run=run, num=num, name=name, change_all=change_all)
236
237
239 """Function for the reversal of the residue selection.
240
241 Keyword Arguments
242 ~~~~~~~~~~~~~~~~~
243
244 run: The name of the run(s). By supplying a single string, array of strings, or None, a
245 single run, multiple runs, or all runs will be selected respectively.
246
247
248 Examples
249 ~~~~~~~~
250
251 To unselect all currently selected residues and select those which are unselected type:
252
253 relax> select.reverse()
254 """
255
256
257 if self.__relax__.interpreter.intro:
258 text = sys.ps3 + "select.reverse("
259 text = text + "run=" + `run` + ")"
260 print text
261
262
263 if run != None and type(run) != str and type(run) != list:
264 raise RelaxNoneStrListError, ('run', run)
265 if type(run) == list:
266 for i in xrange(len(run)):
267 if type(run[i]) != str:
268 raise RelaxListStrError, ('run', run)
269
270
271 self.__relax__.generic.selection.reverse(run=run)
272