예제 #1
0
def main():
    """
    Main CLI handler.
    """
    
    parser = OptionParser(usage=_prog_usage, 
        add_help_option=True, 
        version=_prog_version, 
        description=_prog_description)    
       
    parser.add_option('-n', '--pop-size', '-N',
        action='store',
        dest='pop_size',
        type='int',
        default=1,
        metavar='Ne',
        help='effective HAPLOID population size (default=%default [assumes edge lengths are in units of Ne])')

    (opts, args) = parser.parse_args()
    
    if len(args) == 0:
        sys.stderr.write("%s" % parser.get_usage())
        sys.exit(1)
        
    for a in args:
        fpath = os.path.expandvars(os.path.expanduser(a))
        if not os.path.exists(fpath):
            sys.stderr.write('File not found: "%s"\n' % fpath)
        else:
            sys.stderr.write('Reading: "%s"\n' % fpath)
            d = datasets.Dataset()
            ctrees = d.read_trees(open(fpath, "rU"), "NEXUS")
            for t in ctrees:
                p = coalescent.log_probability_of_coalescent_tree(t, opts.pop_size)
                sys.stdout.write("%s\n" % p)
    def testSimple1(self):

        t = dendropy.Tree.get_from_string("((((a:1, b:1):1, c:2):1, d:3, e:3):2, (f:4, g:4):1)", "newick")
        i1 = coalescent.node_waiting_time_pairs(t)
        assert [x[1] for x in i1] == [1.0, 1.0, 1.0, 1.0, 1.0]
        i2 = coalescent.extract_coalescent_frames(t)
        assert i2 == {7: 1.0, 6:1.0, 5:1.0, 3:1.0, 2:1.0}
        check = coalescent.log_probability_of_coalescent_tree(t, 10)
예제 #3
0
    def testSimple1(self):

        t = dendropy.Tree.get_from_string(
            "((((a:1, b:1):1, c:2):1, d:3, e:3):2, (f:4, g:4):1)", "newick")
        i1 = coalescent.node_waiting_time_pairs(t)
        assert [x[1] for x in i1] == [1.0, 1.0, 1.0, 1.0, 1.0]
        i2 = coalescent.extract_coalescent_frames(t)
        assert i2 == {7: 1.0, 6: 1.0, 5: 1.0, 3: 1.0, 2: 1.0}
        check = coalescent.log_probability_of_coalescent_tree(t, 10)