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


Python NewickIO.get_narrow_newick_string方法代码示例

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


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

示例1: get_form

# 需要导入模块: import NewickIO [as 别名]
# 或者: from NewickIO import get_narrow_newick_string [as 别名]
def get_form():
    """
    @return: the body of a form
    """
    # define the tree string
    tree_string = '(((a:0.05, b:0.05):0.15, c:0.2):0.8, x:1.0, (((m:0.05, n:0.05):0.15, p:0.2):0.8, y:1.0):1.0);'
    tree = NewickIO.parse(tree_string, FelTree.NewickTree)
    formatted_tree_string = NewickIO.get_narrow_newick_string(tree, 60)
    # define the object list
    form_objects = [
            Form.MultiLine('tree', 'tree',
                formatted_tree_string),
            Form.Integer('sequence_length', 'use sequences that are this long',
                100, low=1),
            Form.RadioGroup('assumption', 'distance matrix sampling model', [
                RadioItem('infinite_alleles', 'infinite alleles', True),
                RadioItem('jukes_cantor', 'Jukes-Cantor model (4 alleles)')]),
            Form.RadioGroup('infinity', 'matrices with infinite distances', [
                RadioItem('reject_infinity', 'reject these matrices', True),
                RadioItem('replace_infinity', 'use 20 instead')]),
            Form.RadioGroup('zero', 'matrices with zero distances', [
                RadioItem('reject_zero', 'reject these matrices'),
                RadioItem('replace_zero', 'use .00001 instead'),
                RadioItem('remain_zero', 'use 0 unmodified', True)]),
            Form.RadioGroup('criterion', 'tree reconstruction criterion', [
                RadioItem('sign', 'spectral sign approximation', True),
                RadioItem('nj', 'neighbor joining'),
                RadioItem('random', 'random bipartition')])]
    # return the object list
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:32,代码来源:20080918a.py

示例2: get_form

# 需要导入模块: import NewickIO [as 别名]
# 或者: from NewickIO import get_narrow_newick_string [as 别名]
def get_form():
    """
    @return: the body of a form
    """
    # define the default tree string
    tree = get_default_original_tree()
    formatted_tree_string = NewickIO.get_narrow_newick_string(tree, 60)
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'original tree with branch lengths',
                formatted_tree_string),
            Form.Integer('iterations', 'reconstruct this many trees',
                10, low=1),
            Form.Integer('length', 'use sequences that are this long',
                100, low=2),
            Form.RadioGroup('criterion', 'bipartition function', [
                RadioItem('exact', 'exact criterion'),
                RadioItem('sign', 'spectral sign approximation', True),
                RadioItem('threshold', 'spectral threshold approximation'),
                RadioItem('nj', 'neighbor joining criterion'),
                RadioItem('random', 'random bipartition')]),
            Form.RadioGroup('recourse', 'recourse for degenerate partitions', [
                RadioItem('njrecourse', 'neighbor joining', True),
                RadioItem('halvingrecourse', 'leaf stem length halving')]),
            Form.CheckGroup('output_options', 'extra output option', [
                CheckItem('showtrees', 'show reconstructed tree topologies')])]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:29,代码来源:20080828a.py

示例3: get_form

# 需要导入模块: import NewickIO [as 别名]
# 或者: from NewickIO import get_narrow_newick_string [as 别名]
def get_form():
    """
    @return: a list of form objects
    """
    tree = NewickIO.parse(g_default_string, FelTree.NewickTree)
    formatted_tree_string = NewickIO.get_narrow_newick_string(tree, 60)
    return [Form.MultiLine('tree', 'tree', formatted_tree_string)]
开发者ID:argriffing,项目名称:xgcode,代码行数:9,代码来源:20081120a.py

示例4: get_form

# 需要导入模块: import NewickIO [as 别名]
# 或者: from NewickIO import get_narrow_newick_string [as 别名]
def get_form():
    """
    @return: the body of a form
    """
    # define the default tree string and ordered tip labels
    tree_string = "(a:1, (b:2, d:5):1, c:4);"
    tree = NewickIO.parse(tree_string, FelTree.NewickTree)
    formatted_tree_string = NewickIO.get_narrow_newick_string(tree, 60)
    labels = list(sorted(tip.name for tip in tree.gen_tips()))
    # define the form objects
    form_objects = [
        Form.MultiLine("tree", "newick tree", formatted_tree_string),
        Form.MultiLine("inlabels", "ordered labels", "\n".join(labels)),
        Form.Float("strength", "perturbation strength", 0.1, low_inclusive=0),
        Form.CheckGroup(
            "options",
            "output options",
            [
                CheckItem("perturbed", "a perturbed distance matrix", True),
                CheckItem("distance", "the original distance matrix"),
                CheckItem("outlabels", "ordered labels"),
            ],
        ),
    ]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:27,代码来源:20080703a.py

