Example #1
0
    def test_sampleLabelings(self):
        tree = Tree("(A:1,(B:1,(C:1,(E:1,D:1)Int_1:0.5[&&NHX:ancient=1])Int_2:0.5[&&NHX:ancient=0])Int_3:1)Root;", format=1)
        chrom = {}
        chrom["one"] = ["3","4"]
        species = {}
        species["C"] = chrom
        chrom = {}
        chrom["one"] = ["3","4"]
        species["D"] = chrom
        chrom = {}
        chrom["one"] = []
        species["E"] = chrom
        chrom = {}
        chrom["one"] = []
        species["A"] = chrom
        chrom = {}
        chrom["one"] = []
        species["B"] = chrom

        adj = getAdjacencies.findAdjacencies(species)
        paths = getAdjacencies.findTreePaths(tree)
        internal,adjacenciesAncestral = getAdjacencies.assignAncestralAdjacencies(paths,adj,tree)
        graphs = globalAdjacencyGraph.createGraph(adj,adjacenciesAncestral)
        jointLabels, first = SR.enumJointLabelings(graphs)
        probs={"Int_1":{(6, 7):0.1},"Int_2":{(6, 7):0.1},"Int_3":{(6, 7):0.1},"Root":{(6, 7):0.1}}
        for i in range(0,10):
            validLabels, validAtNode = SR.validLabels(jointLabels,first)
            resolvedCCs = SR.sampleLabelings(tree, graphs, validAtNode, adj,probs, alpha=0)
            reconstructedAdj = SR.reconstructedAdjacencies(resolvedCCs)
            print reconstructedAdj
Example #2
0
            nodesPerAdjacency.update({adj:spec})
    #filling adjacencyProbs with internal nodes
    if species in adjacencyProbs:
            adjacencyProbs[species][adj] = weight
    else:
            adjacencyProbs[species]={adj:weight}

    line=f.readline()
f.close()


#dictionary for all scj distances
dict_SCJ={}

#compute CCs in global adjacency graph
ccs = globalAdjacencyGraph.createGraph(extantAdjacencies,nodesPerAdjacency)
if (not args.skip_first):
    conflicts = globalAdjacencyGraph.analyseConnectedComponents(ccs)
    globalAdjacencyGraph.outputConflicts(conflicts,args.output+"/conflicts")

    jointLabels, first = SR.enumJointLabelings(ccs)
    validLabels, validAtNode = SR.validLabels(jointLabels,first)

    topDown = SR.computeLabelings(tree, ccs, validAtNode, extantAdjacencies, adjacencyProbs, args.alpha)

    reconstructedAdj = SR.reconstructedAdjacencies(topDown)
    SR.outputReconstructedAdjacencies(reconstructedAdj,args.output+"/reconstructed_adjacencies")
    for node in reconstructedAdj:
        print node
        print "Number of reconstructed adjacencies: "+str(len(reconstructedAdj[node]))