Package user_functions :: Module residue'
[hide private]
[frames] | no frames]

Source Code for Module user_functions.residue'

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007-2012 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  # Module docstring. 
 24  """The residue user function definitions.""" 
 25   
 26  # relax module imports. 
 27  from generic_fns.mol_res_spin import copy_residue, create_residue, delete_residue, display_residue, get_molecule_ids, get_molecule_names, get_residue_ids, id_string_doc, name_residue, number_residue 
 28  from generic_fns import pipes 
 29  from graphics import WIZARD_IMAGE_PATH 
 30  from user_functions.data import Uf_info; uf_info = Uf_info() 
 31  from user_functions.objects import Desc_container 
 32   
 33   
 34  # The user function class. 
 35  uf_class = uf_info.add_class('residue') 
 36  uf_class.title = "Class for manipulating the residue data." 
 37  uf_class.menu_text = "&residue" 
 38  uf_class.gui_icon = "relax.residue" 
 39   
 40   
 41  # The residue.copy user function. 
 42  uf = uf_info.add_uf('residue.copy') 
 43  uf.title = "Copy all data associated with a residue." 
 44  uf.title_short = "Residue copying." 
 45  uf.display = True 
 46  uf.add_keyarg( 
 47      name = "pipe_from", 
 48      py_type = "str", 
 49      desc_short = "source pipe", 
 50      desc = "The data pipe containing the residue from which the data will be copied.  This defaults to the current data pipe.", 
 51      wiz_element_type = 'combo', 
 52      wiz_combo_iter = pipes.pipe_names, 
 53      wiz_read_only = True, 
 54      can_be_none = True 
 55  ) 
 56  uf.add_keyarg( 
 57      name = "res_from", 
 58      py_type = "str", 
 59      desc_short = "source residue ID", 
 60      desc = "The residue ID string of the residue to copy the data from.", 
 61      wiz_element_type = 'combo', 
 62      wiz_combo_iter = get_residue_ids, 
 63      wiz_read_only = True 
 64  ) 
 65  uf.add_keyarg( 
 66      name = "pipe_to", 
 67      py_type = "str", 
 68      desc_short = "destination pipe", 
 69      desc = "The data pipe to copy the data to.  This defaults to the current data pipe.", 
 70      wiz_element_type = 'combo', 
 71      wiz_combo_iter = pipes.pipe_names, 
 72      wiz_read_only = True, 
 73      can_be_none = True 
 74  ) 
 75  uf.add_keyarg( 
 76      name = "res_to", 
 77      py_type = "str", 
 78      desc_short = "destination residue ID", 
 79      desc = "The residue ID string of the residue to copy the data to.  If left blank, the new residue will have the same name as the old.", 
 80      can_be_none = True 
 81  ) 
 82  # Description. 
 83  uf.desc.append(Desc_container()) 
 84  uf.desc[-1].add_paragraph("This will copy all the data associated with the identified residue to the new, non-existent residue.  The new residue cannot currently exist.") 
 85  # Prompt examples. 
 86  uf.desc.append(Desc_container("Prompt examples")) 
 87  uf.desc[-1].add_paragraph("To copy the residue data from residue 1 to the new residue 2, type:") 
 88  uf.desc[-1].add_prompt("relax> residue.copy(res_from=':1', res_to=':2')") 
 89  uf.desc[-1].add_paragraph("To copy residue 1 of the molecule 'Old mol' to residue 5 of the molecule 'New mol', type:") 
 90  uf.desc[-1].add_prompt("relax> residue.copy(res_from='#Old mol:1', res_to='#New mol:5')") 
 91  uf.desc[-1].add_paragraph("To copy the residue data of residue 1 from the data pipe 'm1' to 'm2', assuming the current data pipe is 'm1', type:") 
 92  uf.desc[-1].add_prompt("relax> residue.copy(res_from=':1', pipe_to='m2')") 
 93  uf.desc[-1].add_prompt("relax> residue.copy(pipe_from='m1', res_from=':1', pipe_to='m2', res_to=':1')") 
 94  uf.backend = copy_residue 
 95  uf.menu_text = "&copy" 
 96  uf.gui_icon = "oxygen.actions.list-add" 
 97  uf.wizard_size = (800, 600) 
 98  uf.wizard_image = WIZARD_IMAGE_PATH + 'residue.png' 
 99   
