def test_sample_birth_times(self): stree = read_tree("test/data/flies.stree") birth = 8.1 death = 2.1 * 1.0001 print spidir.birthDeathCount(4, .005, birth, death) print spidir.birthDeathCounts(1, 4, .005, birth, death) maxgenes = [5, 10, 20, 40, 50] tic("time") counts = [2, 2, 3, 3, 3, 2, 1, 1, 1, 3, 3, 2] for maxgene in maxgenes: logl = spidir.birth_death_tree_counts(stree, counts, birth, death, maxgene=maxgene, rootgene=1) print maxgene, logl toc() counts = [1] * 12 for maxgene in maxgenes: logl = spidir.birth_death_tree_counts(stree, counts, birth, death, maxgene=maxgene, rootgene=1) print maxgene, logl counts = [4] * 12 for maxgene in maxgenes: logl = spidir.birth_death_tree_counts(stree, counts, birth, death, maxgene=maxgene, rootgene=1) print maxgene, logl
def test_birth_death(self): counts = list(range(1, 10)) birth = 0.01 death = 0.02 t = 1.0 for a in range(1, 10): for b in range(0, 10): l = spidir.birthDeathCounts(a, b, t, birth, death) #l2 = spidir.birthDeathCounts2(a, b, t, birth, death) l2 = l l3 = birthdeath.prob_birth_death(a, b, t, birth, death) print a, b, l, l2, l3 #fequal(l, l2, .1) fequal(l, l3, .01) fequal(sum(spidir.birthDeathCounts(a, b, t, birth, death) for b in xrange(0, 20)), 1.0, .001)
def test_birthDeathCounts2(self): """birthDeathCounts""" l = 3.0 u = .5 t = 1.0 for s in range(1, 40): for e in range(0, 40): p1 = spidir.birthDeathCounts(s, e, t, l, u) p2 = birthdeath.prob_birth_death(s, e, t, l, u) print s, e, p1, p2 fequal(p1, p2, .01)
def test_birth_death(self): counts = list(range(1, 10)) birth = 0.01 death = 0.02 t = 1.0 for a in range(1, 10): for b in range(0, 10): l = spidir.birthDeathCounts(a, b, t, birth, death) #l2 = spidir.birthDeathCounts2(a, b, t, birth, death) l2 = l l3 = birthdeath.prob_birth_death(a, b, t, birth, death) print a, b, l, l2, l3 #fequal(l, l2, .1) fequal(l, l3, .01) fequal( sum( spidir.birthDeathCounts(a, b, t, birth, death) for b in xrange(0, 20)), 1.0, .001)
def test_birth_death_same(self): counts = list(range(1, 10)) birth = .2 death = .1 lam = birth t = 10.4 for a in range(1, 10): for b in range(0, 10): l = spidir.birthDeathCounts(a, b, t, birth, death) #l2 = spidir.birthDeathCounts2(a, b, t, birth, death*.999) #l2 = prob_birth_death_same(a, b, t, lam) l2 = l l3 = birthdeath.prob_birth_death(a, b, t, birth, death) print a, b, l, l2, l3 #fequal(l, l2, .01) fequal(l, l3, .01)
def test_birth_death_large(self): t = 0.0392320007 birth = 0.400400013 death = 0.400000006 print "large" print birthdeath.prob_birth_death(60, 71, t, birth, death) print spidir.birthDeathCounts2(60, 71, t, birth, death) print spidir.birthDeathCounts(60, 71, t, birth, death) t = 0.067008 birth = 0.010100 death = 0.010000 print spidir.birthDeathCounts(51, 51, t, birth, death) print spidir.birthDeathCounts2(51, 51, t, birth, death) print spidir.birthDeathCounts(51, 51, t, birth, death)
def test_birthDeathCounts3(self): """birthDeathCounts""" print spidir.birthDeathCounts(30, 33, .05, 173.2958, 171.58002) print spidir.birthDeathCounts(26, 27, 0.068190, 173.2958, 171.58002)