def main(ddir, rrange = None):
    read_parameters(ddir)

    tf = open("%s/tree" % (ddir))
    t = newickToTree(tf.read())
    root = "N1"
    parent, children = findParentsAndChildren(t, root)
    treestr = rootedTreeToStr(parent, children, root)
    open("%s/tree.full" % (ddir), "w").write(treestr)

    evidence_cpds = read_evidence_cpds("%s/%s" % (ddir, common.CPD_DIR))
    internal_cpds = read_internal_cpds("%s/%s" % (ddir, common.TREE_CPD_FILE))
    
    ef = open("%s/evidence" % (ddir))
    evidence = read_evidence(ef)



    model, observed_species, ancestors = build_model(t, evidence_cpds, internal_cpds)
    naive_model, spec2, anc2 = build_naive_model(t, evidence_cpds)
    blast_model, spec3, anc3 = build_blast_model(t, evidence_cpds, internal_cpds)
    gtg_model, spec4, anc4 = build_gtg_model(t, evidence_cpds, internal_cpds)

    complete_evidence(evidence, observed_species)

    # compute posteriors
    of = open("%s/reaction-scores" % (ddir), "w")
    of.write("#Generated by \"%s\" on %s\n" % (" ".join(sys.argv), datetime.datetime.now()))
    if rrange != None:
        of.write("#Reaction range: %s\n" % (rrange))
    compute_reaction_scores(model, naive_model, 
                            blast_model, gtg_model, evidence, 
                            observed_species, ancestors, of, rrange)
Ejemplo n.º 2
0
def main(ddir, rrange=None):
    read_parameters(ddir)

    tf = open("%s/tree" % (ddir))
    t = newickToTree(tf.read())
    root = "N1"
    parent, children = findParentsAndChildren(t, root)
    treestr = rootedTreeToStr(parent, children, root)
    open("%s/tree.full" % (ddir), "w").write(treestr)

    evidence_cpds = read_evidence_cpds("%s/%s" % (ddir, common.CPD_DIR))
    internal_cpds = read_internal_cpds("%s/%s" % (ddir, common.TREE_CPD_FILE))

    ef = open("%s/evidence" % (ddir))
    evidence = read_evidence(ef)

    model, observed_species, ancestors = build_model(t, evidence_cpds,
                                                     internal_cpds)
    naive_model, spec2, anc2 = build_naive_model(t, evidence_cpds)
    blast_model, spec3, anc3 = build_blast_model(t, evidence_cpds,
                                                 internal_cpds)
    gtg_model, spec4, anc4 = build_gtg_model(t, evidence_cpds, internal_cpds)

    complete_evidence(evidence, observed_species)

    # compute posteriors
    of = open("%s/reaction-scores" % (ddir), "w")
    of.write("#Generated by \"%s\" on %s\n" %
             (" ".join(sys.argv), datetime.datetime.now()))
    if rrange != None:
        of.write("#Reaction range: %s\n" % (rrange))
    compute_reaction_scores(model, naive_model, blast_model, gtg_model,
                            evidence, observed_species, ancestors, of, rrange)
Ejemplo n.º 3
0
def read_tree(fn):
    return tree.newickToTree(open(fn).read())
Ejemplo n.º 4
0
def read_tree(fn):
    return tree.newickToTree(open(fn).read())