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