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

Source Code for Module user_functions.molecule

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007-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 molecule 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 ALLOWED_MOL_TYPES, copy_molecule, create_molecule, delete_molecule, display_molecule, get_molecule_ids, id_string_doc, name_molecule, type_molecule 
 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('molecule') 
 35  uf_class.title = "Class for manipulating the molecule data." 
 36  uf_class.menu_text = "&molecule" 
 37  uf_class.gui_icon = "relax.molecule" 
 38   
 39   
 40  # The molecule.copy user function. 
 41  uf = uf_info.add_uf('molecule.copy') 
 42  uf.title = "Copy all data associated with a molecule." 
 43  uf.title_short = "Molecule copying." 
 44  uf.display = True 
 45  uf.add_keyarg( 
 46      name = "pipe_from", 
 47      py_type = "str", 
 48      desc_short = "source data pipe", 
 49      desc = "The data pipe containing the molecule 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 = "mol_from", 
 57      py_type = "str", 
 58      desc_short = "source molecule ID", 
 59      desc = "The name of the molecule from which to copy data from.", 
 60      wiz_element_type = 'combo', 
 61      wiz_combo_iter = get_molecule_ids, 
 62      wiz_read_only = True 
 63  ) 
 64  uf.add_keyarg( 
 65      name = "pipe_to", 
 66      py_type = "str", 
 67      desc_short = "destination data 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 = "mol_to", 
 76      py_type = "str", 
 77      desc_short = "destination molecule ID", 
 78      desc = "The name of the new molecule.  If left blank, the new molecule will have the same name as the old.  This needs to be a molecule ID string, starting with '#'.", 
 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 a molecule to a second molecule.  This includes all residue and spin system information.  The new molecule name must be unique in the destination data pipe.") 
 84  uf.desc.append(id_string_doc) 
 85  # Prompt examples. 
 86  uf.desc.append(Desc_container("Prompt examples")) 
 87  uf.desc[-1].add_paragraph("To copy the molecule data from the molecule 'GST' to the new molecule 'wt-GST', type:") 
 88  uf.desc[-1].add_prompt("relax> molecule.copy('#GST', '#wt-GST')") 
 89  uf.desc[-1].add_prompt("relax> molecule.copy(mol_from='#GST', mol_to='#wt-GST')") 
 90  uf.desc[-1].add_paragraph("To copy the molecule data of the molecule 'Ap4Aase' from the data pipe 'm1' to 'm2', assuming the current data pipe is 'm1', type:") 
 91  uf.desc[-1].add_prompt("relax> molecule.copy(mol_from='#ApAase', pipe_to='m2')") 
 92  uf.desc[-1].add_prompt("relax> molecule.copy(pipe_from='m1', mol_from='#ApAase', pipe_to='m2', mol_to='#ApAase')") 
 93  uf.backend = copy_molecule 
 94  uf.menu_text = "&copy" 
 95  uf.gui_icon = "oxygen.actions.list-add" 
 96  uf.wizard_height_desc = 600 
 97  uf.wizard_size = (1000, 750) 
 98  uf.wizard_image = WIZARD_IMAGE_PATH + 'molecule.png' 
 99   
100   
101  # The molecule.create user function. 
102  uf = uf_info.add_uf('molecule.create') 
103  uf.title = "Create a new molecule." 
104  uf.title_short = "Molecule creation." 
105  uf.display = True 
106  uf.add_keyarg( 
107      name = "mol_name", 
108      py_type = "str", 
109      desc_short = "molecule name", 
110      desc = "The name of the new molecule." 
111  ) 
112  uf.add_keyarg( 
113      name = "mol_type", 
114      py_type = "str", 
115      desc_short = "molecule type", 
116      desc = "The type of molecule.", 
117      wiz_element_type = "combo", 
118      wiz_combo_choices = ALLOWED_MOL_TYPES, 
119      wiz_read_only = True, 
120      can_be_none = True 
121  ) 
122  # Description. 
123  uf.desc.append(Desc_container()) 
124  text = "This adds a new molecule data container to the relax data storage object.  The same molecule name cannot be used more than once.  The molecule type need not be specified.  However, if given, it should be one of" 
125  for i in range(len(ALLOWED_MOL_TYPES)-1): 
126      text += " '%s'," % ALLOWED_MOL_TYPES[i] 
127  text += " or '%s'." % ALLOWED_MOL_TYPES[-1] 
128  uf.desc[-1].add_paragraph(text) 
129  # Prompt examples. 
130  uf.desc.append(Desc_container("Prompt examples")) 
131  uf.desc[-1].add_paragraph("To create the molecules 'Ap4Aase', 'ATP', and 'MgF4', type:") 
132  uf.desc[-1].add_prompt("relax> molecule.create('Ap4Aase')") 
133  uf.desc[-1].add_prompt("relax> molecule.create('ATP')") 
134  uf.desc[-1].add_prompt("relax> molecule.create('MgF4')") 
135  uf.backend = create_molecule 
136  uf.menu_text = "c&reate" 
137  uf.gui_icon = "oxygen.actions.list-add-relax-blue" 
138  uf.wizard_size = (700, 500) 
139  uf.wizard_image = WIZARD_IMAGE_PATH + 'molecule.png' 
140   
141   
142  # The molecule.delete user function. 
143  uf = uf_info.add_uf('molecule.delete') 
144  uf.title = "Deleting molecules from the relax data store." 
145  uf.title_short = "Molecule deletion." 
146  uf.add_keyarg( 
147      name = "mol_id", 
148      py_type = "str", 
149      desc_short = "molecule ID string", 
150      desc = "The molecule ID string.", 
151      wiz_element_type = 'combo', 
152      wiz_combo_iter = get_molecule_ids, 
153      wiz_read_only = True 
154  ) 
155  # Description. 
156  uf.desc.append(Desc_container()) 
157  uf.desc[-1].add_paragraph("This can be used to delete a single or sets of molecules from the relax data store.  The molecule will be deleted from the current data pipe.") 
158  uf.desc.append(id_string_doc) 
159  uf.backend = delete_molecule 
160  uf.menu_text = "&delete" 
161  uf.gui_icon = "oxygen.actions.list-remove" 
162  uf.wizard_height_desc = 550 
163  uf.wizard_size = (900, 750) 
164  uf.wizard_image = WIZARD_IMAGE_PATH + 'molecule.png' 
165   
166   
167  # The molecule.display user function. 
168  uf = uf_info.add_uf('molecule.display') 
169  uf.title = "Display the molecule information." 
170  uf.title_short = "Molecule information." 
171  uf.display = True 
172  uf.add_keyarg( 
173      name = "mol_id", 
174      py_type = "str", 
175      desc_short = "molecule ID string", 
176      desc = "The molecule ID string.", 
177      wiz_element_type = 'combo', 
178      wiz_combo_iter = get_molecule_ids, 
179      wiz_read_only = True, 
180      can_be_none = True 
181  ) 
182  uf.desc.append(id_string_doc) 
183  uf.backend = display_molecule 
184  uf.menu_text = "dis&play" 
185  uf.gui_icon = "oxygen.actions.document-preview" 
186  uf.wizard_height_desc = 400 
187  uf.wizard_size = (900, 600) 
188  uf.wizard_apply_button = False 
189  uf.wizard_image = WIZARD_IMAGE_PATH + 'molecule.png' 
190   
191   
192  # The molecule.name user function. 
193  uf = uf_info.add_uf('molecule.name') 
194  uf.title = "Name a molecule." 
195  uf.add_keyarg( 
196      name = "mol_id", 
197      py_type = "str", 
198      desc_short = "molecule ID string", 
199      desc = "The molecule ID string corresponding to one or more molecules.", 
200      wiz_element_type = 'combo', 
201      wiz_combo_iter = get_molecule_ids, 
202      wiz_read_only = True, 
203      can_be_none = True 
204  ) 
205  uf.add_keyarg( 
206      name = "name", 
207      py_type = "str", 
208      desc_short = "new molecule name", 
209      desc = "The new molecule name." 
210  ) 
211  uf.add_keyarg( 
212      name = "force", 
213      default = False, 
214      py_type = "bool", 
215      arg_type = "force flag", 
216      desc_short = "force flag", 
217      desc = "A flag which if True will cause the molecule to be renamed." 
218  ) 
219  # Description. 
220  uf.desc.append(Desc_container()) 
221  uf.desc[-1].add_paragraph("This simply allows molecules to be named (or renamed).") 
222  # Prompt examples. 
223  uf.desc.append(Desc_container("Prompt examples")) 
224  uf.desc[-1].add_paragraph("To rename the molecule 'Ap4Aase' to 'Inhib Ap4Aase', type one of:") 
225  uf.desc[-1].add_prompt("relax> molecule.name('#Ap4Aase', 'Inhib Ap4Aase', True)") 
226  uf.desc[-1].add_prompt("relax> molecule.name(mol_id='#Ap4Aase', name='Inhib Ap4Aase', force=True)") 
227  uf.desc[-1].add_paragraph("This assumes the molecule 'Ap4Aase' already exists.") 
228  uf.desc.append(id_string_doc) 
229  uf.backend = name_molecule 
230  uf.menu_text = "&name" 
231  uf.gui_icon = "oxygen.actions.edit-rename" 
232  uf.wizard_height_desc = 550 
233  uf.wizard_size = (1000, 720) 
234  uf.wizard_image = WIZARD_IMAGE_PATH + 'molecule.png' 
235   
236   
237  # The molecule.type user function. 
238  uf = uf_info.add_uf('molecule.type') 
239  uf.title = "Set the molecule type." 
240  uf.title_short = "Setting molecule type." 
241  uf.add_keyarg( 
242      name = "mol_id", 
243      py_type = "str", 
244      desc_short = "molecule ID string", 
245      desc = "The molecule ID string corresponding to one or more molecules.", 
246      wiz_element_type = 'combo', 
247      wiz_combo_iter = get_molecule_ids, 
248      wiz_read_only = True, 
249      can_be_none = True 
250  ) 
251  uf.add_keyarg( 
252      name = "type", 
253      py_type = "str", 
254      desc_short = "molecule type", 
255      desc = "The molecule type.", 
256      wiz_element_type = "combo", 
257      wiz_combo_choices = ALLOWED_MOL_TYPES, 
258      wiz_read_only = True 
259  ) 
260  uf.add_keyarg( 
261      name = "force", 
262      default = False, 
263      py_type = "bool", 
264      arg_type = "force flag", 
265      desc_short = "force flag", 
266      desc = "A flag which if True will cause the molecule to type to be overwritten." 
267  ) 
268  # Description. 
269  uf.desc.append(Desc_container()) 
270  uf.desc[-1].add_paragraph("This allows the type of the molecule to be specified.  It can be one of:") 
271  for i in range(len(ALLOWED_MOL_TYPES)-1): 
272      uf.desc[-1].add_list_element("'%s'," % ALLOWED_MOL_TYPES[i]) 
273  uf.desc[-1].add_list_element("'%s'." % ALLOWED_MOL_TYPES[-1]) 
274  # Prompt examples. 
275  uf.desc.append(Desc_container("Prompt examples")) 
276  uf.desc[-1].add_paragraph("To set the molecule 'Ap4Aase' to the 'protein' type, type one of:") 
277  uf.desc[-1].add_prompt("relax> molecule.type('#Ap4Aase', 'protein', True)") 
278  uf.desc[-1].add_prompt("relax> molecule.type(mol_id='#Ap4Aase', type='protein', force=True)") 
279  uf.desc.append(id_string_doc) 
280  uf.backend = type_molecule 
281  uf.menu_text = "&type" 
282  uf.gui_icon = "oxygen.actions.edit-rename" 
283  uf.wizard_height_desc = 600 
284  uf.wizard_size = (1000, 750) 
285  uf.wizard_image = WIZARD_IMAGE_PATH + 'molecule.png' 
286