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


Python Newick类代码示例

本文整理汇总了Python中Newick的典型用法代码示例。如果您正苦于以下问题:Python Newick类的具体用法?Python Newick怎么用?Python Newick使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: get_form

def get_form():
    """
    @return: the body of a form
    """
    # define the tree string
    tree_string = '(((Human:0.1, Chimpanzee:0.2):0.8, Gorilla:0.3):0.7, Orangutan:0.4, Gibbon:0.5);'
    tree = Newick.parse(tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'newick tree',
                formatted_tree_string),
            Form.MultiLine('alignment', 'nucleotide alignment',
                g_sample_alignment_string.strip()),
            Form.Matrix('matrix_a', 'first nucleotide rate matrix',
                g_nt_matrix_a),
            Form.Float('weight_a', 'first mixture weight',
                1, low_inclusive=0),
            Form.Matrix('matrix_b', 'second nucleotide rate matrix',
                g_nt_matrix_b),
            Form.Float('weight_b', 'second mixture weight',
                2, low_inclusive=0),
            Form.Matrix('matrix_c', 'third nucleotide rate matrix',
                g_nt_matrix_c),
            Form.Float('weight_c', 'third mixture weight',
                3, low_inclusive=0)]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:27,代码来源:20080308a.py

示例2: get_form

def get_form():
    """
    @return: the body of a form
    """
    # define the tree string
    tree = Newick.parse(g_tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # define the default tip data lines
    default_tip_data_lines = [
            'a : A',
            'b : A',
            'c : C',
            'd : T',
            'e : T',
            'f : T']
    # define the default rate matrix lines
    R = np.array([
        [-1, 1/3.0, 1/3.0, 1/3.0],
        [1/3.0, -1, 1/3.0, 1/3.0],
        [1/3.0, 1/3.0, -1, 1/3.0],
        [1/3.0, 1/3.0, 1/3.0, -1]])
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'newick tree', formatted_tree_string),
            Form.MultiLine('column', 'tip data',
                '\n'.join(default_tip_data_lines)),
            Form.Matrix('matrix', 'rate matrix',
                R, MatrixUtil.assert_rate_matrix),
            Form.ImageFormat()]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:30,代码来源:20080207a.py

示例3: get_form

def get_form():
    """
    @return: the body of a form
    """
    # define the tree string
    tree_string = Newick.daylight_example_tree
    tree = Newick.parse(tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'newick tree', formatted_tree_string),
            Form.IntegerInterval(
                'first_index', 'last_index',
                'eigenfunction index range (1 means Fiedler)',
                0, 12, low=0),
            Form.CheckGroup('check_options', 'output options', [
                Form.CheckItem('reflect_trees',
                    'reflect trees across the vertical axis'),
                Form.CheckItem('show_subfigure_labels',
                    'show subfigure labels', True),
                Form.CheckItem('show_vertex_labels',
                    'show vertex labels')]),
            Form.Float('width', 'width (centimeters)',
                12, low_inclusive=1, high_exclusive=1000),
            Form.Float('height', 'height (centimeters)',
                8, low_inclusive=1, high_exclusive=1000),
            Form.Float('inner_margin', 'inner margin (centimeters)',
                0.25, low_inclusive=0, high_exclusive=1000),
            Form.RadioGroup('radio_options', 'tree layout options', [
                Form.RadioItem('equal_daylight_layout',
                    'equal daylight layout', True),
                Form.RadioItem('equal_arc_layout',
                    'equal arc layout')]),
            Form.TikzFormat()]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:35,代码来源:20110513b.py

示例4: get_form

def get_form():
    """
    @return: a list of form objects
    """
    # reformat the tree string
    tree = Newick.parse(g_tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 75)
    # define the form objects
    form_objects = [
            Form.MultiLine('tree_string', 'newick tree',
                formatted_tree_string),
            Form.Float('scaling_factor',
                'figure scaling factor', 3.0, low_exclusive=0),
            Form.RadioGroup('label_mode', 'label mode', [
                Form.RadioItem('label_mode_suppressed',
                    'suppress all vertex labels', True),
                Form.RadioItem('label_mode_leaf_only',
                    'draw leaf names'),
                Form.RadioItem('label_mode_show',
                    'draw arbitrary short names at all vertices')]),
            Form.RadioGroup('sanitization_options',
                'taxon label sanitization options', [
                    Form.RadioItem('no_sanitization',
                        'allow TikZ to interpret the taxon labels', True),
                    Form.RadioItem('sanitization',
                        'attempt an ad-hoc sanitization of taxon labels')]),
            Form.RadioGroup('tree_layout', 'tree layout options', [
                Form.RadioItem('equal_arc', 'equal arc layout', True),
                Form.RadioItem('equal_daylight', 'equal daylight layout')]),
            Form.LatexFormat()]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:31,代码来源:20110616a.py

