Author: bugman Date: Wed Apr 16 14:39:31 2008 New Revision: 5750 URL: http://svn.gna.org/viewcvs/relax?rev=5750&view=rev Log: Converted the class methods into module functions. Modified: 1.3/opendx/opendx.py Modified: 1.3/opendx/opendx.py URL: http://svn.gna.org/viewcvs/relax/1.3/opendx/opendx.py?rev=5750&r1=5749&r2=5750&view=diff ============================================================================== --- 1.3/opendx/opendx.py (original) +++ 1.3/opendx/opendx.py Wed Apr 16 14:39:31 2008 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2003-2005, 2007 Edward d'Auvergne # +# Copyright (C) 2003-2005, 2007-2008 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -30,58 +30,45 @@ from relax_errors import RelaxError, RelaxNoResError +def map(run=None, params=None, map_type='Iso3D', res_num=None, inc=20, lower=None, upper=None, axis_incs=10, file="map", dir="dx", point=None, point_file="point", remap=None): + """Function for mapping the given space and creating OpenDX files.""" + + # Residue index. + index = None + if res_num: + for i in xrange(len(relax_data_store.res[run])): + if relax_data_store.res[run][i].num == res_num: + index = i + break + if index == None: + raise RelaxNoResError, res_num + + # Space type. + if search("^[Ii]so3[Dd]", map_type): + if len(params) != 3: + raise RelaxError, "The 3D isosurface map requires a 3 parameter model." + + # Create the map. + self.iso3d.map_space(run, params, res_num, index, inc, lower, upper, axis_incs, file, dir, point, point_file, remap) + else: + raise RelaxError, "The map type '" + map_type + "' is not supported." -class OpenDX: - def __init__(self, relax): - """Class containting the function for OpenDX.""" +def run(file="map", dir="dx", dx_exe="dx", vp_exec=1): + """Function for running OpenDX.""" - # Place the program class structure under self.relax - self.relax = relax + # Text for changing to the directory dir. + dir_text = "" + if dir != None: + dir_text = " -directory " + dir - # Set up all the classes. - self.iso3d = Iso3D(relax) + # Text for executing OpenDX. + execute_text = "" + if vp_exec: + execute_text = " -execute" + # Test the binary file string corresponds to a valid executable. + self.relax.IO.test_binary(dx_exe) - def map(self, run=None, params=None, map_type='Iso3D', res_num=None, inc=20, lower=None, upper=None, axis_incs=10, file="map", dir="dx", point=None, point_file="point", remap=None): - """Function for mapping the given space and creating OpenDX files.""" - - # Residue index. - index = None - if res_num: - for i in xrange(len(relax_data_store.res[run])): - if relax_data_store.res[run][i].num == res_num: - index = i - break - if index == None: - raise RelaxNoResError, res_num - - # Space type. - if search("^[Ii]so3[Dd]", map_type): - if len(params) != 3: - raise RelaxError, "The 3D isosurface map requires a 3 parameter model." - - # Create the map. - self.iso3d.map_space(run, params, res_num, index, inc, lower, upper, axis_incs, file, dir, point, point_file, remap) - else: - raise RelaxError, "The map type '" + map_type + "' is not supported." - - - def run(self, file="map", dir="dx", dx_exe="dx", vp_exec=1): - """Function for running OpenDX.""" - - # Text for changing to the directory dir. - dir_text = "" - if dir != None: - dir_text = " -directory " + dir - - # Text for executing OpenDX. - execute_text = "" - if vp_exec: - execute_text = " -execute" - - # Test the binary file string corresponds to a valid executable. - self.relax.IO.test_binary(dx_exe) - - # Run OpenDX. - system(dx_exe + dir_text + " -program " + file + ".net" + execute_text + " &") + # Run OpenDX. + system(dx_exe + dir_text + " -program " + file + ".net" + execute_text + " &")