本文整理汇总了Python中Tree.postorder_cheat_traverse方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.postorder_cheat_traverse方法的具体用法?Python Tree.postorder_cheat_traverse怎么用?Python Tree.postorder_cheat_traverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree.postorder_cheat_traverse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: optimize_branch_func
# 需要导入模块: import Tree [as 别名]
# 或者: from Tree import postorder_cheat_traverse [as 别名]
def optimize_branch_func(self, parent, child, t_a):
"""
<t_a> is the new branch length between <parent> --- <child>
(t_a is dressed in an array...should always be just [t_a])
We can cheat & speed up likelihood calculation
by re-using likelihods of subtrees below child and T'
where T' is the subtree under root that does not contain parent/child
Returns: POSITIVE sum of log likelihood (so we try to minimize it)
currently wrapped up by ::optimize_branch::
NOTE: it is ::optimize_branch::'s responsibility to update
self.order and self.like when all is done!!!
p.s. potentialy speed-up by simultaneously optimizing two child branches
of the same parent??
"""
#assert len(t_a) == 1
g = MyMat.calc_likelihood
child.edge_length = t_a[0]
# TODO: make this more efficient!
cheat_order = Tree.postorder_cheat_traverse(parent)
L_single = g(self.single_model.gtr.R, self.S, self.log_freq_single, \
cheat_order, range(self.ncol), self.nnode, self.ncol, self.nbase)
L_paired = g(self.paired_model.gtr.R, self.P, self.log_freq_paired, \
cheat_order, range(self.ncol_p), self.nnode_p, self.ncol_p, self.nbase_p)
return -(L_single.sum() + L_paired.sum())
示例2: reversible_subtree_func
# 需要导入模块: import Tree [as 别名]
# 或者: from Tree import postorder_cheat_traverse [as 别名]
def reversible_subtree_func(copy_S, copy_P, parent, child, t_a):
#assert len(t_a) == 1
child.edge_length = t_a[0]
order = Tree.postorder_cheat_traverse(parent)
L_single = g(tlobj.single_model.gtr.R, copy_S, tlobj.log_freq_single, \
order, range(tlobj.ncol), tlobj.nnode, tlobj.ncol, tlobj.nbase)
L_paired = g(tlobj.paired_model.gtr.R, copy_P, tlobj.log_freq_paired, \
order, range(tlobj.ncol_p), tlobj.nnode_p, tlobj.ncol_p, tlobj.nbase_p)
ans = -(L_single.sum() + L_paired.sum())
return ans