def testContract(): import taxa2image E = [(0,7),(7,8),(8,9),(1,9),(9,11),(2,10),(3,10),(10,11),(11,14),(13,14),(13,6),(12,13),(4,12),(5,12)] A = edgeListToAdjMap(E) labels = {} for u in A: labels[u] = u taxa2image.graphToImage("test.ps", E, labels) T = contractNonJunctions(A) T = adjMapToEdgeList(T) labels = {} for u in A: labels[u] = u taxa2image.graphToImage("test2.ps", T, labels)
def testNewickToTree(): print "=== testNewickToTree() ===" s = "(uma,((cne,dpch),(spo,((((ure,cim),(aor,(ani,afm))),(((mgr,ncr),fgr),ssl)),(yli,(((pgu,dha),(ctp,cal)),((cgr,sce),(kla,ago))))))));" s = "(uma,((cne,dpch),(spo,(((aor,(ani,afm)),((mgr,ncr),fgr)),(yli,((dha),((cgr,sce),(kla,ago))))))));" s = "(uma,((cne,dpch),(spo,(((aor,(ani,afm)),((mgr,ncr),fgr)),(yli,(dha,((cgr,sce),(kla,ago))))))));" A = newickToTree(s) E = adjMapToEdgeList(A) #print A #print E import taxa2image labels = {} for u in A: labels[u] = u taxa2image.graphToImage("test1.ps", E, labels) print "Check test1.ps"
def testContract(): import taxa2image E = [(0, 7), (7, 8), (8, 9), (1, 9), (9, 11), (2, 10), (3, 10), (10, 11), (11, 14), (13, 14), (13, 6), (12, 13), (4, 12), (5, 12)] A = edgeListToAdjMap(E) labels = {} for u in A: labels[u] = u taxa2image.graphToImage("test.ps", E, labels) T = contractNonJunctions(A) T = adjMapToEdgeList(T) labels = {} for u in A: labels[u] = u taxa2image.graphToImage("test2.ps", T, labels)
def testExpandShoots(): import taxa2image labels = {} E = [(1,3),(2,3),(3,4),(4,5),(4,6),(6,8),(6,7)] A = edgeListToAdjMap(E) nodes = set([4,3]) T = adjMapToEdgeList(expandShoots(A, nodes)) for u in A: labels[u] = u print T taxa2image.graphToImage("test1.ps", T, labels) nodes = set([3,4,6]) E = [(1,3),(2,3),(3,4),(4,5),(4,6),(6,8),(6,7),(4,9),(9,10),(9,11),(6,12),(12,13),(12,14)] E = [(1,3),(2,3),(3,4),(4,5),(4,6),(6,8),(6,7)] A = edgeListToAdjMap(E) T = adjMapToEdgeList(expandShoots(A, nodes)) labels = {} for u in A: labels[u] = u print T taxa2image.graphToImage("test2.ps", T, labels) nodes = set([3,4,6,9,10,12]) E = [(1,3),(2,3),(3,4),(4,5),(4,6),(6,8),(6,7),(4,9),(9,10),(9,11),(6,12),(12,13),(12,14)] A = edgeListToAdjMap(E) T = adjMapToEdgeList(expandShoots(A, nodes)) labels = {} for u in A: labels[u] = u print T taxa2image.graphToImage("test3.ps", T, labels)
def testExpandShoots(): import taxa2image labels = {} E = [(1, 3), (2, 3), (3, 4), (4, 5), (4, 6), (6, 8), (6, 7)] A = edgeListToAdjMap(E) nodes = set([4, 3]) T = adjMapToEdgeList(expandShoots(A, nodes)) for u in A: labels[u] = u print T taxa2image.graphToImage("test1.ps", T, labels) nodes = set([3, 4, 6]) E = [(1, 3), (2, 3), (3, 4), (4, 5), (4, 6), (6, 8), (6, 7), (4, 9), (9, 10), (9, 11), (6, 12), (12, 13), (12, 14)] E = [(1, 3), (2, 3), (3, 4), (4, 5), (4, 6), (6, 8), (6, 7)] A = edgeListToAdjMap(E) T = adjMapToEdgeList(expandShoots(A, nodes)) labels = {} for u in A: labels[u] = u print T taxa2image.graphToImage("test2.ps", T, labels) nodes = set([3, 4, 6, 9, 10, 12]) E = [(1, 3), (2, 3), (3, 4), (4, 5), (4, 6), (6, 8), (6, 7), (4, 9), (9, 10), (9, 11), (6, 12), (12, 13), (12, 14)] A = edgeListToAdjMap(E) T = adjMapToEdgeList(expandShoots(A, nodes)) labels = {} for u in A: labels[u] = u print T taxa2image.graphToImage("test3.ps", T, labels)