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

Source Code for Module prompt.dx

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003, 2004 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  import sys 
 24  from types import FunctionType 
 25   
 26  import help 
 27   
 28   
29 -class OpenDX:
30 - def __init__(self, relax):
31 # Help. 32 self.__relax_help__ = \ 33 """Class for interfacing with OpenDX.""" 34 35 # Add the generic help string. 36 self.__relax_help__ = self.__relax_help__ + "\n" + help.relax_class_help 37 38 # Place relax in the class namespace. 39 self.__relax__ = relax
40 41
42 - def execute(self, file="map", dir="dx", dx_exe="dx", vp_exec=1):
43 """Function for running OpenDX. 44 45 Keyword Arguments 46 ~~~~~~~~~~~~~~~~~ 47 48 file: The file name prefix. For example if file is set to 'temp', then the OpenDX program 49 temp.net will be loaded. 50 51 dir: The directory to change to for running OpenDX. If this is set to 'None', OpenDX will 52 be run in the current directory. 53 54 dx_exe: The OpenDX executable file. 55 56 vp_exec: A flag specifying whether to execute the visual program automatically at 57 start-up. The default is 1 which turns execution on. Setting the value to zero turns 58 execution off. 59 """ 60 61 # Function intro text. 62 if self.__relax__.interpreter.intro: 63 text = sys.ps3 + "dx(" 64 text = text + "file=" + `file` 65 text = text + ", dir=" + `dir` 66 text = text + ", dx_exe=" + `dx_exe` 67 text = text + ", vp_exec=" + `vp_exec` + ")" 68 print text 69 70 # File name. 71 if type(file) != str: 72 raise RelaxStrError, ('file name', file) 73 74 # Directory name. 75 if dir == None: 76 pass 77 elif type(dir) != str: 78 raise RelaxNoneStrError, ('file name', file) 79 80 # The OpenDX executable file. 81 if type(dx_exe) != str: 82 raise RelaxStrError, ('OpenDX executable file name', dx_exe) 83 84 # Visual program execution flag. 85 if type(vp_exec) != int or (vp_exec != 0 and vp_exec != 1): 86 raise RelaxBinError, ('visual program execution flag', vp_exec) 87 88 # Execute the functional code. 89 self.__relax__.generic.opendx.run(file=file, dir=dir, dx_exe=dx_exe, vp_exec=vp_exec)
90 91
92 - def map(self, run=None, res_num=None, map_type="Iso3D", inc=20, lower=None, upper=None, swap=None, file="map", dir="dx", point=None, point_file="point", remap=None, labels=None):
93 """Function for creating a map of the given space in OpenDX format. 94 95 Keyword Arguments 96 ~~~~~~~~~~~~~~~~~ 97 98 run: The name of the run. 99 100 res_num: The residue number. 101 102 map_type: The type of map to create. For example the default, a 3D isosurface, the type is 103 "Iso3D". See below for more details. 104 105 inc: The number of increments to map in each dimension. This value controls the resolution 106 of the map. 107 108 lower: The lower bounds of the space. If you wish to change the lower bounds of the map 109 then supply an array of length equal to the number of parameters in the model. A lower 110 bound for each parameter must be supplied. If nothing is supplied then the defaults will 111 be used. 112 113 upper: The upper bounds of the space. If you wish to change the upper bounds of the map 114 then supply an array of length equal to the number of parameters in the model. A upper 115 bound for each parameter must be supplied. If nothing is supplied then the defaults will 116 be used. 117 118 swap: An array used to swap the position of the axes. The length of the array should be 119 the same as the number of parameters in the model. The values should be integers specifying 120 which elements to interchange. For example if swap equals [0, 1, 2] for a three parameter 121 model then the axes are not interchanged whereas if swap equals [1, 0, 2] then the first and 122 second dimensions are interchanged. 123 124 file: The file name. All the output files are prefixed with this name. The main file 125 containing the data points will be called the value of 'file'. The OpenDX program will be 126 called 'file.net' and the OpenDX import file will be called 'file.general'. 127 128 dir: The directory to output files to. Set this to 'None' if you do not want the files to 129 be placed in subdirectory. If the directory does not exist, it will be created. 130 131 point: An array of parameter values where a point in the map, shown as a red sphere, will 132 be placed. The length must be equal to the number of parameters. 133 134 point_file: The name of that the point output files will be prefixed with. 135 136 remap: A user supplied remapping function. This function will receive the parameter array 137 and must return an array of equal length. 138 139 labels: The axis labels. If supplied this argument should be an array of strings of length 140 equal to the number of parameters. 141 142 143 Map type 144 ~~~~~~~~ 145 146 The map type can be changed by supplying the 'map_type' keyword argument. Here is a list of 147 currently supported map types: 148 _____________________________________________________________________________ 149 | | | 150 | Surface type | Pattern | 151 |___________________________________________|_______________________________| 152 | | | 153 | 3D isosurface | '^[Ii]so3[Dd]' | 154 |___________________________________________|_______________________________| 155 156 Pattern syntax is simply regular expression syntax where square brackets [] means any 157 character within the brackets, ^ means the start of the string, etc. 158 159 160 Examples 161 ~~~~~~~~ 162 163 The following commands will generate a map of the extended model-free space defined as run 164 'm5' which consists of the parameters {S2f, S2s, ts}. Files will be output into the 165 directory 'dx' and will be prefixed by 'map'. The residue, in this case, is number 6. 166 167 relax> map('m5', 6) 168 relax> map('m5', 6, 20, "map", "dx") 169 relax> map('m5', res_num=6, file="map", dir="dx") 170 relax> map(run='m5', res_num=6, inc=20, file="map", dir="dx") 171 relax> map(run='m5', res_num=6, type="Iso3D", inc=20, swap=[0, 1, 2], file="map", dir="dx") 172 173 174 The following commands will swap the S2s and ts axes of this map. 175 176 relax> map('m5', res_num=6, swap=[0, 2, 1]) 177 relax> map(run='m5', res_num=6, type="Iso3D", inc=20, swap=[0, 2, 1], file="map", dir="dx") 178 179 180 To map the model-free space 'm4' defined by the parameters {S2, te, Rex}, name the results 181 'test', and not place the files in a subdirectory, use the following commands (assuming 182 residue 2). 183 184 relax> map('m4', res_num=2, file='test', dir=None) 185 relax> map(run='m4', res_num=2, inc=100, file='test', dir=None) 186 """ 187 188 # Function intro text. 189 if self.__relax__.interpreter.intro: 190 text = sys.ps3 + "map(" 191 text = text + "run=" + `run` 192 text = text + ", res_num=" + `res_num` 193 text = text + ", map_type=" + `map_type` 194 text = text + ", inc=" + `inc` 195 text = text + ", lower=" + `lower` 196 text = text + ", upper=" + `upper` 197 text = text + ", swap=" + `swap` 198 text = text + ", file=" + `file` 199 text = text + ", dir=" + `dir` 200 text = text + ", point=" + `point` 201 text = text + ", point_file=" + `point_file` 202 text = text + ", remap=" + `remap` 203 text = text + ", labels=" + `labels` + ")" 204 print text 205 206 # The run argument. 207 if type(run) != str: 208 raise RelaxStrError, ('run', run) 209 210 # The residue number. 211 if type(res_num) != int: 212 raise RelaxIntError, ('residue number', res_num) 213 214 # Increment. 215 if type(inc) != int: 216 raise RelaxIntError, ('increment', inc) 217 elif inc <= 1: 218 raise RelaxError, "The increment value needs to be greater than 1." 219 220 # Lower bounds. 221 if lower != None: 222 if type(lower) != list: 223 raise RelaxListError, ('lower bounds', lower) 224 for i in xrange(len(lower)): 225 if type(lower[i]) != int and type(lower[i]) != float: 226 raise RelaxListNumError, ('lower bounds', lower) 227 228 # Upper bounds. 229 if upper != None: 230 if type(upper) != list: 231 raise RelaxListError, ('upper bounds', upper) 232 for i in xrange(len(upper)): 233 if type(upper[i]) != int and type(upper[i]) != float: 234 raise RelaxListNumError, ('upper bounds', upper) 235 236 # Axes swapping. 237 if swap != None: 238 if type(swap) != list: 239 raise RelaxListError, ('axes swapping', swap) 240 for i in xrange(len(swap)): 241 if type(swap[i]) != int: 242 raise RelaxListIntError, ('axes swapping', swap) 243 244 # File name. 245 if type(file) != str: 246 raise RelaxStrError, ('file name', file) 247 248 # Directory name. 249 if dir != None and type(dir) != str: 250 raise RelaxNoneStrError, ('directory name', dir) 251 252 # Point. 253 if point != None: 254 if type(point) != list: 255 raise RelaxListError, ('point', point) 256 if type(point_file) != str: 257 raise RelaxStrError, ('point file name', point_file) 258 for i in xrange(len(point)): 259 if type(point[i]) != int and type(point[i]) != float: 260 raise RelaxListNumError, ('point', point) 261 262 # Remap function. 263 if remap != None and type(remap) is not FunctionType: 264 raise RelaxFunctionError, ('remap function', remap) 265 266 # Axis labels. 267 if labels != None: 268 if type(labels) != list: 269 raise RelaxListError, ('axis labels', labels) 270 for i in xrange(len(labels)): 271 if type(labels[i]) != str: 272 raise RelaxListStrError, ('axis labels', labels) 273 274 # Space type. 275 if type(map_type) != str: 276 raise RelaxStrError, ('map type', map_type) 277 278 # Execute the functional code. 279 self.__relax__.generic.opendx.map(run=run, res_num=res_num, map_type=map_type, inc=inc, lower=lower, upper=upper, swap=swap, file=file, dir=dir, point=point, point_file=point_file, remap=remap, labels=labels)
280