当前位置: 首页>>代码示例>>Python>>正文


Python Tree.mrca方法代码示例

本文整理汇总了Python中dendropy.Tree.mrca方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.mrca方法的具体用法?Python Tree.mrca怎么用?Python Tree.mrca使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dendropy.Tree的用法示例。


在下文中一共展示了Tree.mrca方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: reroot_tree

# 需要导入模块: from dendropy import Tree [as 别名]
# 或者: from dendropy.Tree import mrca [as 别名]
def reroot_tree(tstr):
    """Input: a tree path to a Newick tree.  Output: a re-rooted version of the tree, based on the outgroup defined in configuration.py"""
    t = Tree()
    t.read_from_string(tstr.__str__(), "newick")
    og = ap.params["outgroup"]
    og = re.sub("\[", "", og)
    og = re.sub("\]", "", og)
    og = re.sub("\"", "", og)
    ogs = og.split(",")
    mrca = t.mrca(taxon_labels=ogs)
    t.reroot_at_edge(mrca.edge, update_splits=False)
    ret = t.as_string("newick")
    ret = re.sub("\[\&\R\] ", "", ret)
    ret = ret.strip()
    return ret
开发者ID:bkacar,项目名称:asr-pipeline,代码行数:17,代码来源:tools.py

示例2: reroot_newick

# 需要导入模块: from dendropy import Tree [as 别名]
# 或者: from dendropy.Tree import mrca [as 别名]
def reroot_newick(con, newick):
    """Provide a newick string, this method will re-root the tree
        based on the 'outgroup' setting."""
    cur = con.cursor()
    dendrotree = Tree()
    dendrotree.read_from_string(newick, "newick")
    sql = "select shortname from Taxa where id in (select taxonid from GroupsTaxa where groupid in (select id from TaxaGroups where name='outgroup'))"
    cur.execute(sql)
    rrr = cur.fetchall()
    outgroup_labels = []
    for iii in rrr:
        label = re.sub("_", " ", iii[0])
        outgroup_labels.append( label.__str__() )
    
    mrca = dendrotree.mrca(taxon_labels=outgroup_labels)
    if mrca.edge.tail_node != None and mrca.edge.head_node != None:
        dendrotree.reroot_at_edge(mrca.edge, update_splits=True)
    newick = dendrotree.as_string("newick")
    return newick
开发者ID:bkacar,项目名称:asr-pipeline,代码行数:21,代码来源:tools.py


注:本文中的dendropy.Tree.mrca方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。