示例5: get_form

# 需要导入模块: import NewickIO [as 别名]
# 或者: from NewickIO import get_narrow_newick_string [as 别名]
def get_form():
    """
    @return: the body of a form
    """
    # define the default tree string
    tree = NewickIO.parse(g_default_string, FelTree.NewickTree)
    formatted_tree_string = NewickIO.get_narrow_newick_string(tree, 60)
    # define the form objects
    form_objects = [
            Form.MultiLine('tree',
                'newick tree with branch lengths', formatted_tree_string),
            Form.SingleLine('lhs_a',
                'the first taxon on one side of the split', 'a'),
            Form.SingleLine('lhs_b',
                'the second taxon on one side of the split', 'b'),
            Form.SingleLine('rhs_a',
                'the first taxon on the other side of the split', 'x'),
            Form.SingleLine('rhs_b',
                'the second taxon on the other side of the split', 'y'),
            Form.CheckGroup('options', 'output options', [
                Form.CheckItem('show_response',
                    'show the full Laplacian matrix'),
                Form.CheckItem('show_reduced_response',
                    'show the 2x2 submatrix'),
                Form.CheckItem('show_blen',
                    'show the branch length implied by the split')])]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:29,代码来源:20090209a.py

示例6: get_response_content

# 需要导入模块: import NewickIO [as 别名]
# 或者: from NewickIO import get_narrow_newick_string [as 别名]
def get_response_content(fs):
    # read the tree
    tree = NewickIO.parse(fs.tree, Newick.NewickTree) 
    # begin the response
    out = StringIO()
    # remove the branch length associated with the root
    if tree.get_root().blen is not None:
        print >> out, 'the root originally had a branch length of', tree.get_root().blen
        tree.get_root().blen = None
    else:
        print >> out, 'the root did not originally have a branch length'
    # force a trifurcation at the root
    if tree.get_root().get_child_count() < 3:
        print >> out, 'the original root had', tree.get_root().get_child_count(), 'children'
        max_children, best_child = max((child.get_child_count(), child) for child in tree.get_root().gen_children())
        old_root = tree.get_root()
        tree.reroot(best_child)
        tree.remove_node(old_root)
        print >> out, 'the new root has', tree.get_root().get_child_count(), 'children'
    else:
        print >> out, 'the root has', tree.get_root().get_child_count(), 'children'
    # remove names of internal nodes
    nremoved_names = 0
    for node in tree.preorder():
        if node.has_children() and node.name is not None:
            node.name = None
            nremoved_names += 1
    print >> out, 'removed', nremoved_names, 'internal node names'
    # draw the new formatted newick string after a break
    print >> out
    formatted_tree_string = NewickIO.get_narrow_newick_string(tree, 120) 
    print >> out, formatted_tree_string
    # return the response
    return out.getvalue()
开发者ID:argriffing,项目名称:xgcode,代码行数:36,代码来源:20090803a.py

示例7: get_form

# 需要导入模块: import NewickIO [as 别名]
# 或者: from NewickIO import get_narrow_newick_string [as 别名]
def get_form():
    """
    @return: the body of a form
    """
    # define the default tree string
    tree = NewickIO.parse(g_default_string, FelTree.NewickTree)
    formatted_tree_string = NewickIO.get_narrow_newick_string(tree, 60)
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'newick tree',
                formatted_tree_string),
            Form.Integer('length', 'use sequences that are this long',
                100, low=1),
            Form.RadioGroup('assumption', 'distance matrix sampling model', [
                Form.RadioItem('infinite_alleles', 'infinite alleles', True),
                Form.RadioItem('jukes_cantor',
                    'Jukes-Cantor model (4 alleles)')]),
            Form.RadioGroup('infinity', 'infinite distance estimates', [
                Form.RadioItem('reject_infinity', 'reject these matrices'),
                Form.RadioItem('replace_infinity',
                    'replace inf with 20', True)]),
            Form.RadioGroup('zero', 'distance estimates of zero', [
                Form.RadioItem('reject_zero', 'reject these matrices'),
                Form.RadioItem('replace_zero', 'use .00001 instead of zero'),
                Form.RadioItem('remain_zero', 'use 0 unmodified', True)])]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:28,代码来源:20080912a.py

