Package user_functions :: Module deselect
[hide private]
[frames] | no frames]

Source Code for Module user_functions.deselect

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003-2013 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program 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 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Module docstring. 
 23  """The deselect user function definitions.""" 
 24   
 25  # Python module imports. 
 26  import dep_check 
 27  if dep_check.wx_module: 
 28      from wx import FD_OPEN 
 29  else: 
 30      FD_OPEN = -1 
 31   
 32  # relax module imports. 
 33  from graphics import WIZARD_IMAGE_PATH 
 34  from pipe_control import selection 
 35  from user_functions.data import Uf_info; uf_info = Uf_info() 
 36  from user_functions.objects import Desc_container 
 37   
 38   
 39  # The user function class. 
 40  uf_class = uf_info.add_class("deselect") 
 41  uf_class.title = "Class for deselecting spins." 
 42  uf_class.menu_text = "&deselect" 
 43  uf_class.gui_icon = "relax.spin_grey" 
 44   
 45   
 46  # The deselect.all user function. 
 47  uf = uf_info.add_uf("deselect.all") 
 48  uf.title = "Deselect all spins in the current data pipe." 
 49  uf.title_short = "Deselection of all spins." 
 50  uf.display = True 
 51  # Description. 
 52  uf.desc.append(Desc_container()) 
 53  uf.desc[-1].add_paragraph("This will deselect all spins, irregardless of their current state.") 
 54  # Prompt examples. 
 55  uf.desc.append(Desc_container("Prompt examples")) 
 56  uf.desc[-1].add_paragraph("To deselect all spins, simply type:") 
 57  uf.desc[-1].add_prompt("relax> deselect.all()") 
 58  uf.backend = selection.desel_all 
 59  uf.menu_text = "&all" 
 60  uf.wizard_size = (600, 550) 
 61  uf.wizard_apply_button = False 
 62  uf.wizard_image = WIZARD_IMAGE_PATH + 'deselect.png' 
 63   
 64   
 65  # The deselect.interatom user function. 
 66  uf = uf_info.add_uf("deselect.interatom") 
 67  uf.title = "Deselect specific interatomic data containers." 
 68  uf.title_short = "Interatomic data container deselection." 
 69  uf.display = True 
 70  uf.add_keyarg( 
 71      name = "spin_id1", 
 72      py_type = "str", 
 73      arg_type = "spin ID", 
 74      desc_short = "first spin ID string", 
 75      desc = "The spin ID string of the first spin of the interatomic data container.", 
 76      can_be_none = True 
 77  ) 
 78  uf.add_keyarg( 
 79      name = "spin_id2", 
 80      py_type = "str", 
 81      arg_type = "spin ID", 
 82      desc_short = "second spin ID string", 
 83      desc = "The spin ID string of the second spin of the interatomic data container.", 
 84      can_be_none = True 
 85  ) 
 86  uf.add_keyarg( 
 87      name = "boolean", 
 88      default = "AND", 
 89      py_type = "str", 
 90      desc_short = "boolean operator", 
 91      desc = "The boolean operator specifying how interatomic data containers should be selected.", 
 92      wiz_element_type = "combo", 
 93      wiz_combo_choices = [ 
 94          "OR", 
 95          "NOR", 
 96          "AND", 
 97          "NAND", 
 98          "XOR", 
 99          "XNOR" 
100      ], 
101      wiz_read_only = True 
102  ) 
103  uf.add_keyarg( 
104      name = "change_all", 
105      default = False, 
106      py_type = "bool", 
107      desc_short = "change all", 
108      desc = "A flag specifying if all other interatomic data containers should be changed." 
109  ) 
110  # Description. 
111  uf.desc.append(Desc_container()) 
112  uf.desc[-1].add_paragraph("This is used to deselect specific interatomic data containers which store information about spin pairs such as RDCs, NOEs, dipole-dipole pairs involved in relaxation, etc.  The 'change all' flag default is False meaning that all interatomic data containers currently either selected or deselected will remain that way.  Setting this to True will cause all interatomic data containers not specified by the spin ID strings to be deselected.") 
113  uf.desc.append(selection.boolean_doc) 
114  # Prompt examples. 
115  uf.desc.append(Desc_container("Prompt examples")) 
116  uf.desc[-1].add_paragraph("To deselect all N-H backbone bond vectors of a protein, assuming these interatomic data containers have been already set up, type one of:") 
117  uf.desc[-1].add_prompt("relax> deselect.interatom('@N', '@H')") 
118  uf.desc[-1].add_prompt("relax> deselect.interatom(spin_id1='@N', spin_id2='@H')") 
119  uf.desc[-1].add_paragraph("To deselect all H-H interatomic vectors of a small organic molecule, type one of:") 
120  uf.desc[-1].add_prompt("relax> deselect.interatom('@H*', '@H*')") 
121  uf.desc[-1].add_prompt("relax> deselect.interatom(spin_id1='@H*', spin_id2='@H*')") 
122  uf.backend = selection.desel_interatom 
123  uf.menu_text = "&interatom" 
124  uf.wizard_height_desc = 450 
125  uf.wizard_size = (1000, 750) 
126  uf.wizard_image = WIZARD_IMAGE_PATH + 'deselect.png' 
127   
128   
129  # The deselect.read user function. 
130  uf = uf_info.add_uf("deselect.read") 
131  uf.title = "Deselect the spins contained in a file." 
132  uf.title_short = "Deselecting spins from file." 
133  uf.display = True 
134  uf.add_keyarg( 
135      name = "file", 
136      py_type = "str_or_inst", 
137      arg_type = "file sel", 
138      desc_short = "file name", 
139      desc = "The name of the file containing the list of spins to deselect.", 
140      wiz_filesel_style = FD_OPEN 
141  ) 
142  uf.add_keyarg( 
143      name = "dir", 
144      py_type = "str", 
145      arg_type = "dir", 
146      desc_short = "directory name", 
147      desc = "The directory where the file is located.", 
148      can_be_none = True 
149  ) 
150  uf.add_keyarg( 
151      name = "spin_id_col", 
152      py_type = "int", 
153      arg_type = "free format", 
154      desc_short = "spin ID string column", 
155      desc = "The spin ID string column (an alternative to the mol, res, and spin name and number columns).", 
156      can_be_none = True 
157  ) 
158  uf.add_keyarg( 
159      name = "mol_name_col", 
160      py_type = "int", 
161      arg_type = "free format", 
162      desc_short = "molecule name column", 
163      desc = "The molecule name column (alternative to the spin_id_col).", 
164      can_be_none = True 
165  ) 
166  uf.add_keyarg( 
167      name = "res_num_col", 
168      py_type = "int", 
169      arg_type = "free format", 
170      desc_short = "residue number column", 
171      desc = "The residue number column (alternative to the spin_id_col).", 
172      can_be_none = True 
173  ) 
174  uf.add_keyarg( 
175      name = "res_name_col", 
176      py_type = "int", 
177      arg_type = "free format", 
178      desc_short = "residue name column", 
179      desc = "The residue name column (alternative to the spin_id_col).", 
180      can_be_none = True 
181  ) 
182  uf.add_keyarg( 
183      name = "spin_num_col", 
184      py_type = "int", 
185      arg_type = "free format", 
186      desc_short = "spin number column", 
187      desc = "The spin number column (alternative to the spin_id_col).", 
188      can_be_none = True 
189  ) 
190  uf.add_keyarg( 
191      name = "spin_name_col", 
192      py_type = "int", 
193      arg_type = "free format", 
194      desc_short = "spin name column", 
195      desc = "The spin name column (alternative to the spin_id_col).", 
196      can_be_none = True 
197  ) 
198  uf.add_keyarg( 
199      name = "sep", 
200      py_type = "str", 
201      arg_type = "free format", 
202      desc_short = "column separator", 
203      desc = "The column separator (the default is white space).", 
204      can_be_none = True 
205  ) 
206  uf.add_keyarg( 
207      name = "spin_id", 
208      py_type = "str", 
209      arg_type = "spin ID", 
210      desc_short = "spin ID string", 
211      desc = "The spin ID string to restrict the loading of data to certain spin subsets.", 
212      can_be_none = True 
213  ) 
214  uf.add_keyarg( 
215      name = "boolean", 
216      default = "AND", 
217      py_type = "str", 
218      desc_short = "boolean operator", 
219      desc = "The boolean operator specifying how spins should be selected.", 
220      wiz_element_type = "combo", 
221      wiz_combo_choices = [ 
222          "OR", 
223          "NOR", 
224          "AND", 
225          "NAND", 
226          "XOR", 
227          "XNOR" 
228      ], 
229      wiz_read_only = True 
230  ) 
231  uf.add_keyarg( 
232      name = "change_all", 
233      default = False, 
234      py_type = "bool", 
235      desc_short = "change all", 
236      desc = "A flag specifying if all other spins should be changed." 
237  ) 
238  # Description. 
239  uf.desc.append(Desc_container()) 
240  uf.desc[-1].add_paragraph("The spin system can be identified in the file using two different formats.  The first is the spin ID string column which can include the molecule name, the residue name and number, and the spin name and number.  Alternatively the molecule name, residue number, residue name, spin number and/or spin name columns can be supplied allowing this information to be in separate columns.  Note that the numbering of columns starts at one.  The spin ID string can be used to restrict the reading to certain spin types, for example only 15N spins when only residue information is in the file.") 
241  uf.desc[-1].add_paragraph("Empty lines and lines beginning with a hash are ignored.") 
242  uf.desc[-1].add_paragraph("The 'change all' flag default is False meaning that all spins currently either selected or deselected will remain that way.  Setting this to True will cause all spins not specified in the file to be selected.") 
243  uf.desc.append(selection.boolean_doc) 
244  # Prompt examples. 
245  uf.desc.append(Desc_container("Prompt examples")) 
246  uf.desc[-1].add_paragraph("To deselect all overlapped residues listed with residue numbers in the first column of the file 'unresolved', type one of:") 
247  uf.desc[-1].add_prompt("relax> deselect.read('unresolved', res_num_col=1)") 
248  uf.desc[-1].add_prompt("relax> deselect.read(file='unresolved', res_num_col=1)") 
249  uf.desc[-1].add_paragraph("To deselect the spins in the second column of the relaxation data file 'r1.600' while selecting all other spins, for example type:") 
250  uf.desc[-1].add_prompt("relax> deselect.read('r1.600', spin_num_col=2, change_all=True)") 
251  uf.desc[-1].add_prompt("relax> deselect.read(file='r1.600', spin_num_col=2, change_all=True)") 
252  uf.backend = selection.desel_read 
253  uf.menu_text = "&read" 
254  uf.gui_icon = "oxygen.actions.document-open" 
255  uf.wizard_height_desc = 400 
256  uf.wizard_size = (1000, 750) 
257  uf.wizard_image = WIZARD_IMAGE_PATH + 'deselect.png' 
258   
259   
260  # The deselect.reverse user function. 
261  uf = uf_info.add_uf("deselect.reverse") 
262  uf.title = "Reversal of the spin selection for the given spins." 
263  uf.title_short = "Spin selection reversal." 
264  uf.display = True 
265  uf.add_keyarg( 
266      name = "spin_id", 
267      py_type = "str", 
268      desc_short = "spin ID string", 
269      desc = "The spin ID string.", 
270      can_be_none = True 
271  ) 
272  # Description. 
273  uf.desc.append(Desc_container()) 
274  uf.desc[-1].add_paragraph("By supplying the spin ID string, a subset of spins can have their selection status reversed.") 
275  # Description. 
276  uf.desc.append(Desc_container()) 
277  uf.desc[-1].add_paragraph("To deselect all currently selected spins and select those which are deselected type:") 
278  uf.desc[-1].add_prompt("relax> deselect.reverse()") 
279  uf.backend = selection.reverse 
280  uf.menu_text = "re&verse" 
281  uf.gui_icon = "oxygen.actions.system-switch-user" 
282  uf.wizard_size = (700, 550) 
283  uf.wizard_apply_button = False 
284  uf.wizard_image = WIZARD_IMAGE_PATH + 'deselect.png' 
285   
286   
287  # The deselect.spin user function. 
288  uf = uf_info.add_uf("deselect.spin") 
289  uf.title = "Deselect specific spins." 
290  uf.title_short = "Spin deselection." 
291  uf.display = True 
292  uf.add_keyarg( 
293      name = "spin_id", 
294      py_type = "str", 
295      desc_short = "spin ID string", 
296      desc = "The spin ID string.", 
297      can_be_none = True 
298  ) 
299  uf.add_keyarg( 
300      name = "boolean", 
301      default = "AND", 
302      py_type = "str", 
303      desc_short = "boolean operator", 
304      desc = "The boolean operator specifying how spins should be deselected.", 
305      wiz_element_type = "combo", 
306      wiz_combo_choices = [ 
307          "OR", 
308          "NOR", 
309          "AND", 
310          "NAND", 
311          "XOR", 
312          "XNOR" 
313      ], 
314      wiz_read_only = True 
315  ) 
316  uf.add_keyarg( 
317      name = "change_all", 
318      default = False, 
319      py_type = "bool", 
320      desc_short = "change all", 
321      desc = "A flag specifying if all other spins should be changed." 
322  ) 
323  # Description. 
324  uf.desc.append(Desc_container()) 
325  uf.desc[-1].add_paragraph("The 'change all' flag default is False meaning that all spins currently either selected or deselected will remain that way.  Setting this to True will cause all spins not specified by the spin ID string to be deselected.") 
326  uf.desc.append(selection.boolean_doc) 
327  # Prompt examples. 
328  uf.desc.append(Desc_container("Prompt examples")) 
329  uf.desc[-1].add_paragraph("To deselect all glycines and alanines, type:") 
330  uf.desc[-1].add_prompt("relax> deselect.spin(spin_id=':GLY|:ALA')") 
331  uf.desc[-1].add_paragraph("To deselect residue 12 MET type:") 
332  uf.desc[-1].add_prompt("relax> deselect.spin(':12')") 
333  uf.desc[-1].add_prompt("relax> deselect.spin(spin_id=':12')") 
334  uf.desc[-1].add_prompt("relax> deselect.spin(spin_id=':12&:MET')") 
335  uf.backend = selection.desel_spin 
336  uf.menu_text = "&spin" 
337  uf.gui_icon = "relax.spin_grey" 
338  uf.wizard_height_desc = 500 
339  uf.wizard_size = (1000, 750) 
340  uf.wizard_image = WIZARD_IMAGE_PATH + 'deselect.png' 
341