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  import os 
12   
13  from . import Cache 
14   
15   
16 -class SimCoalCache(Cache.SimCoalCache):
17 - def __init__(self, data_dir, simcoal_dir):
18 self.data_dir = data_dir 19 Cache.SimCoalCache.__init__(self, data_dir, simcoal_dir)
20
21 - def runJob(self, parameters, inputFiles):
22 parFile = parameters['parFile'] 23 numSims = parameters['numSims'] 24 ploydi = parameters.get('ploydi', '1') 25 f = inputFiles[parFile] 26 text = f.read() 27 f.close() 28 with open(os.sep.join([self.data_dir, 'SimCoal', 'runs', parFile]), 'w') as w: 29 w.write(text) 30 self.run_simcoal(parFile, numSims, ploydi) 31 return 0, None
32