Exemplo n.º 1
0
def get_response_content(fs):
    headers = [
            # define the point
            'exch21', 'exch31', 'exch32', 'exch41', 'exch42', 'exch43',
            'mutprob1', 'mutprob2', 'mutprob3', 'mutprob4',
            'balprob1', 'balprob2', 'balprob3', 'balprob4',
            'infotype',
            't',
            # annotate with some summary statistics
            'shannon.ent.diff',
            'logical.ent.diff',
            'log.shannon.ent.ratio',
            'log.logical.ent.ratio',
            'expected.rate.diff',
            'spectral.rate.diff',
            'log.expected.rate.ratio',
            'log.spectral.rate.ratio',
            'mi.diff',
            'fi.diff',
            'log.mi.ratio',
            'log.fi.ratio',
            # define the label
            'label',
            ]
    accum = Accumulator()
    combobreaker.run_callable(accum, nseconds=5, niterations=fs.nsamples)
    # return csv contents
    out = StringIO()
    print >> out, ', '.join(headers)
    for row in accum.rows:
        print >> out, ', '.join(str(x) for x in row)
    return out.getvalue()
Exemplo n.º 2
0
def main(args):
    """
    @param args: from argparse
    """
    # get some state that will not change between k-means restarts
    with open(args.table_filename) as fin:
        rtable = RUtil.RTable(fin)
    points = get_rtable_info(rtable, args.annotation, args.axes)
    init_strategy = kmeans.InitStrategy().string_to_function(args.kmeans_init)
    gs = GlobalState(rtable, points, args.annotation, args.k, init_strategy)
    # go until iteration is stopped for some reason
    print combobreaker.run_callable(
            ClusterState(gs), args.nseconds, args.nrestarts)
Exemplo n.º 3
0
def get_response_content(fs):
    #nseconds_max = 20
    out = StringIO()
    print >> out, 'theta:', fs.theta
    print >> out, 'Nr:', fs.Nr
    print >> out, 'Ns:', fs.Ns
    print >> out
    for N_diploid in (50, 100, 200):
        N_hap = N_diploid * 2
        # TODO check s vs N_diploid so that selection is not too big
        # as to make fitnesses negative or zero
        #
        #
        f = Accum(N_hap, fs.theta / 2, fs.Nr, fs.Ns / N_diploid)
        info = combobreaker.run_callable(f, niterations=fs.nsamples_max)
        #
        nt1 = len(f.type_1_times)
        nt2 = len(f.type_2_times)
        print >> out, '2N:', N_hap
        print >> out, 'number of type 1 substitutions:', nt1
        print >> out, 'number of type 2 substitutions:', nt2
        pt1 = nt1 / float(nt1 + nt2)
        pt2 = nt2 / float(nt1 + nt2)
        print >> out, 'proportion of type 1 substitutions:', pt1
        print >> out, 'proportion of type 2 substitutions:', pt2
        e1 = np.mean(f.type_1_times) / N_hap
        e2 = np.mean(f.type_2_times) / N_hap
        print >> out, 'mean type 1 pathway generations per 2N:', e1
        print >> out, 'mean type 2 pathway generations per 2N:', e2
        print >> out
    return out.getvalue()
Exemplo n.º 4
0
def get_response_content(fs):
    out = StringIO()
    np.set_printoptions(linewidth=200)
    # look at a bunch of random induced nontrivial connected subgraphs
    f = MyCallback(fs.ndim, fs.pkeep)
    info = combobreaker.run_callable(f, nseconds=5)
    print >> out, info
    return out.getvalue()
Exemplo n.º 5
0
def get_response_content(fs):
    out = StringIO()
    np.set_printoptions(linewidth=200)
    # look at a bunch of random induced nontrivial connected subgraphs
    f = MyCallback(fs.ndim, fs.pkeep)
    info = combobreaker.run_callable(f, nseconds=5)
    print >> out, info
    return out.getvalue()
Exemplo n.º 6
0
def get_response_content(fs):
    # get the user data
    nstates = fs.nstates
    # request a limited amount of time
    nseconds = 4.0
    # get the results
    accum = Accumulate(nstates)
    info = combobreaker.run_callable(accum, nseconds=nseconds)
    return str(info)
Exemplo n.º 7
0
def get_response_content(fs):
    # get the user data
    nstates = fs.nstates
    # request a limited amount of time
    nseconds = 4.0
    # get the results
    accum = Accumulate(nstates)
    info = combobreaker.run_callable(accum, nseconds=nseconds)
    return str(info)