示例8: get_form

# 需要导入模块: import NewickIO [as 别名]
# 或者: from NewickIO import get_narrow_newick_string [as 别名]
def get_form():
    """
    @return: the body of a form
    """
    # define the default tree string
    tree = NewickIO.parse(g_default_string, FelTree.NewickTree)
    formatted_tree_string = NewickIO.get_narrow_newick_string(tree, 60)
    # define the form objects
    form_objects = [
        Form.MultiLine("tree", "newick tree", formatted_tree_string),
        Form.RadioGroup(
            "matrix",
            "nodes used for the distance matrix",
            [
                RadioItem("standard", "tips only", True),
                RadioItem("augmented", "all nodes"),
                RadioItem("named", "all named nodes"),
            ],
        ),
        Form.CheckGroup(
            "output_options",
            "output options",
            [
                CheckItem("show_split", "exact criterion partition", True),
                CheckItem("show_value", "exact criterion value", True),
                CheckItem("show_value_minus_trace", "exact criterion value minus trace", True),
                CheckItem("show_fiedler_split", "show the spectral sign partition", True),
                CheckItem("show_fiedler_eigenvector", "show the eigenvector of interest", True),
                CheckItem("show_labels", "ordered labels", True),
                CheckItem("show_distance_matrix", "distance matrix", True),
                CheckItem("show_M_matrix", "M matrix", True),
            ],
        ),
    ]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:37,代码来源:20081001b.py

示例9: get_form

# 需要导入模块: import NewickIO [as 别名]
# 或者: from NewickIO import get_narrow_newick_string [as 别名]
def get_form():
    """
    @return: a list of form objects
    """
    # define the default tree string
    tree = NewickIO.parse(g_default_string, FelTree.NewickTree)
    formatted_tree_string = NewickIO.get_narrow_newick_string(tree, 60)
    # return the form objects
    form_objects = [Form.MultiLine("tree", "newick tree with branch lengths", formatted_tree_string)]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:12,代码来源:20081202a.py

示例10: get_form

# 需要导入模块: import NewickIO [as 别名]
# 或者: from NewickIO import get_narrow_newick_string [as 别名]
def get_form():
    """
    @return: the body of a form
    """
    # define the formatted tree string
    tree = NewickIO.parse(g_tree_data, Newick.NewickTree) 
    formatted_tree_string = NewickIO.get_narrow_newick_string(tree, 60) 
    # return the form objects
    form_objects = [
            Form.MultiLine('tree', 'newick tree', formatted_tree_string)]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:13,代码来源:20090803a.py

示例11: get_form

# 需要导入模块: import NewickIO [as 别名]
# 或者: from NewickIO import get_narrow_newick_string [as 别名]
def get_form():
    """
    @return: a list of form objects
    """
    # define the default tree string
    tree = NewickIO.parse(g_tree_string, FelTree.NewickTree)
    formatted_default_tree_string = NewickIO.get_narrow_newick_string(tree, 60)
    # define the list of form objects
    form_objects = [
            Form.MultiLine('tree', 'tree', formatted_default_tree_string),
            Form.ImageFormat()]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:14,代码来源:20090920a.py

示例12: get_form

# 需要导入模块: import NewickIO [as 别名]
# 或者: from NewickIO import get_narrow_newick_string [as 别名]
def get_form():
    """
    @return: a list of form objects
    """
    # define the default tree string
    tree = NewickIO.parse(g_default_string, FelTree.NewickTree)
    formatted_tree_string = NewickIO.get_narrow_newick_string(tree, 60)
    # return the form objects
    return [
            Form.MultiLine('tree', 'newick tree with branch lengths',
                formatted_tree_string),
            Form.Integer('precision', 'precision', 4, low=2, high=17)]
开发者ID:argriffing,项目名称:xgcode,代码行数:14,代码来源:20090202b.py