100   
101  # The residue.create user function. 
102  uf = uf_info.add_uf('residue.create') 
103  uf.title = "Create a new residue." 
104  uf.title_short = "Residue creation." 
105  uf.display = True 
106  uf.add_keyarg( 
107      name = "res_num", 
108      py_type = "int", 
109      min = -10000, 
110      max = 10000, 
111      desc_short = "residue number", 
112      desc = "The residue number.", 
113      can_be_none = True 
114  ) 
115  uf.add_keyarg( 
116      name = "res_name", 
117      py_type = "str", 
118      desc_short = "residue name", 
119      desc = "The name of the residue.", 
120      can_be_none = True 
121  ) 
122  uf.add_keyarg( 
123      name = "mol_name", 
124      py_type = "str", 
125      desc_short = "molecule name", 
126      desc = "The name of the molecule to add the residue to.", 
127      wiz_element_type = 'combo', 
128      wiz_combo_iter = get_molecule_names, 
129      wiz_read_only = True, 
130      can_be_none = True 
131  ) 
132  # Description. 
133  uf.desc.append(Desc_container()) 
134  uf.desc[-1].add_paragraph("Using this, a new sequence can be generated without using the sequence user functions.  However if the sequence already exists, the new residue will be added to the end of the residue list (the residue numbers of this list need not be sequential).  The same residue number cannot be used more than once.  A corresponding single spin system will be created for this residue.  The spin system number and name or additional spin systems can be added later if desired.") 
135  # Prompt examples. 
136  uf.desc.append(Desc_container("Prompt examples")) 
137  uf.desc[-1].add_paragraph("The following sequence of commands will generate the sequence 1 ALA, 2 GLY, 3 LYS:") 
138  uf.desc[-1].add_prompt("relax> residue.create(1, 'ALA')") 
139  uf.desc[-1].add_prompt("relax> residue.create(2, 'GLY')") 
140  uf.desc[-1].add_prompt("relax> residue.create(3, 'LYS')") 
141  uf.backend = create_residue 
142  uf.menu_text = "c&reate" 
143  uf.gui_icon = "oxygen.actions.list-add-relax-blue" 
144  uf.wizard_size = (700, 500) 
145  uf.wizard_image = WIZARD_IMAGE_PATH + 'residue.png' 
146   
147   
148  # The residue.delete user function. 
149  uf = uf_info.add_uf('residue.delete') 
150  uf.title = "Delete residues from the current data pipe." 
151  uf.title_short = "Residue deletion." 
152  uf.add_keyarg( 
153      name = "res_id", 
154      py_type = "str", 
155      desc_short = "residue ID string", 
156      desc = "The residue ID string.", 
157      wiz_element_type = 'combo', 
158      wiz_combo_iter = get_residue_ids, 
159      wiz_read_only = True 
160  ) 
161  # Description. 
162  uf.desc.append(Desc_container()) 
163  uf.desc[-1].add_paragraph("This can be used to delete a single or sets of residues.  See the ID string documentation for more information.  If spin system/atom ids are included a RelaxError will be raised.") 
164  uf.desc.append(id_string_doc) 
165  uf.backend = delete_residue 
166  uf.menu_text = "&delete" 
167  uf.gui_icon = "oxygen.actions.list-remove" 
168  uf.wizard_height_desc = 550 
169  uf.wizard_size = (900, 750) 
170  uf.wizard_image = WIZARD_IMAGE_PATH + 'residue.png' 
171   
172   
173  # The residue.display user function. 
174  uf = uf_info.add_uf('residue.display') 
175  uf.title = "Display information about the residue(s)." 
176  uf.display = True 
177  uf.add_keyarg( 
178      name = "res_id", 
179      py_type = "str", 
180      desc_short = "residue ID string", 
181      desc = "The residue ID string.", 
182      wiz_element_type = 'combo', 
183      wiz_combo_iter = get_residue_ids, 
184      wiz_read_only = True, 
185      can_be_none = True 
186  ) 
187  # Description. 
188  uf.desc.append(Desc_container()) 
189  uf.desc[-1].add_paragraph("This will display the residue data loaded into the current data pipe.") 
190  uf.desc.append(id_string_doc) 
191  uf.backend = display_residue 
192  uf.menu_text = "dis&play" 
193  uf.gui_icon = "oxygen.actions.document-preview" 
194  uf.wizard_height_desc = 550 
195  uf.wizard_size = (1000, 750) 
196  uf.wizard_apply_button = False 
197  uf.wizard_image = WIZARD_IMAGE_PATH + 'residue.png' 
198   
199   
200  # The residue.name user function. 
201  uf = uf_info.add_uf('residue.name') 
202  uf.title = "Name the residues." 
203  uf.title_short = "Residue naming." 
204  uf.add_keyarg( 
205      name = "res_id", 
206      py_type = "str", 
207      desc_short = "residue ID string", 
208      desc = "The residue ID string corresponding to one or more residues.", 
209      wiz_element_type = 'combo', 
210      wiz_combo_iter = get_residue_ids, 
211      wiz_read_only = True 
212  ) 
213  uf.add_keyarg( 
214      name = "name", 
215      py_type = "str", 
216      desc_short = "new residue name", 
217      desc = "The new name." 
218  ) 
219  uf.add_keyarg( 
220      name = "force", 
221      default = False, 
222      py_type = "bool", 
223      arg_type = "force flag", 
224      desc_short = "force flag", 
225      desc = "A flag which if True will cause the residue to be renamed." 
226  ) 
227  # Description. 
228  uf.desc.append(Desc_container()) 
229  uf.desc[-1].add_paragraph("This simply allows residues to be named (or renamed).") 
230  uf.desc.append(id_string_doc) 
231  # Prompt examples. 
232  uf.desc.append(Desc_container("Prompt examples")) 
233  uf.desc[-1].add_paragraph("The following sequence of commands will rename the sequence {1 ALA, 2 GLY, 3 LYS} to {1 XXX, 2 XXX, 3 XXX}:") 
234  uf.desc[-1].add_prompt("relax> residue.name(':1', 'XXX', force=True)") 
235  uf.desc[-1].add_prompt("relax> residue.name(':2', 'XXX', force=True)") 
236  uf.desc[-1].add_prompt("relax> residue.name(':3', 'XXX', force=True)") 
237  uf.desc[-1].add_paragraph("Alternatively:") 
238  uf.desc[-1].add_prompt("relax> residue.name(':1,2,3', 'XXX', force=True)") 
239  uf.backend = name_residue 
240  uf.menu_text = "&name" 
241  uf.gui_icon = "oxygen.actions.edit-rename" 
242  uf.wizard_height_desc = 500 
243  uf.wizard_size = (1000, 750) 
244  uf.wizard_image = WIZARD_IMAGE_PATH + 'residue.png' 
245   
246   
247  # The residue.number user function. 
248  uf = uf_info.add_uf('residue.number') 
249  uf.title = "Number the residues." 
250  uf.title_short = "Residue numbering." 
251  uf.add_keyarg( 
252      name = "res_id", 
253      py_type = "str", 
254      desc_short = "residue ID string", 
255      desc = "The residue ID string corresponding to a single residue.", 
256      wiz_element_type = 'combo', 
257      wiz_combo_iter = get_residue_ids, 
258      wiz_read_only = True 
259  ) 
260  uf.add_keyarg( 
261      name = "number", 
262      py_type = "int", 
263      min = -10000, 
264      max = 10000, 
265      desc_short = "new residue number", 
266      desc = "The new residue number." 
267  ) 
268  uf.add_keyarg( 
269      name = "force", 
270      default = False, 
271      py_type = "bool", 
272      arg_type = "force flag", 
273      desc_short = "force flag", 
274      desc = "A flag which if True will cause the residue to be renumbered." 
275  ) 
276  # Description. 
277  uf.desc.append(Desc_container()) 
278  uf.desc[-1].add_paragraph("This simply allows residues to be numbered.  The new number cannot correspond to an existing residue.") 
279  uf.desc.append(id_string_doc) 
280  # Prompt examples. 
281  uf.desc.append(Desc_container("Prompt examples")) 
282  uf.desc[-1].add_paragraph("The following sequence of commands will renumber the sequence {1 ALA, 2 GLY, 3 LYS} to {101 ALA, 102 GLY, 103 LYS}:") 
283  uf.desc[-1].add_prompt("relax> residue.number(':1', 101, force=True)") 
284  uf.desc[-1].add_prompt("relax> residue.number(':2', 102, force=True)") 
285  uf.desc[-1].add_prompt("relax> residue.number(':3', 103, force=True)") 
286  uf.backend = number_residue 
287  uf.menu_text = "&number" 
288  uf.gui_icon = "oxygen.actions.edit-rename" 
289  uf.wizard_height_desc = 500 
290  uf.wizard_size = (1000, 750) 
291  uf.wizard_image = WIZARD_IMAGE_PATH + 'residue.png' 
292