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

Source Code for Module user_functions.pipe

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2004-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 pipe user function definitions.""" 
 24   
 25  # relax module imports. 
 26  from graphics import WIZARD_IMAGE_PATH 
 27  from pipe_control import pipes 
 28  from specific_analyses.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_disp'", "Relaxation dispersion curve fitting,") 
197  uf.desc[-1].add_item_list_element("'relax_fit'", "Relaxation curve fitting,") 
198  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:") 
199  uf.desc[-1].add_list_element("The grouping or categorisation of data pipes, for example when multiple related analyses are performed.") 
200  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.") 
201  uf.desc[-1].add_list_element("In the graphical user interface mode as analysis tabs are linked to specific pipe bundles.") 
202  # Prompt examples. 
203  uf.desc.append(Desc_container("Prompt examples")) 
204  uf.desc[-1].add_paragraph("To set up a model-free analysis data pipe with the name 'm5', type:") 
205  uf.desc[-1].add_prompt("relax> pipe.create('m5', 'mf')") 
206  uf.menu_text = "crea&te" 
207  uf.gui_icon = "oxygen.actions.list-add-relax-blue" 
208  uf.wizard_height_desc = 500 
209  uf.wizard_size = (1000, 750) 
210  uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe.png' 
211   
212   
213  # The pipe.current user function. 
214  uf = uf_info.add_uf('pipe.current') 
215  uf.title = "Print the name of the current data pipe." 
216  uf.title_short = "Current data pipe printing." 
217  uf.display = True 
218  uf.backend = pipes.current 
219  # Prompt examples. 
220  uf.desc.append(Desc_container("Prompt examples")) 
221  uf.desc[-1].add_paragraph("To run the user function, type:") 
222  uf.desc[-1].add_prompt("relax> pipe.current()") 
223  uf.menu_text = "c&urrent" 
224  uf.gui_icon = "oxygen.actions.document-preview" 
225  uf.wizard_size = (600, 300) 
226  uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe.png' 
227   
228   
229  # The pipe.delete user function. 
230  uf = uf_info.add_uf('pipe.delete') 
231  uf.title = "Delete a data pipe from the relax data store." 
232  uf.title_short = "Data pipe deletion." 
233  uf.add_keyarg( 
234      name = "pipe_name", 
235      py_type = "str", 
236      desc_short = "data pipe", 
237      desc = "The name of the data pipe to delete.", 
238      wiz_element_type = 'combo', 
239      wiz_combo_iter = pipes.pipe_names, 
240      can_be_none = True 
241  ) 
242  # Description. 
243  uf.desc.append(Desc_container()) 
244  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.") 
245  uf.backend = pipes.delete 
246  uf.menu_text = "&delete" 
247  uf.gui_icon = "oxygen.actions.list-remove" 
248  uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe.png' 
249  uf.gui_sync = True    # Force synchronous operation to avoid the GUI from blowing up. 
250   
251   
252  # The pipe.display user function. 
253  uf = uf_info.add_uf('pipe.display') 
254  uf.title = "Print a list of all the data pipes." 
255  uf.title_short = "Data pipe listing." 
256  uf.display = True 
257  uf.backend = pipes.display 
258  # Prompt examples. 
259  uf.desc.append(Desc_container("Prompt examples")) 
260  uf.desc[-1].add_paragraph("To run the user function, type:") 
261  uf.desc[-1].add_prompt("relax> pipe.display()") 
262  uf.menu_text = "di&splay" 
263  uf.gui_icon = "oxygen.actions.document-preview" 
264  uf.wizard_size = (600, 300) 
265  uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe.png' 
266   
267   
268  # The pipe.hybridise user function. 
269  uf = uf_info.add_uf('pipe.hybridise') 
270  uf.title = "Create a hybrid data pipe by fusing a number of other data pipes." 
271  uf.title_short = "Hybrid data pipe creation." 
272  uf.add_keyarg( 
273      name = "hybrid", 
274      py_type = "str", 
275      desc_short = "hybrid pipe name", 
276      desc = "The name of the hybrid data pipe to create." 
277  ) 
278  uf.add_keyarg( 
279      name = "pipes", 
280      py_type = "str_list", 
281      desc_short = "data pipes to hybridise", 
282      desc = "An array containing the names of all data pipes to hybridise.", 
283      wiz_element_type = 'combo_list', 
284      wiz_combo_iter = pipes.pipe_names, 
285      wiz_combo_list_min = 2 
286  ) 
287  uf.backend = hybrid_obj._hybridise 
288  # Description. 
289  uf.desc.append(Desc_container()) 
290  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.") 
291  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.") 
292  # Prompt examples. 
293  uf.desc.append(Desc_container("Prompt examples")) 
294  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:") 
295  uf.desc[-1].add_prompt("relax> pipe.hybridise('mixed model', ['N_sphere', 'C_ellipsoid'])") 
296  uf.desc[-1].add_prompt("relax> pipe.hybridise(hybrid='mixed model', pipes=['N_sphere', 'C_ellipsoid'])") 
297  uf.menu_text = "&hybridise" 
298  uf.gui_icon = "relax.pipe_hybrid" 
299  uf.wizard_height_desc = 350 
300  uf.wizard_size = (1000, 750) 
301  uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe_hybrid.png' 
302   
303   
304  # The pipe.switch user function. 
305  uf = uf_info.add_uf('pipe.switch') 
306  uf.title = "Switch between the data pipes of the relax data store." 
307  uf.title_short = "Data pipe switching." 
308  uf.add_keyarg( 
309      name = "pipe_name", 
310      py_type = "str", 
311      desc_short = "data pipe", 
312      desc = "The name of the data pipe.", 
313      wiz_element_type = 'combo', 
314      wiz_combo_iter = pipes.pipe_names 
315  ) 
316  uf.backend = pipes.switch 
317  # Description. 
318  uf.desc.append(Desc_container()) 
319  uf.desc[-1].add_paragraph("This will switch between the various data pipes within the relax data store.") 
320  # Prompt examples. 
321  uf.desc.append(Desc_container("Prompt examples")) 
322  uf.desc[-1].add_paragraph("To switch to the 'ellipsoid' data pipe, type:") 
323  uf.desc[-1].add_prompt("relax> pipe.switch('ellipsoid')") 
324  uf.desc[-1].add_prompt("relax> pipe.switch(pipe_name='ellipsoid')") 
325  uf.menu_text = "&switch" 
326  uf.gui_icon = "oxygen.actions.system-switch-user" 
327  uf.wizard_size = (700, 500) 
328  uf.wizard_apply_button = False 
329  uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe_switch.png' 
330