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


Python Tree.new_treecollection_tree方法代码示例

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


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

示例1: get_best_TC_tree

# 需要导入模块: from tree import Tree [as 别名]
# 或者: from tree.Tree import new_treecollection_tree [as 别名]
def get_best_TC_tree(
    dv_file,
    gm_file,
    label_file,
    tree_files,
    name='unnamed_tree',
    ):
    """
    Given a distance-variance file, a genome-map file, a label file
    and a number of tree files
    """

    if not isinstance(tree_files, list):
        return Tree.new_treecollection_tree(dv_file, gm_file,
                label_file, tree_files, name)
    best_score = float('inf')
    best_tree = None
    starts = len(tree_files)

    for i in range(starts):
        guide = tree_files[i]
        current_tree = Tree.new_treecollection_tree(dv_file, gm_file,
                label_file, guide, name)
        if current_tree.score < best_score:
            best_score = current_tree.score
            best_tree = current_tree

    return best_tree
开发者ID:kgori,项目名称:clustering_project,代码行数:30,代码来源:cluster_TC_input.py

示例2: _put_best_TC_trees

# 需要导入模块: from tree import Tree [as 别名]
# 或者: from tree.Tree import new_treecollection_tree [as 别名]
 def _put_best_TC_trees(self, tmpdir="/tmp", overwrite=True, max_guide_trees=-1):
     rec_list = self.get_cluster_records_with_memberships()
     for (rec, members) in rec_list:
         print "Calculating treecollection tree for {0}".format(rec.name),
         if rec.name in self.inferred_trees and overwrite == False:
             print "Skipping - already calculated (overwrite set to False)"
             continue
         guidetrees = [self.keys_to_records[member].tree for member in members]
         if max_guide_trees > 0:
             guidetrees = guidetrees[:max_guide_trees]
         TCtrees = []
         pref = rec._write_temp_tc(make_guide_tree=False, tmpdir=tmpdir)
         pref = "{0}/{1}".format(tmpdir, pref)
         dv_file = pref + "_dv.txt"
         labels_file = pref + "_labels.txt"
         map_file = pref + "_map.txt"
         if len(guidetrees) > 1:
             print "(using best of {0} guidetrees)".format(len(guidetrees))
         else:
             print "(using single guidetree)"
         for t in guidetrees:
             guidetree_file = "{0}/{1}.nwk".format(tmpdir, t.name)
             n = t.reroot_newick()
             with open(guidetree_file, "w") as writer:
                 writer.write(n)
             TCtrees.append(Tree.new_treecollection_tree(dv_file, map_file, labels_file, guidetree_file, rec.name))
         best = min(TCtrees, key=lambda x: x.score)
         rec.tree = best
         self.inferred_trees[rec.name] = best
     self.update_scores()
开发者ID:kgori,项目名称:clustering_project,代码行数:32,代码来源:sequence_collection.py


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