Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
Bio.PopGen.SimCoal.Async.SimCoalCache Class Reference
Inheritance diagram for Bio.PopGen.SimCoal.Async.SimCoalCache:
Inheritance graph
[legend]
Collaboration diagram for Bio.PopGen.SimCoal.Async.SimCoalCache:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def runJob
def run_simcoal
def listSimulations
def getSimulation

Public Attributes

 data_dir
 dataDir
 cacheDir
 simcoalDir

Detailed Description

Definition at line 20 of file Async.py.


Constructor & Destructor Documentation

def Bio.PopGen.SimCoal.Async.SimCoalCache.__init__ (   self,
  data_dir,
  simcoal_dir 
)
Initializes the cache.

data_dir - Where the cache can be found
simcoal_dir - where the binaries are

IMPORTANT: The cache only makes sense if the file name univocally
identifies the model.
  For now use use the model name as key,
  and it will probably stay like that.

Reimplemented from Bio.PopGen.SimCoal.Cache.SimCoalCache.

Definition at line 21 of file Async.py.

00021 
00022     def __init__(self, data_dir, simcoal_dir):
00023         self.data_dir = data_dir
00024         Cache.SimCoalCache.__init__(self, data_dir, simcoal_dir)


Member Function Documentation

def Bio.PopGen.SimCoal.Cache.SimCoalCache.getSimulation (   self,
  sim_name,
  ploidy = '1',
  parDir = None 
) [inherited]
   Makes available a cached simulation.

   @param sim_name simulation name.

   This mainly means untaring a file.

Definition at line 70 of file Cache.py.

00070 
00071     def getSimulation(self, sim_name, ploidy = '1', parDir = None):
00072         '''
00073            Makes available a cached simulation.
00074 
00075            @param sim_name simulation name.
00076 
00077            This mainly means untaring a file.
00078         '''
00079         if parDir == None:
00080             parDir = os.sep.join([self.dataDir, 'SimCoal', 'runs'])
00081         tar_name = os.sep.join([self.cacheDir, ploidy, sim_name + 
00082             '.tar.bz2'])
00083         tf = tarfile.open(tar_name)
00084         tf.extractall(parDir)
00085         tf.close()
00086 
00087 
00088 #if __name__ == '__main__':
00089 #  cache = Cache('/home/work/werk/consolidator/sc_cache',
00090 #      '/home/work/software/simcoal')
00091 #  cache.run_simcoal('.', 'island_snp-50_0.0025_10_0.083_100_60.par', 102)
def Bio.PopGen.SimCoal.Cache.SimCoalCache.listSimulations (   self,
  ploidy = '1' 
) [inherited]
   Lists available simulations.

Definition at line 59 of file Cache.py.

00059 
00060     def listSimulations(self, ploidy = '1'):
00061         '''
00062            Lists available simulations.
00063         '''
00064         files = os.listdir(self.cacheDir + os.sep + ploidy)
00065         sims = []
00066         for file in files:
00067             if file.endswith('.tar.bz2'):
00068                 sims.append(file[:-8])
00069         return sims

def Bio.PopGen.SimCoal.Cache.SimCoalCache.run_simcoal (   self,
  par_file,
  num_sims,
  ploydi = '1',
  parDir = None 
) [inherited]

Definition at line 33 of file Cache.py.

00033 
00034     def run_simcoal(self, par_file, num_sims, ploydi = '1', parDir = None):
00035         if parDir == None:
00036             parDir = os.sep.join([self.dataDir, 'SimCoal', 'runs'])
00037         par_file_root = par_file[:-4]
00038         tar_name = os.sep.join([self.cacheDir, ploydi, par_file_root + 
00039             '.tar.bz2'])
00040         if os.access(tar_name, os.R_OK):
00041             tf = tarfile.open(tar_name)
00042             tar_num_sims = len(tf.getmembers()) - 3
00043         else:
00044             tar_num_sims = 0
00045         if tar_num_sims >= num_sims:
00046             tf.extractall(parDir)
00047             tf.close()
00048             return
00049         else:
00050             try:
00051                 tf.close()
00052             except NameError:
00053                 pass #not opened in the first place, OK.
00054         scc = SimCoalController(self.simcoalDir)
00055         scc.run_simcoal(par_file, num_sims, ploydi, parDir)
00056         tf = tarfile.open(tar_name, 'w:bz2')
00057         tf.add(os.sep.join([parDir, par_file_root]), par_file_root)
00058         tf.close()

Here is the caller graph for this function:

def Bio.PopGen.SimCoal.Async.SimCoalCache.runJob (   self,
  parameters,
  inputFiles 
)

Definition at line 25 of file Async.py.

00025 
00026     def runJob(self, parameters, inputFiles):
00027         parFile = parameters['parFile']
00028         numSims = parameters['numSims']
00029         ploydi = parameters.get('ploydi', '1')
00030         f = inputFiles[parFile]
00031         text = f.read()
00032         f.close()
00033         w = open (os.sep.join([self.data_dir, 'SimCoal', 'runs', parFile]), 'w')
00034         w.write(text)
00035         w.close()
00036         self.run_simcoal(parFile, numSims, ploydi)
00037         return 0, None

Here is the call graph for this function:


Member Data Documentation

Definition at line 29 of file Cache.py.

Definition at line 22 of file Async.py.

Definition at line 28 of file Cache.py.

Definition at line 30 of file Cache.py.


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