示例#1
0
import sys
import os
import re
import glob

from configobj import ConfigObj

from pymsbayes import config
from pymsbayes.utils import probability
from pymsbayes.utils import functions
from pymsbayes.fileio import process_file_arg, expand_path
from pymsbayes.utils import stats
from pymsbayes.utils import parsing
from pymsbayes.utils.messaging import get_logger

_LOG = get_logger(__name__)


def get_partitions_from_posterior_sample_file(file_obj,
                                              integer_partitions=False):
    post = parsing.parse_parameters(file_obj)
    if not 'taus' in post:
        name = getattr(file_obj, 'name', file_obj)
        raise Exception('posterior sample in {0} does not contain a '
                        'divergence time vector'.format(name))
    if integer_partitions:
        return stats.IntegerPartitionCollection(post['taus'])
    return stats.PartitionCollection(post['taus'])


def parse_omega_results_file(file_obj):
示例#2
0
"""

import unittest
import os
import sys

from pymsbayes import workers, fileio, manager
from pymsbayes.config import MsBayesConfig
from pymsbayes.test.support import package_paths
from pymsbayes.test.support.pymsbayes_test_case import PyMsBayesTestCase
from pymsbayes.utils import ToolPathManager, MSBAYES_SORT_INDEX
from pymsbayes.utils import parsing, stats
# from pymsbayes.test.test_dmc import DmcTestCase
from pymsbayes.utils.messaging import get_logger

_LOG = get_logger(__name__, level="INFO")


class ToolTestCase(PyMsBayesTestCase):
    def setUp(self):
        self.set_up()
        self.cfg_path = package_paths.data_path('negros_panay.cfg')
        self.new_cfg_path = package_paths.data_path('negros_panay_new.cfg')
        self.sum_stats_path = package_paths.data_path(
            'negros_panay_sum_stats_sort0.txt')
        self.prior_path = package_paths.data_path(
            'negros_panay_new_prior_sample_10.txt')
        self.posterior_path = package_paths.data_path(
            'posterior-sample.txt.gz')

    def tearDown(self):
示例#3
0
#! /usr/bin/env python

import os
import sys
from gzip import GzipFile
from __builtin__ import file
from __builtin__ import open as fopen

from pymsbayes.utils.messaging import get_logger

_LOG = get_logger(__name__)


def expand_path(path):
    return os.path.abspath(os.path.expandvars(os.path.expanduser(path)))

def open(*args, **kwargs):
    return FileStream(*args, **kwargs)

def process_file_arg(file_arg, mode='rU', compresslevel = None):
    if isinstance(file_arg, str):
        fp = expand_path(file_arg)
        gzipped = False
        if os.path.isfile(fp):
            gzipped = is_gzipped(fp)
        if compresslevel:
            return GzipFileStream(fp, mode.strip('U+') + 'b',
                    compresslevel), True
        elif gzipped:
            return GzipFileStream(fp, mode.strip('U+') + 'b'), True
        else:
示例#4
0
"""

import unittest
import os
import sys

from pymsbayes import workers, fileio, manager
from pymsbayes.config import MsBayesConfig
from pymsbayes.test.support import package_paths
from pymsbayes.test.support.pymsbayes_test_case import PyMsBayesTestCase
from pymsbayes.utils import ToolPathManager, MSBAYES_SORT_INDEX
from pymsbayes.utils import parsing, stats
# from pymsbayes.test.test_dmc import DmcTestCase
from pymsbayes.utils.messaging import get_logger

_LOG = get_logger(__name__, level = "INFO")


class ToolTestCase(PyMsBayesTestCase):
    def setUp(self):
        self.set_up()
        self.cfg_path = package_paths.data_path('negros_panay.cfg')
        self.new_cfg_path = package_paths.data_path('negros_panay_new.cfg')
        self.sum_stats_path = package_paths.data_path(
                'negros_panay_sum_stats_sort0.txt')
        self.prior_path = package_paths.data_path(
                'negros_panay_new_prior_sample_10.txt')
        self.posterior_path = package_paths.data_path(
                'posterior-sample.txt.gz')

    def tearDown(self):