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

Source Code for Module user_functions.molecule'

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