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

Source Code for Module prompt.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  """Module containing the 'dx' user function class for controlling the OpenDX visualisation software.""" 
 25  __docformat__ = 'plaintext' 
 26   
 27  # relax module imports. 
 28  from base_class import User_fn_class, _build_doc 
 29  import arg_check 
 30  from doc_string import docs 
 31  from generic_fns import diffusion_tensor 
 32  import opendx.main 
 33  from relax_errors import RelaxError 
 34  from specific_fns.model_free import Model_free 
 35   
 36   
37 -class OpenDX(User_fn_class):
38 """Class for interfacing with OpenDX.""" 39
40 - def execute(self, file="map", dir="dx", dx_exe="dx", vp_exec=True):
41 # Function intro text. 42 if self._exec_info.intro: 43 text = self._exec_info.ps3 + "dx(" 44 text = text + "file=" + repr(file) 45 text = text + ", dir=" + repr(dir) 46 text = text + ", dx_exe=" + repr(dx_exe) 47 text = text + ", vp_exec=" + repr(vp_exec) + ")" 48 print(text) 49 50 # The argument checks. 51 arg_check.is_str(file, 'file name') 52 arg_check.is_str(dir, 'directory name', can_be_none=True) 53 arg_check.is_str(dx_exe, 'OpenDX executable file name') 54 arg_check.is_bool(vp_exec, 'visual program execution flag') 55 56 # Execute the functional code. 57 opendx.main.run(file_prefix=file, dir=dir, dx_exe=dx_exe, vp_exec=vp_exec)
58 59 # The function doc info. 60 execute._doc_title = "Execution of OpenDX." 61 execute._doc_title_short = "OpenDX execution." 62 execute._doc_args = [ 63 ["file", "The file name prefix. For example if file is set to 'temp', then the OpenDX program temp.net will be loaded."], 64 ["dir", "The directory to change to for running OpenDX. If this is set to None, OpenDX will be run in the current directory."], 65 ["dx_exe", "The OpenDX executable file."], 66 ["vp_exec", "A flag specifying whether to execute the visual program automatically at start-up. The default of True causes the program to be executed."] 67 ] 68 _build_doc(execute) 69 70
71 - def map(self, params=None, map_type="Iso3D", spin_id=None, inc=20, lower=None, upper=None, axis_incs=5, file_prefix="map", dir="dx", point=None, point_file="point", remap=None):
72 # Function intro text. 73 if self._exec_info.intro: 74 text = self._exec_info.ps3 + "map(" 75 text = text + "params=" + repr(params) 76 text = text + ", map_type=" + repr(map_type) 77 text = text + ", spin_id=" + repr(spin_id) 78 text = text + ", inc=" + repr(inc) 79 text = text + ", lower=" + repr(lower) 80 text = text + ", upper=" + repr(upper) 81 text = text + ", axis_incs=" + repr(axis_incs) 82 text = text + ", file_prefix=" + repr(file_prefix) 83 text = text + ", dir=" + repr(dir) 84 text = text + ", point=" + repr(point) 85 text = text + ", point_file=" + repr(point_file) 86 text = text + ", remap=" + repr(remap) + ")" 87 print(text) 88 89 # The argument checks. 90 arg_check.is_str_list(params, 'parameters') 91 arg_check.is_str(map_type, 'map type') 92 arg_check.is_str(spin_id, 'spin identification string', can_be_none=True) 93 arg_check.is_int(inc, 'increment') 94 if inc <= 1: 95 raise RelaxError("The increment value needs to be greater than 1.") 96 arg_check.is_num_list(lower, 'lower bounds', size=len(params), can_be_none=True) 97 arg_check.is_num_list(upper, 'upper bounds', size=len(params), can_be_none=True) 98 arg_check.is_int(axis_incs, 'axis increments') 99 if axis_incs <= 1: 100 raise RelaxError("The axis increment value needs to be greater than 1.") 101 arg_check.is_str(file_prefix, 'file prefix') 102 arg_check.is_str(dir, 'directory name', can_be_none=True) 103 arg_check.is_num_list(point, 'point', size=len(params), can_be_none=True) 104 if point != None: 105 arg_check.is_str(point_file, 'point file name') 106 arg_check.is_func(remap, 'remap function', can_be_none=True) 107 108 # Execute the functional code. 109 opendx.main.map(params=params, map_type=map_type, spin_id=spin_id, inc=inc, lower=lower, upper=upper, axis_incs=axis_incs, file_prefix=file_prefix, dir=dir, point=point, point_file=point_file, remap=remap)
110 111 # The function doc info. 112 map._doc_title = "Create a map of the given space in OpenDX format." 113 map._doc_title_short = "OpenDX map creation." 114 map._doc_args = [ 115 ["params", "The parameters to be mapped. This argument should be an array of strings, the meanings of which are described below."], 116 ["map_type", "The type of map to create. For example the default, a 3D isosurface, the type is 'Iso3D'. See below for more details."], 117 ["spin_id", "The spin identification numbe."], 118 ["inc", "The number of increments to map in each dimension. This value controls the resolution of the map."], 119 ["lower", "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."], 120 ["upper", "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."], 121 ["axis_incs", "The number of increments or ticks displaying parameter values along the axes of the OpenDX plot."], 122 ["file_prefix", "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'."], 123 ["dir", "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."], 124 ["point", "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."], 125 ["point_file", "The name of that the point output files will be prefixed with."], 126 ["remap", "A user supplied remapping function. This function will receive the parameter array and must return an array of equal length."] 127 ] 128 map._doc_desc = """ 129 The map type can be changed to one of the following supported map types: 130 _____________________________________________________________________________ 131 | | | 132 | Surface type | Name | 133 |___________________________________________|_______________________________| 134 | | | 135 | 3D isosurface | 'Iso3D' | 136 |___________________________________________|_______________________________| 137 """ 138 map._doc_examples = """ 139 The following commands will generate a map of the extended model-free space for model 'm5' 140 consisting of the parameters {S2, S2f, ts}. Files will be output into the 141 directory 'dx' and will be prefixed by 'map'. In this case, the system is a protein and 142 residue number 6 will be mapped. 143 144 relax> dx.map(['s2', 's2f', 'ts'], spin_id=':6') 145 relax> dx.map(['s2', 's2f', 'ts'], spin_id=':6', file_prefix='map', dir='dx') 146 relax> dx.map(params=['s2', 's2f', 'ts'], spin_id=':6', inc=20, file_prefix='map', dir='dx') 147 relax> dx.map(params=['s2', 's2f', 'ts'], spin_id=':6', map_type='Iso3D', inc=20, 148 file_prefix='map', dir='dx') 149 150 151 To map the model-free space 'm4' for residue 2, spin N6 defined by the parameters {S2, te, 152 Rex}, name the results 'test', and to place the files in the current directory, use one of 153 the following commands: 154 155 relax> dx.map(['s2', 'te', 'rex'], spin_id=':2@N6', file_prefix='test', dir=None) 156 relax> dx.map(params=['s2', 'te', 'rex'], spin_id=':2@N6', inc=100, file_prefix='test', dir=None) 157 """ 158 map._doc_additional = [ 159 docs.regexp.doc, 160 diffusion_tensor.__return_data_name_prompt_doc__, 161 Model_free.return_data_name_doc 162 ] 163 _build_doc(map)
164