示例5: get_form

def get_form():
    """
    @return: the body of a form
    """
    # define the tree string
    tree_string = '(((Human:0.1, Chimpanzee:0.2):0.8, Gorilla:0.3):0.7, Orangutan:0.4, Gibbon:0.5);'
    tree = Newick.parse(tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'newick tree', formatted_tree_string),
            Form.Integer('ncols', 'sample this many nucleotide columns',
                100, low=1, high=1000),
            Form.MultiLine('frequency_a', 'first component frequencies',
                get_frequency_string(0)),
            Form.Float('kappa_a', 'first component kappa',
                get_kappa(0), low_inclusive=0),
            Form.Float('weight_a', 'first component weight',
                get_weight(0), low_inclusive=0),
            Form.MultiLine('frequency_b', 'second component frequencies',
                get_frequency_string(1)),
            Form.Float('kappa_b', 'second component kappa',
                get_kappa(1), low_inclusive=0),
            Form.Float('weight_b', 'second component weight',
                get_weight(1), low_inclusive=0),
            Form.RadioGroup('fmt', 'output format options', [
                Form.RadioItem('fasta', 'fasta'),
                Form.RadioItem('nex', 'nexus', True)])]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:29,代码来源:20080329a.py

示例6: get_form

def get_form():
    """
    @return: the body of a form
    """
    # define the tree string
    tree_string = Newick.daylight_example_tree
    tree = Newick.parse(tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'newick tree', formatted_tree_string),
            Form.IntegerInterval(
                'first_index', 'last_index',
                'eigenfunction index range (1 means Fiedler)',
                0, 12, low=0),
            Form.CheckGroup('check_options', 'output options', [
                Form.CheckItem('reflect_trees', 'reflect trees', True),
                Form.CheckItem('draw_background', 'draw background', True),
                Form.CheckItem('draw_labels', 'draw labels', True)]),
            Form.Integer('width', 'physical width', 880, low=10, high=1000),
            Form.Integer('height', 'physical height', 680, low=10, high=1000),
            Form.Integer('inner_margin', 'inner margin', 10, low=0, high=1000),
            Form.Integer('outer_margin', 'outer margin', 0, low=0, high=1000),
            Form.ImageFormat()]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:25,代码来源:20110512a.py

示例7: get_form

def get_form():
    """
    @return: the body of a form
    """
    # define the default tree string
    tree_string = Newick.brown_example_tree
    tree = Newick.parse(tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # define the default alignment string
    default_alignment_string = Fasta.brown_example_alignment.strip()
    # define the default nucleotide distribution weights
    default_nt_lines = [
            'A : 1',
            'C : 1',
            'G : 1',
            'T : 1']
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'newick tree', formatted_tree_string),
            Form.MultiLine('alignment', 'nucleotide alignment',
                default_alignment_string),
            Form.MultiLine('weights', 'nucleotide weights',
                '\n'.join(default_nt_lines)),
            Form.Float('kappa', 'transition transversion rate ratio',
                2, low_inclusive=0)]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:26,代码来源:20080523a.py

示例8: get_form

