Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
Bio.PopGen.SimCoal.Controller.SimCoalController Class Reference

List of all members.

Public Member Functions

def __init__
def run_simcoal

Public Attributes

 simcoal_dir
 os_name
 bin_name

Detailed Description

Definition at line 17 of file Controller.py.


Constructor & Destructor Documentation

Initializes the controller.

simcoal_dir is the directory where simcoal is.

The initializer checks for existance and executability of binaries.

Definition at line 18 of file Controller.py.

00018 
00019     def __init__(self, simcoal_dir):
00020         """Initializes the controller.
00021         
00022         simcoal_dir is the directory where simcoal is.
00023         
00024         The initializer checks for existance and executability of binaries.
00025         """
00026         self.simcoal_dir = simcoal_dir
00027         self.os_name = os.name #remove this?
00028         dir_contents = os.listdir(self.simcoal_dir)
00029         #We expect the tool to be installed as simcoal2(.exe)
00030         #without any trailing version number.
00031         self.bin_name = "simcoal2"
00032         if self.bin_name not in dir_contents:
00033             #Try case insensitive,
00034             dir_contents = [x.lower() for x in dir_contents]
00035         if self.bin_name not in dir_contents:
00036             #Try with .exe
00037             self.bin_name += '.exe'
00038         if self.bin_name not in dir_contents:
00039             raise IOError("SimCoal not available")
00040         if not os.access(os.path.join(self.simcoal_dir, self.bin_name),
00041                          os.X_OK):
00042             raise IOError("SimCoal not executable")


Member Function Documentation

def Bio.PopGen.SimCoal.Controller.SimCoalController.run_simcoal (   self,
  par_file,
  num_sims,
  ploydi = '1',
  par_dir = '.' 
)
Executes SimCoal.

Definition at line 43 of file Controller.py.

00043 
00044     def run_simcoal(self, par_file, num_sims, ploydi = '1', par_dir = '.'):
00045         """Executes SimCoal.
00046         """
00047         if par_dir == None:
00048             par_dir = os.sep.join([".", 'SimCoal', 'runs'])
00049         curr_dir = os.getcwd()
00050         #TODO - Make sure we change drive on Windows as well?
00051         os.chdir(par_dir)
00052         exe = os.path.join(self.simcoal_dir, self.bin_name)
00053         if " " in exe:
00054             exe = '"' + exe + '"'
00055         cmd = exe + ' ' + par_file + ' ' + str(num_sims) + ' ' + ploydi
00056         #TODO - Better way to spot if on Jython on Windows?
00057         if sys.platform=="win32" or self.bin_name.endswith(".exe"):
00058             #There is no /dev/nul on Windows
00059             cmd += ' > nul 2>nul'
00060         else:
00061             cmd += ' >/dev/null 2>&1'
00062         os.system(cmd)
00063         os.chdir(curr_dir)
00064     
00065 

Member Data Documentation

Definition at line 30 of file Controller.py.

Definition at line 26 of file Controller.py.

Definition at line 25 of file Controller.py.


The documentation for this class was generated from the following file: