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

Source Code for Module user_functions.dx

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003-2014 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 dx user function definitions for controlling the OpenDX visualisation software.""" 
 24   
 25  # Python module imports. 
 26  import dep_check 
 27  if dep_check.wx_module: 
 28      from wx import FD_OPEN 
 29  else: 
 30      FD_OPEN = -1 
 31   
 32  # relax module imports. 
 33  from graphics import WIZARD_IMAGE_PATH 
 34  from lib.software.opendx.execute import run 
 35  from pipe_control.opendx import map 
 36  from specific_analyses.frame_order.parameter_object import Frame_order_params; frame_order_params = Frame_order_params() 
 37  from specific_analyses.model_free.parameter_object import Model_free_params; model_free_params = Model_free_params() 
 38  from specific_analyses.n_state_model.parameter_object import N_state_params; n_state_params = N_state_params() 
 39  from specific_analyses.relax_disp.parameter_object import Relax_disp_params; relax_disp_params = Relax_disp_params() 
 40  from user_functions.data import Uf_info; uf_info = Uf_info() 
 41  from user_functions.data import Uf_tables; uf_tables = Uf_tables() 
 42  from user_functions.objects import Desc_container 
 43   
 44   
 45  # The user function class. 
 46  uf_class = uf_info.add_class("dx") 
 47  uf_class.title = "Class for interfacing with OpenDX." 
 48  uf_class.menu_text = "&dx" 
 49  uf_class.gui_icon = "relax.opendx" 
 50   
 51   
 52  # The dx.execute user function. 
 53  uf = uf_info.add_uf("dx.execute") 
 54  uf.title = "Execute an OpenDX program." 
 55  uf.title_short = "OpenDX execution." 
 56  uf.add_keyarg( 
 57      name = "file_prefix", 
 58      default = "map", 
 59      py_type = "str", 
 60      desc_short = "file name", 
 61      desc = "The file name prefix.  For example if file is set to 'temp', then the OpenDX program temp.net will be loaded." 
 62  ) 
 63  uf.add_keyarg( 
 64      name = "dir", 
 65      default = "dx", 
 66      py_type = "str", 
 67      arg_type = "dir sel", 
 68      desc_short = "directory name", 
 69      desc = "The directory to change to for running OpenDX.  If this is set to None, OpenDX will be run in the current directory.", 
 70      can_be_none = True 
 71  ) 
 72  uf.add_keyarg( 
 73      name = "dx_exe", 
 74      default = "dx", 
 75      py_type = "str", 
 76      arg_type = "file sel", 
 77      desc_short = "OpenDX executable file name", 
 78      desc = "The OpenDX executable file.", 
 79      wiz_filesel_style = FD_OPEN, 
 80      wiz_filesel_preview = False 
 81  ) 
 82  uf.add_keyarg( 
 83      name = "vp_exec", 
 84      default = True, 
 85      py_type = "bool", 
 86      desc_short = "visual program execution flag", 
 87      desc = "A flag specifying whether to execute the visual program automatically at start-up.  The default of True causes the program to be executed." 
 88  ) 
 89  # Description. 
 90  uf.desc.append(Desc_container()) 
 91  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.") 
 92  uf.backend = run 
 93  uf.menu_text = "&execute" 
 94  uf.gui_icon = "oxygen.categories.applications-education" 
 95  uf.wizard_size = (700, 500) 
 96  uf.wizard_apply_button = False 
 97  uf.wizard_image = WIZARD_IMAGE_PATH + 'opendx.png' 
 98   
 99   
100  # The dx.map user function. 
101  uf = uf_info.add_uf("dx.map") 
102  uf.title = "Create a map of the given space in OpenDX format." 
103  uf.title_short = "OpenDX map creation." 
104  uf.display = True 
105  uf.add_keyarg( 
106      name = "params", 
107      py_type = "str_list", 
108      desc_short = "parameters", 
109      desc = "The parameters to be mapped.  This should be an array of strings, the meanings of which are described below." 
110  ) 
111  uf.add_keyarg( 
112      name = "map_type", 
113      default = "Iso3D", 
114      py_type = "str", 
115      desc_short = "map type", 
116      desc = "The type of map to create.  For example the default, a 3D isosurface, the type is 'Iso3D'.  See below for more details.", 
117      wiz_element_type = "combo", 
118      wiz_combo_choices = ["Iso3D"], 
119      wiz_read_only = True, 
120  ) 
121  uf.add_keyarg( 
122      name = "spin_id", 
123      py_type = "str", 
124      desc_short = "spin ID string", 
125      desc = "The spin ID string.", 
126      can_be_none = True 
127  ) 
128  uf.add_keyarg( 
129      name = "inc", 
130      default = 20, 
131      py_type = "int", 
132      desc_short = "number of increments", 
133      desc = "The number of increments to map in each dimension.  This value controls the resolution of the map.", 
134      wiz_element_type = "spin" 
135  ) 
136  uf.add_keyarg( 
137      name = "lower", 
138      py_type = "num_list", 
139      desc_short = "lower bounds", 
140      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.", 
141      can_be_none = True 
142  ) 
143  uf.add_keyarg( 
144      name = "upper", 
145      py_type = "num_list", 
146      desc_short = "upper bounds", 
147      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.", 
148      can_be_none = True 
149  ) 
150  uf.add_keyarg( 
151      name = "axis_incs", 
152      default = 5, 
153      py_type = "int", 
154      desc_short = "axis increments", 
155      desc = "The number of increments or ticks displaying parameter values along the axes of the OpenDX plot.", 
156      wiz_element_type = "spin" 
157  ) 
158  uf.add_keyarg( 
159      name = "file_prefix", 
160      default = "map", 
161      py_type = "str", 
162      desc_short = "file prefix", 
163      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'." 
164  ) 
165  uf.add_keyarg( 
166      name = "dir", 
167      default = "dx", 
168      py_type = "str", 
169      arg_type = "dir sel", 
170      desc_short = "directory name", 
171      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.", 
172      can_be_none = True 
173  ) 
174  uf.add_keyarg( 
175      name = "point", 
176      py_type = "list_val_or_list_of_list_val", 
177      dim = (None, 3), 
178      desc_short = "highlight points in the space", 
179      desc = "This argument allows specific points in the optimisation space to be displayed as coloured spheres.  This can be used to highlight a minimum or other any other feature of the space.  Either a single point or a list of points can be supplied.  Each point is a list of floating point numbers in the form [x, y, z]", 
180      list_titles = ['X coordinate', 'Y coordinate', 'Z coordinate'], 
181      can_be_none = True 
182  ) 
183  uf.add_keyarg( 
184      name = "point_file", 
185      default = "point", 
186      py_type = "str", 
187      desc_short = "point file name prefix", 
188      desc = "The name of that the point output files will be prefixed with.", 
189      can_be_none = True 
190  ) 
191  uf.add_keyarg( 
192      name = "chi_surface", 
193      default = None, 
194      py_type = "float_array", 
195      desc_short = "Set the chi2 surface level for the Innermost, Inner, Middle and Outer Isosurface.", 
196      desc = "A list of 4 numbers, setting the level for the 4 isosurfaces. Useful in scripting if you create a set of OpenDX maps with all the same contour levels.  Ideal for comparisons.", 
197      can_be_none = True, 
198      dim = 4 
199  ) 
200  # Description. 
201  uf.desc.append(Desc_container()) 
202  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:") 
203  table = uf_tables.add_table(label="table: opendx map", caption="OpenDx mapping types.") 
204  table.add_headings(["Surface type", "Name"]) 
205  table.add_row(["3D isosurface", "'Iso3D'"]) 
206  uf.desc[-1].add_table(table.label) 
207  # Additional. 
208  uf.desc.append(model_free_params.uf_doc(label="table: all model-free parameters")) 
209  uf.desc.append(n_state_params.uf_doc(label="table: N-state parameters")) 
210  uf.desc.append(relax_disp_params.uf_doc(label="table: dispersion parameters")) 
211  uf.desc.append(frame_order_params.uf_doc(label="table: frame order parameters")) 
212  # Prompt examples. 
213  uf.desc.append(Desc_container("Prompt examples")) 
214  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.") 
215  uf.desc[-1].add_prompt("relax> dx.map(['s2', 's2f', 'ts'], spin_id=':6')") 
216  uf.desc[-1].add_prompt("relax> dx.map(['s2', 's2f', 'ts'], spin_id=':6', file_prefix='map', dir='dx')") 
217  uf.desc[-1].add_prompt("relax> dx.map(params=['s2', 's2f', 'ts'], spin_id=':6', inc=20, file_prefix='map', dir='dx')") 
218  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')") 
219  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:") 
220  uf.desc[-1].add_prompt("relax> dx.map(['s2', 'te', 'rex'], spin_id=':2@N6', file_prefix='test', dir=None)") 
221  uf.desc[-1].add_prompt("relax> dx.map(params=['s2', 'te', 'rex'], spin_id=':2@N6', inc=100, file_prefix='test', dir=None)") 
222  uf.backend = map 
223  uf.menu_text = "&map" 
224  uf.gui_icon = "relax.grid_search" 
225  uf.wizard_height_desc = 280 
226  uf.wizard_size = (1000, 750) 
227  uf.wizard_image = WIZARD_IMAGE_PATH + 'opendx.png' 
228