Exemplo n.º 8
0
def get_response_content(fs):
    headers = [
        # define the point
        'exch21',
        'exch31',
        'exch32',
        'exch41',
        'exch42',
        'exch43',
        'mutprob1',
        'mutprob2',
        'mutprob3',
        'mutprob4',
        'balprob1',
        'balprob2',
        'balprob3',
        'balprob4',
        'infotype',
        't',
        # annotate with some summary statistics
        'shannon.ent.diff',
        'logical.ent.diff',
        'log.shannon.ent.ratio',
        'log.logical.ent.ratio',
        'expected.rate.diff',
        'spectral.rate.diff',
        'log.expected.rate.ratio',
        'log.spectral.rate.ratio',
        'mi.diff',
        'fi.diff',
        'log.mi.ratio',
        'log.fi.ratio',
        # define the label
        'label',
    ]
    accum = Accumulator()
    combobreaker.run_callable(accum, nseconds=5, niterations=fs.nsamples)
    # return csv contents
    out = StringIO()
    print >> out, ', '.join(headers)
    for row in accum.rows:
        print >> out, ', '.join(str(x) for x in row)
    return out.getvalue()
Exemplo n.º 9
0
def get_response_content(fs):
    # get the user data
    nstates = fs.nstates
    # request a limited amount of time
    nseconds = 4.0
    # get the results
    if fs.bipartitioned:
        simplification = msimpl.get_fast_meta_f81_autobarrier
    else:
        simplification = msimpl.get_fast_f81
    accum = Accumulate(nstates, simplification)
    info = combobreaker.run_callable(accum, nseconds=nseconds)
    return str(info)
Exemplo n.º 10
0
def get_response_content(fs):
    # get the user data
    nstates = fs.nstates
    # request a limited amount of time
    nseconds = 4.0
    # get the results
    if fs.bipartitioned:
        simplification = msimpl.get_fast_meta_f81_autobarrier
    else:
        simplification = msimpl.get_fast_f81
    accum = Accumulate(nstates, simplification)
    info = combobreaker.run_callable(accum, nseconds=nseconds)
    return str(info)
Exemplo n.º 11
0
def get_response_content(fs):
    niterations = fs.nsamples
    ntaxa = fs.ntaxa
    nseconds = 4
    if fs.split_fiedler:
        fsplit = nhj.fsplit_fiedler
    elif fs.split_random:
        fsplit = nhj.fsplit_random
    accum = Accumulator(ntaxa, fsplit)
    info = combobreaker.run_callable(
            accum, nseconds=nseconds, niterations=niterations)
    out = StringIO()
    print >> out, str(info)
    return out.getvalue()
Exemplo n.º 12
0
def get_response_content(fs):
    niterations = fs.nsamples
    ntaxa = fs.ntaxa
    nseconds = 4
    if fs.split_fiedler:
        fsplit = nhj.fsplit_fiedler
    elif fs.split_random:
        fsplit = nhj.fsplit_random
    accum = Accumulator(ntaxa, fsplit)
    info = combobreaker.run_callable(accum,
                                     nseconds=nseconds,
                                     niterations=niterations)
    out = StringIO()
    print >> out, str(info)
    return out.getvalue()
Exemplo n.º 13
0
def get_response_content(fs):
    #
    N_hap = fs.N_diploid * 2
    # TODO check s vs N_diploid so that selection is not too big
    # as to make fitnesses negative or zero
    #
    (t1, v1), (t2, v2) = get_backward_info(
            fs.N_diploid, fs.theta, fs.Nr, fs.Ns)
    #
    f = Accum(N_hap, fs.theta / 2, fs.Nr, fs.Ns / fs.N_diploid)
    #
    nseconds_max = 5.0
    info = combobreaker.run_callable(f, nseconds_max, fs.nsamples_max)
    #
    out = StringIO()
    print >> out, 'exact results:'
    print >> out
    print >> out, 'Type-1 compensatory substitution time expectation:'
    print >> out, t1
    print >> out
    print >> out, 'Type-1 compensatory substitution time stdev:'
    print >> out, math.sqrt(v1)
    print >> out
    print >> out, 'Type-2 compensatory substitution time expectation:'
    print >> out, t2
    print >> out
    print >> out, 'Type-2 compensatory substitution stdev:'
    print >> out, math.sqrt(v2)
    print >> out
    print >> out
    print >> out, 'forward sampling results (%s Type-1, %s Type-2):' % (
            len(f.type_1_times), len(f.type_2_times))
    print >> out
    print >> out, 'Type-1 compensatory substitution time expectation:'
    print >> out, np.mean(f.type_1_times)
    print >> out
    print >> out, 'Type-1 compensatory substitution time stdev:'
    print >> out, np.std(f.type_1_times)
    print >> out
    print >> out, 'Type-2 compensatory substitution time expectation:'
    print >> out, np.mean(f.type_2_times)
    print >> out
    print >> out, 'Type-2 compensatory substitution time stdev:'
    print >> out, np.std(f.type_2_times)
    print >> out
    return out.getvalue()