def get_form():
    """
    @return: the body of a form
    """
    # define the tree string
    tree_string = '((((a:5)a:5, (b:5)b:5)A:1.5)A:1.5, (((c:5)c:5, (d:5)d:5)B:1.5)B:1.5);'
    tree = Newick.parse(tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # define the form objects
    return [Form.MultiLine('tree', 'newick tree', formatted_tree_string)]
开发者ID:argriffing,项目名称:xgcode,代码行数:10,代码来源:20080130b.py

示例9: get_form

def get_form():
    """
    @return: the body of a form
    """
    # define the tree string
    tree_string = Newick.daylight_example_tree
    tree = Newick.parse(tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # define the form objects
    return [Form.MultiLine('tree', 'newick tree', formatted_tree_string)]
开发者ID:argriffing,项目名称:xgcode,代码行数:10,代码来源:20080129a.py

示例10: get_form

def get_form():
    """
    @return: the body of a form
    """
    # format the default tree string
    tree = Newick.parse(g_default_tree, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'tree', formatted_tree_string)]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:11,代码来源:20110427b.py

示例11: get_response_content

def get_response_content(fs):
    # Read the newick trees.
    true_tree = Newick.parse(fs.true_tree, Newick.NewickTree)
    test_tree = Newick.parse(fs.test_tree, Newick.NewickTree)
    flags = get_flags(fs)
    # Get a list of maps from node id to harmonic extension.
    true_tree_leaf_ids = set(id(x) for x in true_tree.gen_tips())
    nleaves = len(true_tree_leaf_ids)
    id_to_full_val_list = [Harmonic.get_harmonic_valuations(
        true_tree, i) for i in range(1, nleaves)]
    id_map =  get_true_leaf_id_to_test_leaf_id(true_tree, test_tree)
    test_id_to_adj = get_id_to_adj(test_tree)
    test_id_to_name = get_id_to_name(test_tree)
    # Get the list of id to val maps with respect to leaf ids of the test tree.
    test_tree_internal_ids = set(id(x) for x in test_tree.gen_internal_nodes())
    test_tree_leaf_ids = set(id(x) for x in test_tree.gen_tips())
    id_to_val_list = []
    for id_to_full_val in id_to_full_val_list:
        d = {}
        for x in true_tree_leaf_ids:
            value = id_to_full_val[x]
            if abs(value) < 1e-8:
                raise ValueError('the true tree is too symmetric')
            elif value < 0:
                s = -1
            else:
                s = 1
            d[id_map[x]] = s
        for x in test_tree_internal_ids:
            d[x] = None
        id_to_val_list.append(d)
    # Attempt to find a sign assignment.
    id_to_vals = SeekEigenLacing.rec_eigen(
            test_id_to_adj, id_to_val_list, flags)
    # Reorder the leaf and the internal node ids according to name order.
    leaf_pair = sorted(
            (test_id_to_name[x], x) for x in test_tree_leaf_ids)
    internal_pair = sorted(
            (test_id_to_name[x], x) for x in test_tree_internal_ids)
    reordered_leaf_ids = zip(*leaf_pair)[1]
    reordered_internal_ids = zip(*internal_pair)[1]
    # Check for a failure to find a certificate.
    if not id_to_vals:
        return 'no non-rejection certificate was found'
    # Start writing the response.
    out = StringIO()
    print >> out, 'leaf sign valuations:'
    for x in reordered_leaf_ids:
        print >> out, test_id_to_name[x], get_sign_string(id_to_vals[x])
    print >> out
    print >> out, 'vertex sign compatible internal vertex valuations:'
    for x in reordered_internal_ids:
        print >> out, test_id_to_name[x], get_sign_string(id_to_vals[x])
    return out.getvalue()
开发者ID:argriffing,项目名称:xgcode,代码行数:54,代码来源:20110331a.py

示例12: get_form

def get_form():
    """
    @return: a list of form objects
    """
    # reformat the tree string
    tree = Newick.parse(g_tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 75)
    # define the form objects
    form_objects = [
            Form.MultiLine('tree_string', 'newick tree',
                formatted_tree_string)]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:12,代码来源:20110617a.py

示例13: get_form

def get_form():
    """
    @return: the body of a form
    """
    # define the tree string
    tree_string = '(((Human:0.1, Chimpanzee:0.2):0.8, Gorilla:0.3):0.7, Orangutan:0.4, Gibbon:0.5);'
    tree = Newick.parse(tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'newick tree', formatted_tree_string),
            Form.Float('sf', 'scaling factor', 0.333333, low_exclusive=0)]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:13,代码来源:20080327a.py

示例14: get_form

def get_form():
    """
    @return: the body of a form
    """
    # define the tree string
    tree_string = stone_example_tree
    tree = Newick.parse(tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'newick tree', formatted_tree_string),
            Form.SingleLine('node', 'the name of the node to remove', 'a')]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:13,代码来源:20080118b.py

示例15: get_form

def get_form():
    """
    @return: the body of a form
    """
    # format the default tree string
    tree = Newick.parse(g_default_tree, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'tree', formatted_tree_string),
            Form.SingleLine('vertex',
                'distinguished vertex of articulation', 'r')]
    return form_objects
开发者ID:argriffing,项目名称:xgcode,代码行数:13,代码来源:20110427a.py


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