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

Source Code for Module user_functions.pipe

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2004-2012 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 pipe user function definitions.""" 
 24   
 25  # relax module imports. 
 26  from graphics import WIZARD_IMAGE_PATH 
 27  from generic_fns import pipes 
 28  from specific_fns.setup import hybrid_obj 
 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('pipe') 
 35  uf_class.title = "Class holding the user functions for manipulating data pipes." 
 36  uf_class.menu_text = "&pipe" 
 37  uf_class.gui_icon = "relax.pipe" 
 38   
 39   
 40  # The pipe.bundle user function. 
 41  uf = uf_info.add_uf('pipe.bundle') 
 42  uf.title = "The grouping of data pipes into a bundle." 
 43  uf.title_short = "Data pipe bundling." 
 44  uf.add_keyarg( 
 45      name = "bundle", 
 46      py_type = "str", 
 47      desc_short = "pipe bundle", 
 48      desc = "The pipe bundle is a special grouping or clustering of data pipes.", 
 49      wiz_element_type = 'combo', 
 50      wiz_combo_iter = pipes.bundle_names, 
 51      wiz_read_only = False 
 52  ) 
 53  uf.add_keyarg( 
 54      name = "pipe", 
 55      py_type = "str", 
 56      desc_short = "data pipe", 
 57      desc = "The name of the data pipe to add to the bundle.", 
 58      wiz_element_type = 'combo', 
 59      wiz_combo_iter = pipes.pipe_names, 
 60      wiz_read_only = True 
 61  ) 
 62  # Description. 
 63  uf.desc.append(Desc_container()) 
 64  uf.desc[-1].add_paragraph("Data pipes can be grouped or clustered together through special structures known as pipe bundles.  If the specified data pipe bundle does not currently exist, it will be created.") 
 65  # Prompt examples. 
 66  uf.desc.append(Desc_container("Prompt examples")) 
 67  uf.desc[-1].add_paragraph("To add the data pipes 'test 1', 'test 2', and 'test 3' to the bundle 'first analysis', type the following:") 
 68  uf.desc[-1].add_prompt("relax> pipe.bundle('first analysis 1', 'test 1')") 
 69  uf.desc[-1].add_prompt("relax> pipe.bundle('first analysis 1', 'test 2')") 
 70  uf.desc[-1].add_prompt("relax> pipe.bundle('first analysis 1', 'test 3')") 
 71  uf.backend = pipes.bundle 
 72  uf.menu_text = "&bundle" 
 73  uf.gui_icon = "relax.pipe_bundle" 
 74  uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe_bundle.png' 
 75   
 76           
 77  # The pipe.change_type user function. 
 78  uf = uf_info.add_uf('pipe.change_type') 
 79  uf.title = "Change the type of the current data pipe." 
 80  uf.title_short = "Data pipe type change." 
 81  uf.add_keyarg( 
 82      name = "pipe_type", 
 83      py_type = "str", 
 84      desc_short = "type of data pipe", 
 85      desc = "The type of data pipe.", 
 86      wiz_element_type = 'combo', 
 87      wiz_combo_choices = pipes.PIPE_DESC_LIST, 
 88      wiz_combo_data = pipes.VALID_TYPES, 
 89      wiz_read_only = True 
 90  ) 
 91  uf.backend = pipes.change_type 
 92  # Description. 
 93  uf.desc.append(Desc_container()) 
 94  uf.desc[-1].add_paragraph("The data pipe type must be one of the following:") 
 95  for name in pipes.VALID_TYPES: 
 96      uf.desc[-1].add_item_list_element("'%s'" % name, "%s." % pipes.PIPE_DESC[name]) 
 97  # Prompt examples. 
 98  uf.desc.append(Desc_container("Prompt examples")) 
 99  uf.desc[-1].add_paragraph("To change the type of the current 'frame order' data pipe to the N-state model, type one of:") 
100  uf.desc[-1].add_prompt("relax> pipe.change_type('N-state')") 
101  uf.desc[-1].add_prompt("relax> pipe.change_type(pipe_type='N-state')") 
102  uf.menu_text = "change_&type" 
103  uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe.png' 
104   
105   
106  # The pipe.copy user function. 
107  uf = uf_info.add_uf('pipe.copy') 
108  uf.title = "Copy a data pipe." 
109  uf.title_short = "Data pipe copying." 
110  uf.add_keyarg( 
111      name = "pipe_from", 
112      py_type = "str", 
113      desc_short = "source data pipe", 
114      desc = "The name of the source data pipe to copy the data from.", 
115      wiz_element_type = 'combo', 
116      wiz_combo_iter = pipes.pipe_names, 
117      wiz_read_only = True, 
118      can_be_none = True 
119  ) 
120  uf.add_keyarg( 
121      name = "pipe_to", 
122      py_type = "str", 
123      desc_short = "destination data pipe", 
124      desc = "The name of the target data pipe to copy the data to.", 
125      can_be_none = True 
126  ) 
127  uf.add_keyarg( 
128      name = "bundle_to", 
129      py_type = "str", 
130      desc_short = "destination pipe bundle", 
131      desc = "If given, the new data pipe will be grouped into this bundle.", 
132      wiz_element_type = 'combo', 
133      wiz_combo_iter = pipes.bundle_names, 
134      wiz_read_only = False, 
135      can_be_none = True 
136  ) 
137  # Description. 
138  uf.desc.append(Desc_container()) 
139  uf.desc[-1].add_paragraph("This allows the contents of a data pipe to be copied.  If the source data pipe is not set, the current data pipe will be assumed.  The target data pipe must not yet exist.") 
140  uf.desc[-1].add_paragraph("The optional bundling allows the newly created data pipe to be placed into either a new or existing data pipe bundle.  If not specified, then the copied data pipe will not be associated with a bundle.") 
141  # Prompt examples. 
142  uf.desc.append(Desc_container("Prompt examples")) 
143  uf.desc[-1].add_paragraph("To copy the contents of the 'm1' data pipe to the 'm2' data pipe, type:") 
144  uf.desc[-1].add_prompt("relax> pipe.copy('m1', 'm2')") 
145  uf.desc[-1].add_prompt("relax> pipe.copy(pipe_from='m1', pipe_to='m2')") 
146  uf.desc[-1].add_paragraph("If the current data pipe is 'm1', then the following command can be used:") 
147  uf.desc[-1].add_prompt("relax> pipe.copy(pipe_to='m2')") 
148  uf.backend = pipes.copy 
149  uf.menu_text = "&copy" 
150  uf.gui_icon = "oxygen.actions.list-add" 
151  uf.wizard_size = (800, 500) 
152  uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe.png' 
153   
154   
155  # The pipe.create user function. 
156  uf = uf_info.add_uf('pipe.create') 
157  uf.title = "Add a new data pipe to the relax data store." 
158  uf.title_short = "Data pipe creation." 
159  uf.add_keyarg( 
160      name = "pipe_name", 
161      py_type = "str", 
162      desc_short = "data pipe name", 
163      desc = "The name of the data pipe.", 
164  ) 
165  uf.add_keyarg( 
166      name = "pipe_type", 
167      py_type = "str", 
168      desc_short = "type of data pipe", 
169      desc = "The type of data pipe.", 
170      wiz_element_type = 'combo', 
171      wiz_combo_choices = pipes.PIPE_DESC_LIST, 
172      wiz_combo_data = pipes.VALID_TYPES, 
173      wiz_read_only = True 
174  ) 
175  uf.add_keyarg( 
176      name = "bundle", 
177      py_type = "str", 
178      desc_short = "pipe bundle", 
179      desc = "The optional pipe bundle is a special grouping or clustering of data pipes.  If this is specified, the newly created data pipe will be added to this bundle.", 
180      wiz_element_type = 'combo', 
181      wiz_combo_iter = pipes.bundle_names, 
182      wiz_read_only = False, 
183      can_be_none = True 
184  ) 
185  uf.backend = pipes.create 
186  # Description. 
187  uf.desc.append(Desc_container()) 
188  uf.desc[-1].add_paragraph("The data pipe name can be any string however the data pipe type can only be one of the following:") 
189  uf.desc[-1].add_item_list_element("'ct'", "Consistency testing,") 
190  uf.desc[-1].add_item_list_element("'frame order'", "The Frame Order theories,") 
191  uf.desc[-1].add_item_list_element("'jw'", "Reduced spectral density mapping,") 
192  uf.desc[-1].add_item_list_element("'hybrid'", "A special hybrid pipe,") 
193  uf.desc[-1].add_item_list_element("'mf'", "Model-free analysis,") 
194  uf.desc[-1].add_item_list_element("'N-state'", "N-state model of domain motions,") 
195  uf.desc[-1].add_item_list_element("'noe'", "Steady state NOE calculation,") 
196  uf.desc[-1].add_item_list_element("'relax_fit'", "Relaxation curve fitting,") 
197  uf.desc[-1].add_paragraph("The pipe bundling concept is simply a way of grouping data pipes together.  This is useful for a number of purposes:") 
198  uf.desc[-1].add_list_element("The grouping or categorisation of data pipes, for example when multiple related analyses are performed.") 
199  uf.desc[-1].add_list_element("In the auto-analyses, as all the data pipes that they spawn are bound together within the original bundle.") 
200  uf.desc[-1].add_list_element("In the graphical user interface mode as analysis tabs are linked to specific pipe bundles.") 
201  # Prompt examples. 
202  uf.desc.append(Desc_container("Prompt examples")) 
203  uf.desc[-1].add_paragraph("To set up a model-free analysis data pipe with the name 'm5', type:") 
204  uf.desc[-1].add_prompt("relax> pipe.create('m5', 'mf')") 
205  uf.menu_text = "crea&te" 
206  uf.gui_icon = "oxygen.actions.list-add-relax-blue" 
207  uf.wizard_height_desc = 500 
208  uf.wizard_size = (1000, 750) 
209  uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe.png' 
210   
211   
212  # The pipe.current user function. 
213  uf = uf_info.add_uf('pipe.current') 
214  uf.title = "Print the name of the current data pipe." 
215  uf.title_short = "Current data pipe printing." 
216  uf.display = True 
217  uf.backend = pipes.current 
218  # Prompt examples. 
219  uf.desc.append(Desc_container("Prompt examples")) 
220  uf.desc[-1].add_paragraph("To run the user function, type:") 
221  uf.desc[-1].add_prompt("relax> pipe.current()") 
222  uf.menu_text = "c&urrent" 
223  uf.gui_icon = "oxygen.actions.document-preview" 
224  uf.wizard_size = (600, 300) 
225  uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe.png' 
226   
227   
228  # The pipe.delete user function. 
229  uf = uf_info.add_uf('pipe.delete') 
230  uf.title = "Delete a data pipe from the relax data store." 
231  uf.title_short = "Data pipe deletion." 
232  uf.add_keyarg( 
233      name = "pipe_name", 
234      py_type = "str", 
235      desc_short = "data pipe", 
236      desc = "The name of the data pipe to delete.", 
237      wiz_element_type = 'combo', 
238      wiz_combo_iter = pipes.pipe_names, 
239      can_be_none = True 
240  ) 
241  # Description. 
242  uf.desc.append(Desc_container()) 
243  uf.desc[-1].add_paragraph("This will permanently remove the data pipe and all of its contents from the relax data store.  If the pipe name is not given, then all data pipes will be deleted.") 
244  uf.backend = pipes.delete 
245  uf.menu_text = "&delete" 
246  uf.gui_icon = "oxygen.actions.list-remove" 
247  uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe.png' 
248  uf.gui_sync = True    # Force synchronous operation to avoid the GUI from blowing up. 
249   
250   
251  # The pipe.display user function. 
252  uf = uf_info.add_uf('pipe.display') 
253  uf.title = "Print a list of all the data pipes." 
254  uf.title_short = "Data pipe listing." 
255  uf.display = True 
256  uf.backend = pipes.display 
257  # Prompt examples. 
258  uf.desc.append(Desc_container("Prompt examples")) 
259  uf.desc[-1].add_paragraph("To run the user function, type:") 
260  uf.desc[-1].add_prompt("relax> pipe.display()") 
261  uf.menu_text = "di&splay" 
262  uf.gui_icon = "oxygen.actions.document-preview" 
263  uf.wizard_size = (600, 300) 
264  uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe.png' 
265   
266   
267  # The pipe.hybridise user function. 
268  uf = uf_info.add_uf('pipe.hybridise') 
269  uf.title = "Create a hybrid data pipe by fusing a number of other data pipes." 
270  uf.title_short = "Hybrid data pipe creation." 
271  uf.add_keyarg( 
272      name = "hybrid", 
273      py_type = "str", 
274      desc_short = "hybrid pipe name", 
275      desc = "The name of the hybrid data pipe to create." 
276  ) 
277  uf.add_keyarg( 
278      name = "pipes", 
279      py_type = "str_list", 
280      desc_short = "data pipes to hybridise", 
281      desc = "An array containing the names of all data pipes to hybridise.", 
282      wiz_element_type = 'combo_list', 
283      wiz_combo_iter = pipes.pipe_names, 
284      wiz_combo_list_min = 2 
285  ) 
286  uf.backend = hybrid_obj._hybridise 
287  # Description. 
288  uf.desc.append(Desc_container()) 
289  uf.desc[-1].add_paragraph("This user function can be used to construct hybrid models.  An example of the use of a hybrid model could be if the protein consists of two independent domains.  These two domains could be analysed separately, each having their own optimised diffusion tensors.  The N-terminal domain data pipe could be called 'N_sphere' while the C-terminal domain could be called 'C_ellipsoid'.  These two data pipes could then be hybridised into a single data pipe.  This hybrid data pipe can then be compared via model selection to a data pipe whereby the entire protein is assumed to have a single diffusion tensor.") 
290  uf.desc[-1].add_paragraph("The requirements for data pipes to be hybridised is that the molecules, sequences, and spin systems for all the data pipes is the same, and that no spin system is allowed to be selected in two or more data pipes.  The selections must not overlap to allow for rigorous statistical comparisons.") 
291  # Prompt examples. 
292  uf.desc.append(Desc_container("Prompt examples")) 
293  uf.desc[-1].add_paragraph("The two data pipes 'N_sphere' and 'C_ellipsoid' could be hybridised into a single data pipe called 'mixed model' by typing:") 
294  uf.desc[-1].add_prompt("relax> pipe.hybridise('mixed model', ['N_sphere', 'C_ellipsoid'])") 
295  uf.desc[-1].add_prompt("relax> pipe.hybridise(hybrid='mixed model', pipes=['N_sphere', 'C_ellipsoid'])") 
296  uf.menu_text = "&hybridise" 
297  uf.gui_icon = "relax.pipe_hybrid" 
298  uf.wizard_height_desc = 350 
299  uf.wizard_size = (1000, 750) 
300  uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe_hybrid.png' 
301   
302   
303  # The pipe.switch user function. 
304  uf = uf_info.add_uf('pipe.switch') 
305  uf.title = "Switch between the data pipes of the relax data store." 
306  uf.title_short = "Data pipe switching." 
307  uf.add_keyarg( 
308      name = "pipe_name", 
309      py_type = "str", 
310      desc_short = "data pipe", 
311      desc = "The name of the data pipe.", 
312      wiz_element_type = 'combo', 
313      wiz_combo_iter = pipes.pipe_names 
314  ) 
315  uf.backend = pipes.switch 
316  # Description. 
317  uf.desc.append(Desc_container()) 
318  uf.desc[-1].add_paragraph("This will switch between the various data pipes within the relax data store.") 
319  # Prompt examples. 
320  uf.desc.append(Desc_container("Prompt examples")) 
321  uf.desc[-1].add_paragraph("To switch to the 'ellipsoid' data pipe, type:") 
322  uf.desc[-1].add_prompt("relax> pipe.switch('ellipsoid')") 
323  uf.desc[-1].add_prompt("relax> pipe.switch(pipe_name='ellipsoid')") 
324  uf.menu_text = "&switch" 
325  uf.gui_icon = "oxygen.actions.system-switch-user" 
326  uf.wizard_size = (700, 500) 
327  uf.wizard_apply_button = False 
328  uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe_switch.png' 
329