File: Async.py

package info (click to toggle)
python-biopython 1.68%2Bdfsg-3~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 46,856 kB
  • sloc: python: 160,306; xml: 93,216; ansic: 9,118; sql: 1,208; makefile: 155; sh: 63
file content (31 lines) | stat: -rw-r--r-- 967 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Copyright 2007 by Tiago Antao <tiagoantao@gmail.com>.  All rights reserved.

"""Async. caching of Simcoal2 results (DEPRECATED).

This module allows to cache Simcoal2 results, and return on the fly
in case the calculation was done. Async version

This version will run Sincoal2 (if necessary) Asynchrously.

"""

import os
from . import Cache


class SimCoalCache(Cache.SimCoalCache):
    def __init__(self, data_dir, simcoal_dir):
        self.data_dir = data_dir
        Cache.SimCoalCache.__init__(self, data_dir, simcoal_dir)

    def runJob(self, parameters, inputFiles):
        parFile = parameters['parFile']
        numSims = parameters['numSims']
        ploydi = parameters.get('ploydi', '1')
        f = inputFiles[parFile]
        text = f.read()
        f.close()
        with open(os.sep.join([self.data_dir, 'SimCoal', 'runs', parFile]), 'w') as w:
            w.write(text)
        self.run_simcoal(parFile, numSims, ploydi)
        return 0, None