~ubuntu-branches/debian/sid/python-biopython/sid

« back to all changes in this revision

Viewing changes to Bio/PopGen/SimCoal/Cache.py

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2014-06-08 10:25:35 UTC
  • mfrom: (1.1.22)
  • Revision ID: package-import@ubuntu.com-20140608102535-ebgnhcpcrum3i3w8
Tags: 1.64+dfsg-1
* New upstream version
* Build-Depends raxml only on those architectures where it is available
  Closes: #750845

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright 2007 by Tiago Antao <tiagoantao@gmail.com>.  All rights reserved.
2
2
 
3
3
"""
 
4
(DEPRECATED)
4
5
This module allows to cache Simcoal2 results, and return on the fly
5
6
in case the calculation was done.
6
7
 
27
28
        self.cacheDir = os.sep.join([data_dir, 'SimCoal', 'cache'])
28
29
        self.simcoalDir = simcoal_dir
29
30
 
30
 
    def run_simcoal(self, par_file, num_sims, ploydi = '1', parDir = None):
 
31
    def run_simcoal(self, par_file, num_sims, ploydi='1', parDir=None):
31
32
        if parDir is None:
32
33
            parDir = os.sep.join([self.dataDir, 'SimCoal', 'runs'])
33
34
        par_file_root = par_file[:-4]
34
35
        tar_name = os.sep.join([self.cacheDir, ploydi, par_file_root +
35
 
            '.tar.bz2'])
 
36
                                '.tar.bz2'])
36
37
        if os.access(tar_name, os.R_OK):
37
38
            tf = tarfile.open(tar_name)
38
39
            tar_num_sims = len(tf.getmembers()) - 3
53
54
        tf.add(os.sep.join([parDir, par_file_root]), par_file_root)
54
55
        tf.close()
55
56
 
56
 
    def listSimulations(self, ploidy = '1'):
 
57
    def listSimulations(self, ploidy='1'):
57
58
        '''
58
59
           Lists available simulations.
59
60
        '''
64
65
                sims.append(file[:-8])
65
66
        return sims
66
67
 
67
 
    def getSimulation(self, sim_name, ploidy = '1', parDir = None):
 
68
    def getSimulation(self, sim_name, ploidy='1', parDir=None):
68
69
        '''
69
70
           Makes available a cached simulation.
70
71
 
75
76
        if parDir is None:
76
77
            parDir = os.sep.join([self.dataDir, 'SimCoal', 'runs'])
77
78
        tar_name = os.sep.join([self.cacheDir, ploidy, sim_name +
78
 
            '.tar.bz2'])
 
79
                                '.tar.bz2'])
79
80
        tf = tarfile.open(tar_name)
80
81
        tf.extractall(parDir)
81
82
        tf.close()