本文整理汇总了Python中tree.Tree.new_random_coal方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.new_random_coal方法的具体用法?Python Tree.new_random_coal怎么用?Python Tree.new_random_coal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree.Tree
的用法示例。
在下文中一共展示了Tree.new_random_coal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_master_tree
# 需要导入模块: from tree import Tree [as 别名]
# 或者: from tree.Tree import new_random_coal [as 别名]
def make_master_tree(
n,
method,
names=None,
inner_edge_params=(1, 1),
leaf_params=(1, 1),
distribution_func=np.random.gamma,
):
"""
Function returns a tree object with n tips,
named according to `names`, and constructed
according to `method`, which is one of 'random_topology',
'random_yule' and 'random_coal'
"""
if method == 'random_topology':
master_topology = Tree.new_random_topology(n,
names=names, rooted=True)
master_tree = \
master_topology.randomise_branch_lengths(inner_edges=inner_edge_params,
leaves=leaf_params,
distribution_func=branch_length_func)
master_tree.newick = '[&R] ' + master_tree.newick
elif method == 'random_yule':
master_tree = Tree.new_random_yule(n, names=names)
elif method == 'random_coal':
master_tree = Tree.new_random_coal(n, names=names)
return master_tree
示例2: run
# 需要导入模块: from tree import Tree [as 别名]
# 或者: from tree.Tree import new_random_coal [as 别名]
print 'There was an IOError: {0}'.format(e)
print 'Geodesic distances couldn\'t be calculated'
raise
def run(self, trees):
self.writetmp(trees)
rooted = self.allrooted(trees)
self.call(rooted)
try:
matrix = self.read(len(trees))
self.clean()
return matrix
except IOError:
print 'except'
matrix = None
raise
def writetmp(self, trees):
with open('{0}/geotrees.nwk'.format(self.tmpdir), 'w') as tmpf:
tmpf.write('\n'.join(tree.newick.rstrip() for tree in
trees))
if __name__ == '__main__':
from tree import Tree
trees = [Tree.new_random_coal(10) for _ in range(100)]
g = GTP()
print g
m = g.run(trees)
print m