Package Bio :: Package PopGen :: Package SimCoal :: Module Async
[hide private]
[frames] | no frames]

Source Code for Module Bio.PopGen.SimCoal.Async

 1  # Copyright 2007 by Tiago Antao <tiagoantao@gmail.com>.  All rights reserved. 
 2   
 3  """ 
 4  This module allows to cache Simcoal2 results, and return on the fly 
 5  in case the calculation was done. Async version 
 6   
 7  This version will run Sincoal2 (if necessary) Asynchrously. 
 8   
 9  """ 
10   
11  from logging import debug 
12  from sys import exit 
13  import os 
14  import tarfile 
15  import tempfile 
16   
17  from Controller import SimCoalController 
18  import Cache 
19   
20 -class SimCoalCache(Cache.SimCoalCache):
21 - def __init__(self, data_dir, simcoal_dir):
22 self.data_dir = data_dir 23 Cache.SimCoalCache.__init__(self, data_dir, simcoal_dir)
24
25 - def runJob(self, parameters, inputFiles):
26 parFile = parameters['parFile'] 27 numSims = parameters['numSims'] 28 ploydi = parameters.get('ploydi', '1') 29 f = inputFiles[parFile] 30 text = f.read() 31 f.close() 32 w = open (os.sep.join([self.data_dir, 'SimCoal', 'runs', parFile]), 'w') 33 w.write(text) 34 w.close() 35 self.run_simcoal(parFile, numSims, ploydi) 36 return 0, None
37