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

Source Code for Module user_functions.residue

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