本文整理汇总了Python中Search.searchMCMC方法的典型用法代码示例。如果您正苦于以下问题:Python Search.searchMCMC方法的具体用法?Python Search.searchMCMC怎么用?Python Search.searchMCMC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search.searchMCMC方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: spidir
# 需要导入模块: import Search [as 别名]
# 或者: from Search import searchMCMC [as 别名]
def spidir(conf, distmat, labels, stree, gene2species, params):
"""Main function for the SPIDIR algorithm"""
setDebug(conf["debug"])
if isDebug(DEBUG_HIGH) and pyspidir:
pyspidir.set_log(3, "")
if "out" in conf:
# create debug table
conf["debugtab_file"] = file(conf["out"] + ".debug.tab", "w")
debugtab = tablelib.Table(headers=["correct",
"logl", "treelen", "baserate",
"error", "errorlogl",
"eventlogl", "tree",
"topology", "species_hash"],
types={"correct": bool,
"logl": float,
"treelen": float,
"baserate": float,
"error": float,
"errorlogl": float,
"eventlogl": float,
"tree": str,
"topology": str,
"species_hash": str})
debugtab.writeHeader(conf["debugtab_file"])
conf["debugtab"] = debugtab
else:
conf["debugfile"] = None
trees = []
logls = []
tree = None
visited = {}
util.tic("SPIDIR")
# do auto searches
for search in conf["search"]:
util.tic("Search by %s" % search)
if search == "greedy":
tree, logl = Search.searchGreedy(conf, distmat, labels, stree,
gene2species, params,
visited=visited)
elif search == "mcmc":
tree, logl = Search.searchMCMC(conf, distmat, labels, stree,
gene2species, params, initTree=tree,
visited=visited)
elif search == "regraft":
tree, logl = Search.searchRegraft(conf, distmat, labels, stree,
gene2species, params, initTree=tree,
visited=visited, proposeFunc=Search.proposeTree3)
elif search == "exhaustive":
if tree == None:
tree = phylo.neighborjoin(distmat, labels)
tree = phylo.recon_root(tree, stree, gene2species)
tree, logl = Search.searchExhaustive(conf, distmat, labels, tree, stree,
gene2species, params,
depth=conf["depth"],
visited=visited)
elif search == "hillclimb":
tree, logl = Search.searchHillClimb(conf, distmat, labels, stree,
gene2species, params, initTree=tree,
visited=visited)
elif search == "none":
break
else:
raise SindirError("unknown search '%s'" % search)
util.toc()
Search.printMCMC(conf, "N/A", tree, stree, gene2species, visited)
printVisitedTrees(visited)
def evalUserTree(tree):
setTreeDistances(conf, tree, distmat, labels)
logl = treeLogLikelihood(conf, tree, stree, gene2species, params)
thash = phylo.hash_tree(tree)
if thash in visited:
a, b, count = visited[thash]
else:
count = 0
visited[thash] = [logl, tree.copy(), count+1]
if isDebug(DEBUG_LOW):
debug("\nuser given tree:")
recon = phylo.reconcile(tree, stree, gene2species)
#.........这里部分代码省略.........