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

Source Code for Module dx.opendx

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003 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  from Numeric import zeros 
 24  from os import system 
 25  from re import match 
 26   
 27  from isosurface_3D import Iso3D 
 28   
 29   
30 -class OpenDX:
31 - def __init__(self, relax):
32 """Class containting the function for OpenDX.""" 33 34 # Place the program class structure under self.relax 35 self.relax = relax 36 37 # Set up all the classes. 38 self.iso3d = Iso3D(relax)
39 40
41 - 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):
42 """Function for mapping the given space and creating OpenDX files.""" 43 44 # Residue index. 45 index = None 46 for i in xrange(len(self.relax.data.res[run])): 47 if self.relax.data.res[run][i].num == res_num: 48 index = i 49 break 50 if index == None: 51 raise RelaxNoResError, res_num 52 53 # The number of parameters. 54 n = len(self.relax.data.res[run][index].params) 55 56 # Lower bounds. 57 if lower != None: 58 if len(lower) != n: 59 raise RelaxLenError, ('lower bounds', n) 60 61 # Upper bounds. 62 if upper != None: 63 if len(upper) != n: 64 raise RelaxLenError, ('upper bounds', n) 65 66 # Axes swapping. 67 if swap != None: 68 if len(swap) != n: 69 raise RelaxLenError, ('axes swapping', n) 70 test = zeros(n) 71 for i in xrange(n): 72 if swap[i] >= n: 73 raise RelaxError, "The integer " + `swap[i]` + " is greater than the final array element." 74 elif swap[i] < 0: 75 raise RelaxError, "All integers of the swap argument must be positive." 76 test[swap[i]] = 1 77 for i in xrange(n): 78 if test[i] != 1: 79 raise RelaxError, "The swap argument is invalid (possibly duplicated integer values)." 80 81 # Point. 82 if point != None: 83 if len(point) != n: 84 raise RelaxLenError, ('point', n) 85 86 # Axis labels. 87 if labels != None: 88 if len(labels) != n: 89 raise RelaxLenError, ('axis labels', n) 90 91 # Space type. 92 if match("^[Ii]so3[Dd]", map_type): 93 if n != 3: 94 raise RelaxError, "The 3D isosurface map requires a 3 parameter model." 95 96 # Create the map. 97 self.iso3d.map_space(run, index, n, inc, lower, upper, swap, file, dir, point, point_file, remap, labels) 98 else: 99 raise RelaxError, "The map type '" + map_type + "' is not supported."
100 101
102 - def run(self, file="map", dir="dx", dx_exe="dx", vp_exec=1):
103 """Function for running OpenDX.""" 104 105 # Text for changing to the directory dir. 106 dir_text = "" 107 if dir != None: 108 dir_text = " -directory " + dir 109 110 # Text for executing OpenDX. 111 execute_text = "" 112 if vp_exec: 113 execute_text = " -execute" 114 115 # Run OpenDX. 116 system(dx_exe + dir_text + " -program " + file + ".net" + execute_text + " &")
117