Exemplo n.º 14
0
def get_response_content(fs):
    #
    N_hap = fs.N_diploid * 2
    # TODO check s vs N_diploid so that selection is not too big
    # as to make fitnesses negative or zero
    #
    (t1, v1), (t2, v2) = get_backward_info(fs.N_diploid, fs.theta, fs.Nr,
                                           fs.Ns)
    #
    f = Accum(N_hap, fs.theta / 2, fs.Nr, fs.Ns / fs.N_diploid)
    #
    nseconds_max = 5.0
    info = combobreaker.run_callable(f, nseconds_max, fs.nsamples_max)
    #
    out = StringIO()
    print >> out, 'exact results:'
    print >> out
    print >> out, 'Type-1 compensatory substitution time expectation:'
    print >> out, t1
    print >> out
    print >> out, 'Type-1 compensatory substitution time stdev:'
    print >> out, math.sqrt(v1)
    print >> out
    print >> out, 'Type-2 compensatory substitution time expectation:'
    print >> out, t2
    print >> out
    print >> out, 'Type-2 compensatory substitution stdev:'
    print >> out, math.sqrt(v2)
    print >> out
    print >> out
    print >> out, 'forward sampling results (%s Type-1, %s Type-2):' % (len(
        f.type_1_times), len(f.type_2_times))
    print >> out
    print >> out, 'Type-1 compensatory substitution time expectation:'
    print >> out, np.mean(f.type_1_times)
    print >> out
    print >> out, 'Type-1 compensatory substitution time stdev:'
    print >> out, np.std(f.type_1_times)
    print >> out
    print >> out, 'Type-2 compensatory substitution time expectation:'
    print >> out, np.mean(f.type_2_times)
    print >> out
    print >> out, 'Type-2 compensatory substitution time stdev:'
    print >> out, np.std(f.type_2_times)
    print >> out
    return out.getvalue()
Exemplo n.º 15
0
def get_response_content(fs):
    #
    N_hap = fs.N_diploid * 2
    # TODO check s vs N_diploid so that selection is not too big
    # as to make fitnesses negative or zero
    #
    t, v = get_backward_info(
            fs.N_diploid, fs.theta, fs.Nr, fs.Ns)
    #
    f = Accum(N_hap, fs.theta / 2, fs.Nr, fs.Ns / fs.N_diploid)
    nseconds_max = 5.0
    info = combobreaker.run_callable(f, nseconds_max, fs.nsamples_max)
    #
    out = StringIO()
    print >> out, 'sampling info:'
    print >> out
    print >> out, info
    print >> out
    print >> out
    print >> out, 'exact results:'
    print >> out
    print >> out, 'compensatory substitution time expectation:'
    print >> out, t
    print >> out
    print >> out, 'compensatory substitution time variance:'
    print >> out, v
    print >> out
    print >> out
    print >> out, 'forward sampling results:'
    print >> out
    print >> out, 'compensatory substitution time expectation:'
    print >> out, np.mean(f.times)
    print >> out
    print >> out, 'compensatory substitution time variance:'
    print >> out, np.var(f.times)
    print >> out
    return out.getvalue()
Exemplo n.º 16
0
def process(nstates, nseconds):
    f = Checker(nstates)
    info = combobreaker.run_callable(f, nseconds=nseconds, niterations=None)
    return str(info)
Exemplo n.º 17
0
def get_response_content(fs):
    nseconds = 4.0
    accum = Accumulate(fs.nstates)
    info = combobreaker.run_callable(accum, nseconds=nseconds)
    return str(info)
Exemplo n.º 18
0
def process(nstates, nseconds):
    f = Checker(nstates)
    info = combobreaker.run_callable(f, nseconds=nseconds, niterations=None)
    return str(info)
Exemplo n.º 19
0
def get_response_content(fs):
    nseconds = 4.0
    accum = Accumulate(fs.nstates)
    info = combobreaker.run_callable(accum, nseconds=nseconds)
    return str(info)