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

Source Code for Module user_functions.spin

  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 spin user function definitions.""" 
 25   
 26  # relax module imports. 
 27  from generic_fns.mol_res_spin import copy_spin, create_pseudo_spin, create_spin, delete_spin, display_spin, get_molecule_names, get_residue_ids, get_residue_names, get_residue_nums, get_spin_ids, id_string_doc, name_spin, number_spin, set_spin_element 
 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('spin') 
 36  uf_class.title = "Class for manipulating the spin data." 
 37  uf_class.menu_text = "&spin" 
 38  uf_class.gui_icon = "relax.spin" 
 39   
 40   
 41  # The spin.copy user function. 
 42  uf = uf_info.add_uf('spin.copy') 
 43  uf.title = "Copy all data associated with a spin." 
 44  uf.title_short = "Spin 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 spin 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 = "spin_from", 
 58      py_type = "str", 
 59      desc_short = "source spin ID", 
 60      desc = "The spin identifier string of the spin to copy the data from.", 
 61      wiz_element_type = 'combo', 
 62      wiz_combo_iter = get_spin_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 = "spin_to", 
 77      py_type = "str", 
 78      desc_short = "destination spin ID", 
 79      desc = "The spin identifier string of the spin to copy the data to.  If left blank, the new spin 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 spin to the new, non-existent spin.  The new spin must not already exist.") 
 85  # Prompt examples. 
 86  uf.desc.append(Desc_container("Prompt examples")) 
 87  uf.desc[-1].add_paragraph("To copy the spin data from spin 1 to the new spin 2, type:") 
 88  uf.desc[-1].add_prompt("relax> spin.copy(spin_from='@1', spin_to='@2')") 
 89  uf.desc[-1].add_paragraph("To copy spin 1 of the molecule 'Old mol' to spin 5 of the molecule 'New mol', type:") 
 90  uf.desc[-1].add_prompt("relax> spin.copy(spin_from='#Old mol@1', spin_to='#New mol@5')") 
 91  uf.desc[-1].add_paragraph("To copy the spin data of spin 1 from the data pipe 'm1' to 'm2', assuming the current data pipe is 'm1', type:") 
 92  uf.desc[-1].add_prompt("relax> spin.copy(spin_from='@1', pipe_to='m2')") 
 93  uf.desc[-1].add_prompt("relax> spin.copy(pipe_from='m1', spin_from='@1', pipe_to='m2', spin_to='@1')") 
 94  uf.backend = copy_spin 
 95  uf.menu_text = "&copy" 
 96  uf.gui_icon = "oxygen.actions.list-add" 
 97  uf.wizard_size = (700, 600) 
 98  uf.wizard_image = WIZARD_IMAGE_PATH + 'spin.png' 
 99   
100   
101  # The spin.create user function. 
102  uf = uf_info.add_uf('spin.create') 
103  uf.title = "Create a new spin." 
104  uf.title_short = "Spin creation." 
105  uf.display = True 
106  uf.add_keyarg( 
107      name = "spin_name", 
108      py_type = "str", 
109      desc_short = "spin name", 
110      desc = "The name of the spin.", 
111      can_be_none = True 
112  ) 
113  uf.add_keyarg( 
114      name = "spin_num", 
115      py_type = "int", 
116      min = -10000, 
117      max = 10000, 
118      desc_short = "spin number", 
119      desc = "The spin number.", 
120      can_be_none = True 
121  ) 
122  uf.add_keyarg( 
123      name = "res_name", 
124      py_type = "str", 
125      desc_short = "residue name", 
126      desc = "The name of the residue to add the spin to.", 
127      wiz_element_type = 'combo', 
128      wiz_combo_iter = get_residue_names, 
129      wiz_read_only = True, 
130      can_be_none = True 
131  ) 
132  uf.add_keyarg( 
133      name = "res_num", 
134      py_type = "int", 
135      desc_short = "residue number", 
136      desc = "The number of the residue to add the spin to.", 
137      wiz_element_type = 'combo', 
138      wiz_combo_iter = get_residue_nums, 
139      wiz_read_only = True, 
140      can_be_none = True 
141  ) 
142  uf.add_keyarg( 
143      name = "mol_name", 
144      py_type = "str", 
145      desc_short = "molecule name", 
146      desc = "The name of the molecule to add the spin to.", 
147      wiz_element_type = 'combo', 
148      wiz_combo_iter = get_molecule_names, 
149      wiz_read_only = True, 
150      can_be_none = True 
151  ) 
152  # Description. 
153  uf.desc.append(Desc_container()) 
154  uf.desc[-1].add_paragraph("This will add a new spin data container to the relax data storage object.  The same spin number cannot be used more than once.") 
155  # Prompt examples. 
156  uf.desc.append(Desc_container("Prompt examples")) 
157  uf.desc[-1].add_paragraph("The following sequence of commands will generate the sequence 1 C4, 2 C9, 3 C15:") 
158  uf.desc[-1].add_prompt("relax> spin.create(1, 'C4')") 
159  uf.desc[-1].add_prompt("relax> spin.create(2, 'C9')") 
160  uf.desc[-1].add_prompt("relax> spin.create(3, 'C15')") 
161  uf.backend = create_spin 
162  uf.menu_text = "c&reate" 
163  uf.gui_icon = "oxygen.actions.list-add-relax-blue" 
164  uf.wizard_size = (700, 500) 
165  uf.wizard_image = WIZARD_IMAGE_PATH + 'spin.png' 
166   
167   
168  # The spin.create_pseudo user function. 
169  uf = uf_info.add_uf('spin.create_pseudo') 
170  uf.title = "Create a spin system representing a pseudo-atom." 
171  uf.title_short = "Pseudo-atom creation." 
172  uf.add_keyarg( 
173      name = "spin_name", 
174      py_type = "str", 
175      desc_short = "spin name", 
176      desc = "The name of the pseudo-atom spin." 
177  ) 
178  uf.add_keyarg( 
179      name = "spin_num", 
180      py_type = "int", 
181      min = -10000, 
182      max = 10000, 
183      desc_short = "spin number", 
184      desc = "The spin number.", 
185      can_be_none = True 
186  ) 
187  uf.add_keyarg( 
188      name = "res_id", 
189      py_type = "str", 
190      desc_short = "residue ID string", 
191      desc = "The molecule and residue ID string identifying the position to add the pseudo-spin to.", 
192      wiz_element_type = 'combo', 
193      wiz_combo_iter = get_residue_ids, 
194      can_be_none = True 
195  ) 
196  uf.add_keyarg( 
197      name = "members", 
198      py_type = "str_list", 
199      desc_short = "members", 
200      desc = "A list of the atoms (as spin ID strings) that the pseudo-atom is composed of.", 
201      wiz_element_type = "combo_list", 
202      wiz_combo_iter = get_spin_ids, 
203      wiz_combo_list_min = 2, 
204      wiz_read_only = True 
205  ) 
206  uf.add_keyarg( 
207      name = "averaging", 
208      default = "linear", 
209      py_type = "str", 
210      desc_short = "positional averaging", 
211      desc = "The positional averaging technique.", 
212      wiz_element_type = "combo", 
213      wiz_combo_choices = ["linear"], 
214      wiz_read_only = True 
215  ) 
216  # Description. 
217  uf.desc.append(Desc_container()) 
218  uf.desc[-1].add_paragraph("This will create a spin data container representing a number of pre-existing spin containers as a pseudo-atom.  The optional spin number must not already exist.") 
219  uf.desc.append(id_string_doc) 
220  # Prompt examples. 
221  uf.desc.append(Desc_container("Prompt examples")) 
222  uf.desc[-1].add_paragraph("The following will create the pseudo-atom named 'Q9' consisting of the protons '@H16', '@H17', '@H18':") 
223  uf.desc[-1].add_prompt("relax> spin.create_pseudo('Q9', members=['@H16', '@H17', '@H18'])") 
224  uf.backend = create_pseudo_spin 
225  uf.menu_text = "create_p&seudo" 
226  uf.gui_icon = "oxygen.actions.list-add-relax-blue" 
227  uf.wizard_height_desc = 350 
228  uf.wizard_size = (1000, 750) 
229  uf.wizard_image = WIZARD_IMAGE_PATH + 'spin.png' 
230   
231   
232  # The spin.delete user function. 
233  uf = uf_info.add_uf('spin.delete') 
234  uf.title = "Delete spins." 
235  uf.title_short = "Spin deletion." 
236  uf.add_keyarg( 
237      name = "spin_id", 
238      py_type = "str", 
239      desc_short = "spin ID string", 
240      desc = "The spin identifier string.", 
241      wiz_element_type = 'combo', 
242      wiz_combo_iter = get_spin_ids 
243  ) 
244  # Description. 
245  uf.desc.append(Desc_container()) 
246  uf.desc[-1].add_paragraph("This can be used to delete a single or sets of spins.  See the identification string documentation below for more information.") 
247  uf.desc.append(id_string_doc) 
248  uf.backend = delete_spin 
249  uf.menu_text = "&delete" 
250  uf.gui_icon = "oxygen.actions.list-remove" 
251  uf.wizard_height_desc = 550 
252  uf.wizard_size = (900, 750) 
253  uf.wizard_image = WIZARD_IMAGE_PATH + 'spin.png' 
254   
255   
256  # The spin.display user function. 
257  uf = uf_info.add_uf('spin.display') 
258  uf.title = "Display information about the spin(s)." 
259  uf.title_short = "Spin information." 
260  uf.display = True 
261  uf.add_keyarg( 
262      name = "spin_id", 
263      py_type = "str", 
264      desc_short = "spin ID string", 
265      desc = "The spin identification string.", 
266      wiz_element_type = 'combo', 
267      wiz_combo_iter = get_spin_ids, 
268      can_be_none = True 
269  ) 
270  # Description. 
271  uf.desc.append(Desc_container()) 
272  uf.desc[-1].add_paragraph("This will display the spin data loaded into the current data pipe.") 
273  uf.desc.append(id_string_doc) 
274  uf.backend = display_spin 
275  uf.menu_text = "dis&play" 
276  uf.gui_icon = "oxygen.actions.document-preview" 
277  uf.wizard_height_desc = 550 
278  uf.wizard_size = (1000, 750) 
279  uf.wizard_apply_button = False 
280  uf.wizard_image = WIZARD_IMAGE_PATH + 'spin.png' 
281   
282   
283  # The spin.element user function. 
284  uf = uf_info.add_uf('spin.element') 
285  uf.title = "Set the element type of the spin." 
286  uf.title_short = "Spin element setting." 
287  uf.add_keyarg( 
288      name = "spin_id", 
289      py_type = "str", 
290      desc_short = "spin ID string", 
291      desc = "The spin identification string corresponding to one or more spins.", 
292      wiz_element_type = 'combo', 
293      wiz_combo_iter = get_spin_ids, 
294      can_be_none = True 
295  ) 
296  uf.add_keyarg( 
297      name = "element", 
298      py_type = "str", 
299      desc_short = "IUPAC element name", 
300      desc = "The IUPAC element name.", 
301      wiz_element_type = "combo", 
302      wiz_combo_choices = ["N", "C", "H", "O", "P"] 
303  ) 
304  uf.add_keyarg( 
305      name = "force", 
306      default = False, 
307      py_type = "bool", 
308      arg_type = "force flag", 
309      desc_short = "force flag", 
310      desc = "A flag which if True will cause the element to be changed." 
311  ) 
312  # Description. 
313  uf.desc.append(Desc_container()) 
314  uf.desc[-1].add_paragraph("This allows the element type of the spins to be set.") 
315  uf.desc.append(id_string_doc) 
316  # Prompt examples. 
317  uf.desc.append(Desc_container("Prompt examples")) 
318  uf.desc[-1].add_paragraph("The set all spins of residue 1 to be carbons, type one of:") 
319  uf.desc[-1].add_prompt("relax> spin.element('@1', 'C', force=True)") 
320  uf.desc[-1].add_prompt("relax> spin.element(spin_id='@1', element='C', force=True)") 
321  uf.backend = set_spin_element 
322  uf.menu_text = "&element" 
323  uf.gui_icon = "oxygen.actions.edit-rename" 
324  uf.wizard_height_desc = 500 
325  uf.wizard_size = (1000, 750) 
326  uf.wizard_image = WIZARD_IMAGE_PATH + 'spin.png' 
327   
328   
329  # The spin.name user function. 
330  uf = uf_info.add_uf('spin.name') 
331  uf.title = "Name the spins." 
332  uf.title_short = "Spin naming." 
333  uf.add_keyarg( 
334      name = "name", 
335      py_type = "str", 
336      desc_short = "new spin name", 
337      desc = "The new name." 
338  ) 
339  uf.add_keyarg( 
340      name = "spin_id", 
341      py_type = "str", 
342      arg_type = "spin ID", 
343      desc_short = "spin ID string", 
344      desc = "The spin identification string corresponding to one or more spins.", 
345      wiz_combo_iter = get_spin_ids, 
346      can_be_none = True 
347  ) 
348  uf.add_keyarg( 
349      name = "force", 
350      default = False, 
351      py_type = "bool", 
352      arg_type = "force flag", 
353      desc_short = "force flag", 
354      desc = "A flag which if True will cause the spin to be renamed." 
355  ) 
356  # Description. 
357  uf.desc.append(Desc_container()) 
358  uf.desc[-1].add_paragraph("This simply allows spins to be named (or renamed).  Spin naming often essential.  For example when reading Sparky peak list files, then the spin name must match that in the file.") 
359  uf.desc.append(id_string_doc) 
360  # Prompt examples. 
361  uf.desc.append(Desc_container("Prompt examples")) 
362  uf.desc[-1].add_paragraph("The following sequence of commands will rename the sequence {1 C1, 2 C2, 3 C3} to {1 C11, 2 C12, 3 C13}:") 
363  uf.desc[-1].add_prompt("relax> spin.name('@1', 'C11', force=True)") 
364  uf.desc[-1].add_prompt("relax> spin.name('@2', 'C12', force=True)") 
365  uf.desc[-1].add_prompt("relax> spin.name('@3', 'C13', force=True)") 
366  uf.backend = name_spin 
367  uf.menu_text = "&name" 
368  uf.gui_icon = "oxygen.actions.edit-rename" 
369  uf.wizard_height_desc = 500 
370  uf.wizard_size = (1000, 750) 
371  uf.wizard_image = WIZARD_IMAGE_PATH + 'spin.png' 
372   
373   
374  # The spin.number user function. 
375  uf = uf_info.add_uf('spin.number') 
376  uf.title = "Number the spins." 
377  uf.title_short = "Spin numbering." 
378  uf.add_keyarg( 
379      name = "spin_id", 
380      py_type = "str", 
381      desc_short = "spin ID string", 
382      desc = "The spin identification string corresponding to a single spin.", 
383      wiz_element_type = 'combo', 
384      wiz_combo_iter = get_spin_ids, 
385      can_be_none = True 
386  ) 
387  uf.add_keyarg( 
388      name = "number", 
389      py_type = "int", 
390      min = -10000, 
391      max = 10000, 
392      desc_short = "new spin number", 
393      desc = "The new spin number.", 
394      can_be_none = True 
395  ) 
396  uf.add_keyarg( 
397      name = "force", 
398      default = False, 
399      py_type = "bool", 
400      arg_type = "force flag", 
401      desc_short = "force flag", 
402      desc = "A flag which if True will cause the spin to be renumbered." 
403  ) 
404  # Description. 
405  uf.desc.append(Desc_container()) 
406  uf.desc[-1].add_paragraph("This simply allows spins to be numbered.  The new number cannot correspond to an existing spin number.") 
407  uf.desc.append(id_string_doc) 
408  # Prompt examples. 
409  uf.desc.append(Desc_container("Prompt examples")) 
410  uf.desc[-1].add_paragraph("The following sequence of commands will renumber the sequence {1 C1, 2 C2, 3 C3} to {-1 C1, -2 C2, -3 C3}:") 
411  uf.desc[-1].add_prompt("relax> spin.number('@1', -1, force=True)") 
412  uf.desc[-1].add_prompt("relax> spin.number('@2', -2, force=True)") 
413  uf.desc[-1].add_prompt("relax> spin.number('@3', -3, force=True)") 
414  uf.backend = number_spin 
415  uf.menu_text = "num&ber" 
416  uf.gui_icon = "oxygen.actions.edit-rename" 
417  uf.wizard_height_desc = 500 
418  uf.wizard_size = (1000, 750) 
419  uf.wizard_image = WIZARD_IMAGE_PATH + 'spin.png' 
420