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

Source Code for Module user_functions.dx'

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003-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 dx user function definitions for controlling the OpenDX visualisation software.""" 
 25   
 26  # relax module imports. 
 27  from generic_fns import diffusion_tensor 
 28  from graphics import WIZARD_IMAGE_PATH 
 29  import opendx.main 
 30  from prompt.doc_string import regexp_doc 
 31  from specific_fns.model_free import Model_free 
 32  from user_functions.data import Uf_info; uf_info = Uf_info() 
 33  from user_functions.data import Uf_tables; uf_tables = Uf_tables() 
 34  from user_functions.objects import Desc_container 
 35   
 36   
 37  # The user function class. 
 38  uf_class = uf_info.add_class("dx") 
 39  uf_class.title = "Class for interfacing with OpenDX." 
 40  uf_class.menu_text = "&dx" 
 41  uf_class.gui_icon = "relax.opendx" 
 42   
 43   
 44  # The dx.execute user function. 
 45  uf = uf_info.add_uf("dx.execute") 
 46  uf.title = "Execute an OpenDX program." 
 47  uf.title_short = "OpenDX execution." 
 48  uf.add_keyarg( 
 49      name = "file_prefix", 
 50      default = "map", 
 51      py_type = "str", 
 52      desc_short = "file name", 
 53      desc = "The file name prefix.  For example if file is set to 'temp', then the OpenDX program temp.net will be loaded." 
 54  ) 
 55  uf.add_keyarg( 
 56      name = "dir", 
 57      default = "dx", 
 58      py_type = "str", 
 59      arg_type = "dir sel", 
 60      desc_short = "directory name", 
 61      desc = "The directory to change to for running OpenDX.  If this is set to None, OpenDX will be run in the current directory.", 
 62      can_be_none = True 
 63  ) 
 64  uf.add_keyarg( 
 65      name = "dx_exe", 
 66      default = "dx", 
 67      py_type = "str", 
 68      desc_short = "OpenDX executable file name", 
 69      desc = "The OpenDX executable file." 
 70  ) 
 71  uf.add_keyarg( 
 72      name = "vp_exec", 
 73      default = True, 
 74      py_type = "bool", 
 75      desc_short = "visual program execution flag", 
 76      desc = "A flag specifying whether to execute the visual program automatically at start-up.  The default of True causes the program to be executed." 
 77  ) 
 78  # Description. 
 79  uf.desc.append(Desc_container()) 
 80  uf.desc[-1].add_paragraph("This will execute OpenDX to display the space maps created previously by the dx.map user function.  This will work for any type of OpenDX map.") 
 81  uf.backend = opendx.main.run 
 82  uf.menu_text = "&execute" 
 83  uf.gui_icon = "oxygen.categories.applications-education" 
 84  uf.wizard_size = (700, 500) 
 85  uf.wizard_apply_button = False 
 86  uf.wizard_image = WIZARD_IMAGE_PATH + 'opendx.png' 
 87   
 88   
 89  # The dx.map user function. 
 90  uf = uf_info.add_uf("dx.map") 
 91  uf.title = "Create a map of the given space in OpenDX format." 
 92  uf.title_short = "OpenDX map creation." 
 93  uf.display = True 
 94  uf.add_keyarg( 
 95      name = "params", 
 96      py_type = "str_list", 
 97      desc_short = "parameters", 
 98      desc = "The parameters to be mapped.  This should be an array of strings, the meanings of which are described below." 
 99  ) 
100  uf.add_keyarg( 
101      name = "map_type", 
102      default = "Iso3D", 
103      py_type = "str", 
104      desc_short = "map type", 
105      desc = "The type of map to create.  For example the default, a 3D isosurface, the type is 'Iso3D'.  See below for more details.", 
106      wiz_element_type = "combo", 
107      wiz_combo_choices = ["Iso3D"], 
108      wiz_read_only = True, 
109  ) 
110  uf.add_keyarg( 
111      name = "spin_id", 
112      py_type = "str", 
113      desc_short = "spin ID string", 
114      desc = "The spin ID string.", 
115      can_be_none = True 
116  ) 
117  uf.add_keyarg( 
118      name = "inc", 
119      default = 20, 
120      py_type = "int", 
121      desc_short = "number of increments", 
122      desc = "The number of increments to map in each dimension.  This value controls the resolution of the map.", 
123      wiz_element_type = "spin" 
124  ) 
125  uf.add_keyarg( 
126      name = "lower", 
127      py_type = "num_list", 
128      desc_short = "lower bounds", 
129      desc = "The lower bounds of the space.  If you wish to change the lower bounds of the map then supply an array of length equal to the number of parameters in the model.  A lower bound for each parameter must be supplied.  If nothing is supplied then the defaults will be used.", 
130      can_be_none = True 
131  ) 
132  uf.add_keyarg( 
133      name = "upper", 
134      py_type = "num_list", 
135      desc_short = "upper bounds", 
136      desc = "The upper bounds of the space.  If you wish to change the upper bounds of the map then supply an array of length equal to the number of parameters in the model.  A upper bound for each parameter must be supplied.  If nothing is supplied then the defaults will be used.", 
137      can_be_none = True 
138  ) 
139  uf.add_keyarg( 
140      name = "axis_incs", 
141      default = 5, 
142      py_type = "int", 
143      desc_short = "axis increments", 
144      desc = "The number of increments or ticks displaying parameter values along the axes of the OpenDX plot.", 
145      wiz_element_type = "spin" 
146  ) 
147  uf.add_keyarg( 
148      name = "file_prefix", 
149      default = "map", 
150      py_type = "str", 
151      desc_short = "file prefix", 
152      desc = "The file name.  All the output files are prefixed with this name.  The main file containing the data points will be called the value of 'file'.  The OpenDX program will be called 'file.net' and the OpenDX import file will be called 'file.general'." 
153  ) 
154  uf.add_keyarg( 
155      name = "dir", 
156      default = "dx", 
157      py_type = "str", 
158      arg_type = "dir sel", 
159      desc_short = "directory name", 
160      desc = "The directory to output files to.  Set this to 'None' if you do not want the files to be placed in subdirectory.  If the directory does not exist, it will be created.", 
161      can_be_none = True 
162  ) 
163  uf.add_keyarg( 
164      name = "point", 
165      py_type = "num_list", 
166      desc_short = "point", 
167      desc = "An array of parameter values where a point in the map, shown as a red sphere, will be placed.  The length must be equal to the number of parameters.", 
168      can_be_none = True 
169  ) 
170  uf.add_keyarg( 
171      name = "point_file", 
172      default = "point", 
173      py_type = "str", 
174      desc_short = "point file name prefix", 
175      desc = "The name of that the point output files will be prefixed with.", 
176      can_be_none = True 
177  ) 
178  uf.add_keyarg( 
179      name = "remap", 
180      py_type = "func", 
181      arg_type = "func", 
182      desc_short = "remap function", 
183      desc = "A user supplied remapping function.  This function will receive the parameter array and must return an array of equal length.", 
184      can_be_none = True 
185  ) 
186  # Description. 
187  uf.desc.append(Desc_container()) 
188  uf.desc[-1].add_paragraph("This will map the space corresponding to the spin identifier and create the OpenDX files.  The map type can be changed to one of the following supported map types:") 
189  table = uf_tables.add_table(label="table: opendx map", caption="OpenDx mapping types.") 
190  table.add_headings(["Surface type", "Name"]) 
191  table.add_row(["3D isosurface", "'Iso3D'"]) 
192  uf.desc[-1].add_table(table.label) 
193  # Additional. 
194  uf.desc.append(regexp_doc) 
195  uf.desc.append(diffusion_tensor.__return_data_name_doc__) 
196  uf.desc.append(Model_free.return_data_name_doc) 
197  # Prompt examples. 
198  uf.desc.append(Desc_container("Prompt examples")) 
199  uf.desc[-1].add_paragraph("The following commands will generate a map of the extended model-free space for model 'm5' consisting of the parameters {S2, S2f, ts}.  Files will be output into the directory 'dx' and will be prefixed by 'map'.  In this case, the system is a protein and residue number 6 will be mapped.") 
200  uf.desc[-1].add_prompt("relax> dx.map(['s2', 's2f', 'ts'], spin_id=':6')") 
201  uf.desc[-1].add_prompt("relax> dx.map(['s2', 's2f', 'ts'], spin_id=':6', file_prefix='map', dir='dx')") 
202  uf.desc[-1].add_prompt("relax> dx.map(params=['s2', 's2f', 'ts'], spin_id=':6', inc=20, file_prefix='map', dir='dx')") 
203  uf.desc[-1].add_prompt("relax> dx.map(params=['s2', 's2f', 'ts'], spin_id=':6', map_type='Iso3D', inc=20, file_prefix='map', dir='dx')") 
204  uf.desc[-1].add_paragraph("To map the model-free space 'm4' for residue 2, spin N6 defined by the parameters {S2, te, Rex}, name the results 'test', and to place the files in the current directory, use one of the following commands:") 
205  uf.desc[-1].add_prompt("relax> dx.map(['s2', 'te', 'rex'], spin_id=':2@N6', file_prefix='test', dir=None)") 
206  uf.desc[-1].add_prompt("relax> dx.map(params=['s2', 'te', 'rex'], spin_id=':2@N6', inc=100, file_prefix='test', dir=None)") 
207  uf.backend = opendx.main.map 
208  uf.menu_text = "&map" 
209  uf.gui_icon = "relax.grid_search" 
210  uf.wizard_height_desc = 280 
211  uf.wizard_size = (1000, 750) 
212  uf.wizard_image = WIZARD_IMAGE_PATH + 'opendx.png' 
213