Back to index

python-biopython  1.60
Async.py
Go to the documentation of this file.
00001 # Copyright 2007 by Tiago Antao <tiagoantao@gmail.com>.  All rights reserved.
00002 
00003 """
00004 This module allows to cache Simcoal2 results, and return on the fly
00005 in case the calculation was done. Async version
00006 
00007 This version will run Sincoal2 (if necessary) Asynchrously.
00008 
00009 """
00010 
00011 from logging import debug
00012 from sys import exit
00013 import os
00014 import tarfile
00015 import tempfile
00016 
00017 from Controller import SimCoalController
00018 import Cache
00019 
00020 class SimCoalCache(Cache.SimCoalCache):
00021     def __init__(self, data_dir, simcoal_dir):
00022         self.data_dir = data_dir
00023         Cache.SimCoalCache.__init__(self, data_dir, simcoal_dir)
00024 
00025     def runJob(self, parameters, inputFiles):
00026         parFile = parameters['parFile']
00027         numSims = parameters['numSims']
00028         ploydi = parameters.get('ploydi', '1')
00029         f = inputFiles[parFile]
00030         text = f.read()
00031         f.close()
00032         w = open (os.sep.join([self.data_dir, 'SimCoal', 'runs', parFile]), 'w')
00033         w.write(text)
00034         w.close()
00035         self.run_simcoal(parFile, numSims, ploydi)
00036         return 0, None