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  from PopGen.SimCoal.Controller import SimCoalController 
17  from PopGen.SimCoal import Cache 
18  from PopGen import Config 
19  from PopGen import Async 
20   
21 -class SimCoalCache(Cache.SimCoalCache):
22 - def __init__(self, simcoalDir = None):
23 Cache.SimCoalCache.__init__(self, simcoalDir)
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([Config.dataDir, 'SimCoal', 'runs', parFile]), 'w') 33 w.write(text) 34 w.close() 35 self.run_simcoal(parFile, numSims, ploydi) 36 return 0, None
37