示例13: get_form

# 需要导入模块: import NewickIO [as 别名]
# 或者: from NewickIO import get_narrow_newick_string [as 别名]
def get_form():
    """
    @return: a list of form objects
    """
    # define the default tree string
    # ordered_labels = ('a', 'b', 'c', 'x', 'm', 'n', 'p', 'y', 'ab', 'abc', 'mn', 'mnp', 'mnpy', 'abcxmnpy')
    tree = NewickIO.parse(g_default_string, FelTree.NewickTree)
    formatted_tree_string = NewickIO.get_narrow_newick_string(tree, 60)
    # return the form objects
    return [
        Form.MultiLine("tree", "newick tree with branch lengths", formatted_tree_string),
        Form.Integer("precision", "precision", 4, low=2, high=17),
    ]
开发者ID:argriffing,项目名称:xgcode,代码行数:15,代码来源:20090203b.py

示例14: get_form

# 需要导入模块: import NewickIO [as 别名]
# 或者: from NewickIO import get_narrow_newick_string [as 别名]
def get_form():
    """
    @return: the body of a form
    """
    default_tree = NewickIO.parse(g_tree_data, FelTree.NewickTree)
    default_tree_string = NewickIO.get_narrow_newick_string(default_tree, 60)
    # define the list of form objects
    form_objects = [
            Form.MultiLine('tree', 'tree',
                default_tree_string),
            Form.MultiLine('annotation', 'SNP annotations',
                g_annotation_data)]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:15,代码来源:20100528a.py

示例15: get_verbose_summary

# 需要导入模块: import NewickIO [as 别名]
# 或者: from NewickIO import get_narrow_newick_string [as 别名]
 def get_verbose_summary(self):
     """
     @return: a multiline string
     """
     # begin the response
     out = StringIO()
     # show the number of taxa in various domains
     print >> out, self._get_name_summary()
     print >> out
     # show the pruned full tree
     formatted_tree_string = NewickIO.get_narrow_newick_string(self.pruned_tree, 120) 
     print >> out, 'this is the tree that represents all clades but for which redundant nodes have been pruned:'
     print >> out, formatted_tree_string
     print >> out
     # split the distance matrix
     D = np.array(self.pruned_tree.get_distance_matrix(self.pruned_names))
     L = Euclid.edm_to_laplacian(D)
     v = BuildTreeTopology.laplacian_to_fiedler(L)
     eigensplit = BuildTreeTopology.eigenvector_to_split(v)
     # report the eigendecomposition
     print >> out, get_eigendecomposition_report(D)
     print >> out
     # report the clade intersections of sides of the split
     side_names = [set(self.pruned_names[i] for i in side) for side in eigensplit]
     print >> out, 'domains represented by each side of the primary split:'
     print >> out, 'the left side has:\t', ', '.join(self._get_domains(side_names[0]))
     print >> out, 'the right side has:\t', ', '.join(self._get_domains(side_names[1]))
     print >> out
     # prepare to do the secondary splits
     left_indices, right_indices = eigensplit
     full_label_sets = [set([i]) for i in range(len(self.pruned_names))]
     # do the secondary splits
     for index_selection, index_complement in ((left_indices, right_indices), (right_indices, left_indices)):
         L_secondary = SchurAlgebra.mmerge(L, index_complement)
         next_label_sets = SchurAlgebra.vmerge(full_label_sets, index_complement)
         v = BuildTreeTopology.laplacian_to_fiedler(L_secondary)
         left_subindices, right_subindices = BuildTreeTopology.eigenvector_to_split(v)
         left_sublabels = set()
         for i in left_subindices:
             left_sublabels.update(next_label_sets[i])
         right_sublabels = set()
         for i in right_subindices:
             right_sublabels.update(next_label_sets[i])
         left_subnames = set(self.pruned_names[i] for i in left_sublabels)
         right_subnames = set(self.pruned_names[i] for i in right_sublabels)
         print >> out, 'domains represented by a subsplit:'
         print >> out, 'the left side has:\t', ', '.join(self._get_domains(left_subnames))
         print >> out, 'the right side has:\t', ', '.join(self._get_domains(right_subnames))
         print >> out
     # return the multiline string
     return out.getvalue().strip()
开发者ID:argriffing,项目名称:xgcode,代码行数:53,代码来源:20090802a.py


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