Exemplo n.º 1
0
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 columns',
                     100,
                     low=1,
                     high=1000),
        Form.Matrix('matrix_a', 'first nucleotide rate matrix', g_nt_matrix_a),
        Form.Float('weight_a',
                   'first mixture weight',
                   g_weight_a,
                   low_inclusive=0),
        Form.Matrix('matrix_b', 'second nucleotide rate matrix',
                    g_nt_matrix_b),
        Form.Float('weight_b',
                   'second mixture weight',
                   g_weight_b,
                   low_inclusive=0),
        Form.Matrix('matrix_c', 'third nucleotide rate matrix', g_nt_matrix_c),
        Form.Float('weight_c',
                   'third mixture weight',
                   g_weight_c,
                   low_inclusive=0)
    ]
    return form_objects
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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
Exemplo n.º 5
0
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)
    # make a real distance matrix
    D_s = [line.split() for line in g_default_D_lines]
    D_default = np.array([[float(x) for x in row] for row in D_s])
    # define the form objects
    form_objects = [
        Form.MultiLine('test_tree', 'harmonic extension tree',
                       formatted_tree_string),
        Form.Matrix('D', 'leaf distance matrix', D_default,
                    MatrixUtil.assert_symmetric),
        Form.MultiLine('names', 'ordered leaf names',
                       '\n'.join(g_default_leaf_names)),
        Form.Float('scale',
                   'scale the image of the tree by this factor',
                   200.0,
                   low_exclusive=0.0),
        Form.ImageFormat()
    ]
    return form_objects
Exemplo n.º 6
0
def process_tree(tree, tree_name, show_newick, show_art):
    """
    @param tree: a FelTree to be split by each method
    @param tree_name: a description of the tree
    @param show_newick: an output option
    @param show_art: an output option
    @return: a multi-line output string
    """
    out = StringIO()
    # be verbose if requested
    if show_newick:
        print >> out, 'newick representation of %s:' % tree_name
        print >> out, Newick.get_narrow_newick_string(tree, 80) 
    if show_art:
        print >> out, 'ascii art representation of %s:' % tree_name
        print >> out, get_art(tree)
    # cut the tree using each method
    ordered_names = list(sorted(node.get_name() for node in tree.gen_tips()))
    n = len(ordered_names)
    D = tree.get_distance_matrix(ordered_names)
    splitters = (Clustering.StoneExactDMS(), Clustering.StoneSpectralSignDMS())
    splitter_names = ('the +1 / -1 split criterion', 'the fiedler criterion')
    for splitter, splitter_name in zip(splitters, splitter_names):
        small_index_selection = splitter.get_selection(D)
        big_index_selection = set(range(n)) - small_index_selection
        names_a = list(sorted(ordered_names[i] for i in small_index_selection))
        names_b = list(sorted(ordered_names[i] for i in big_index_selection))
        print >> out, 'split inferred by %s:' % splitter_name
        print >> out, '{{%s}, {%s}}' % (', '.join(names_a), ', '.join(names_b))
    # return the string
    return out.getvalue()
Exemplo n.º 7
0
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
Exemplo n.º 8
0
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
Exemplo n.º 9
0
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
Exemplo n.º 10
0
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
Exemplo n.º 11
0
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
Exemplo n.º 12
0
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
Exemplo n.º 13
0
def get_form():
    """
    @return: the body of a form
    """
    # define the default newick tree
    tree_string = '((((a:.05, b:.05)L1:.15, c:.2)L2:.8, x:1)L3:.5, (((m:.05, n:.05)R1:.15, p:.2)R2:.8, y:1)R3:.5)root;'
    tree = Newick.parse(tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # define the default rate matrix and its ordered states
    R = np.array([[-.3, .1, .1, .1], [.1, -.3, .1, .1], [.1, .1, -.3, .1],
                  [.1, .1, .1, -.3]])
    ordered_states = list('ACGT')
    # define the default leaf state assigments
    leaf_assignment_lines = [
        'a : A', 'b : A', 'c : A', 'x : A', 'm : C', 'n : C', 'p : C', 'y : C'
    ]
    # define the form objects
    form_objects = [
        Form.MultiLine('tree', 'newick tree with branch lengths',
                       formatted_tree_string),
        Form.Matrix('rate_matrix', 'rate matrix', R,
                    MatrixUtil.assert_rate_matrix),
        Form.MultiLine('states', 'ordered states', '\n'.join(ordered_states)),
        Form.MultiLine('assignments', 'leaf states',
                       '\n'.join(leaf_assignment_lines))
    ]
    return form_objects
Exemplo n.º 14
0
def process_tree(tree, tree_name, show_newick, show_art):
    """
    @param tree: a FelTree to be split by each method
    @param tree_name: a description of the tree
    @param show_newick: an output option
    @param show_art: an output option
    @return: a multi-line output string
    """
    out = StringIO()
    # be verbose if requested
    if show_newick:
        print >> out, "newick representation of %s:" % tree_name
        print >> out, Newick.get_narrow_newick_string(tree, 80)
    if show_art:
        print >> out, "ascii art representation of %s:" % tree_name
        print >> out, get_art(tree)
    # cut the tree using each method
    ordered_names = list(sorted(node.get_name() for node in tree.gen_tips()))
    n = len(ordered_names)
    D = tree.get_distance_matrix(ordered_names)
    splitters = (Clustering.StoneExactDMS(), Clustering.StoneSpectralSignDMS())
    splitter_names = ("the +1 / -1 split criterion", "the fiedler criterion")
    for splitter, splitter_name in zip(splitters, splitter_names):
        small_index_selection = splitter.get_selection(D)
        big_index_selection = set(range(n)) - small_index_selection
        names_a = list(sorted(ordered_names[i] for i in small_index_selection))
        names_b = list(sorted(ordered_names[i] for i in big_index_selection))
        print >> out, "split inferred by %s:" % splitter_name
        print >> out, "{{%s}, {%s}}" % (", ".join(names_a), ", ".join(names_b))
    # return the string
    return out.getvalue()
Exemplo n.º 15
0
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('model', 'DNA frequency mixture model',
                       get_sample_xml_string().strip()),
        Form.Integer('ncols',
                     'sample this many nucleotide columns',
                     200,
                     low=1,
                     high=1000),
        Form.Integer('seed', 'random number seed', 314159, low=0),
        Form.RadioGroup('format', 'output format', [
            Form.RadioItem('fastaformat', 'fasta alignment'),
            Form.RadioItem('nexusformat', 'nexus alignment', True)
        ])
    ]
    return form_objects
Exemplo n.º 16
0
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,
                             4,
                             low=0),
        Form.CheckGroup('check_options', 'output options', [
            Form.CheckItem('draw_background', 'draw background', True),
            Form.CheckItem('draw_vertices', 'draw vertices'),
            Form.CheckItem('draw_labels', 'draw labels', True)
        ]),
        Form.ImageFormat()
    ]
    return form_objects
Exemplo n.º 17
0
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)]
Exemplo n.º 18
0
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)]
Exemplo n.º 19
0
def get_form():
    """
    @return: the body of a form
    """
    # define the newick string
    tree_string = Newick.daylight_example_tree
    tree = Newick.parse(tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # return the form objects
    return [Form.MultiLine('tree', 'newick tree', formatted_tree_string)]
Exemplo n.º 20
0
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
Exemplo n.º 21
0
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)]
Exemplo n.º 22
0
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
Exemplo n.º 23
0
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
Exemplo n.º 24
0
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
Exemplo n.º 25
0
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
Exemplo n.º 26
0
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
Exemplo n.º 27
0
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
Exemplo n.º 28
0
def get_form():
    """
    @return: the body of a form
    """
    # define the tree and alignment strings
    tree_string = '(((Human:0.1, Chimpanzee:0.2)to-chimp:0.8, Gorilla:0.3)to-gorilla:0.7, Orangutan:0.4, Gibbon:0.5)all;'
    tree = Newick.parse(tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    alignment_string = Fasta.brown_example_alignment.strip()
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'newick tree', formatted_tree_string),
            Form.MultiLine('fasta', 'fasta alignment', alignment_string)]
    return form_objects
Exemplo n.º 29
0
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
Exemplo n.º 30
0
def get_form():
    """
    @return: the body of a form
    """
    # define the tree and alignment strings
    tree_string = Newick.brown_example_tree
    tree = Newick.parse(tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    alignment_string = Fasta.brown_example_alignment.strip()
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'newick tree', formatted_tree_string),
            Form.MultiLine('fasta', 'fasta alignment', alignment_string)]
    return form_objects
Exemplo n.º 31
0
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.Integer('segments',
                'minimum segment count', 200, low=1, high=10000)]
    return form_objects
Exemplo n.º 32
0
def get_form():
    """
    @return: the body of a form
    """
    # define the newick string and the ordered labels
    tree = Newick.parse(g_default_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    labels = list('xyabcmnp')
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'newick tree', formatted_tree_string),
            Form.MultiLine('order', 'sequence order', '\n'.join(labels)),
            Form.Integer('length', 'sequence length', 60, low=2)]
    return form_objects
Exemplo n.º 33
0
def get_form():
    """
    @return: the body of a form
    """
    # define the tree and alignment strings
    tree_string = '(((Human:0.1, Chimpanzee:0.2)to-chimp:0.8, Gorilla:0.3)to-gorilla:0.7, Orangutan:0.4, Gibbon:0.5)all;'
    tree = Newick.parse(tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    alignment_string = Fasta.brown_example_alignment.strip()
    # define the form objects
    form_objects = [
        Form.MultiLine('tree', 'newick tree', formatted_tree_string),
        Form.MultiLine('fasta', 'fasta alignment', alignment_string)
    ]
    return form_objects
Exemplo n.º 34
0
def get_form():
    """
    @return: the body of a form
    """
    # define the newick string and the ordered labels
    tree = Newick.parse(g_default_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    labels = list('xyabcmnp')
    # define the form objects
    form_objects = [
        Form.MultiLine('tree', 'newick tree', formatted_tree_string),
        Form.MultiLine('order', 'sequence order', '\n'.join(labels)),
        Form.Integer('length', 'sequence length', 60, low=2)
    ]
    return form_objects
Exemplo n.º 35
0
def get_form():
    """
    @return: the body of a form
    """
    # define the tree
    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('model', 'Direct RNA mixture model',
                DirectRna.get_sample_xml_string().strip()),
            Form.Integer('ncols', 'sample this many columns',
                100, low=1, high=10000)]
    return form_objects
Exemplo n.º 36
0
def get_form():
    """
    @return: the body of a form
    """
    # define the newick 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.MultiLine('model', 'Direct RNA mixture model',
                DirectRna.get_sample_xml_string().strip())]
    return form_objects
Exemplo n.º 37
0
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 form objects
    form_objects = [
            Form.MultiLine('tree', 'newick tree', formatted_tree_string),
            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.TikzFormat()]
    return form_objects
Exemplo n.º 38
0
def get_form():
    """
    @return: the body of a form
    """
    # define the tree string
    tree = Newick.parse(g_default_tree, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # get the form objects
    form_objects = [
            Form.MultiLine('tree', 'tree', formatted_tree_string),
            Form.Integer('eigenvector_index',
                'eigenvector index (1 is Fiedler)',
                g_default_eigenvector_index, low=1),
            Form.Float('yaw', 'yaw', g_default_yaw),
            Form.Float('pitch', 'pitch', g_default_pitch),
            Form.TikzFormat()]
    return form_objects
Exemplo n.º 39
0
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('model', 'Direct Protein mixture model',
                DirectProtein.get_sample_xml_string().strip()),
            Form.Integer('ncols', 'sample this many codon columns',
                100, low=1, high=1000)]
    return form_objects
Exemplo n.º 40
0
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.RadioGroup('layout', 'tree layout options', [
                Form.RadioItem('daylight', 'equal daylight layout', True),
                Form.RadioItem('arc', 'equal arc layout'),
                Form.RadioItem('curved', 'curved branch layout')]),
            Form.ImageFormat()]
    return form_objects
Exemplo n.º 41
0
def get_form():
    """
    @return: the body of a form
    """
    # define the newick 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.MultiLine('model', 'Direct RNA mixture model',
                       DirectRna.get_sample_xml_string().strip())
    ]
    return form_objects
Exemplo n.º 42
0
def get_form():
    """
    @return: the body of a form
    """
    # define the tree string
    tree_string = LeafWeights.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.RadioGroup('method', 'weight calculation method', [
            Form.RadioItem('stone', 'use the method of Stone and Sidow', True),
            Form.RadioItem('thompson', 'use the Thompson et al.')
        ])
    ]
    return form_objects
Exemplo n.º 43
0
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.Integer('eig_idx1',
                'first eigenfunction index (1 means Fiedler)', 1, low=0),
            Form.Integer('eig_idx2',
                'second eigenfunction index (1 means Fiedler)', 2, low=0),
            Form.ImageFormat()]
    return form_objects
Exemplo n.º 44
0
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.Integer('segments',
                     'minimum segment count',
                     200,
                     low=1,
                     high=10000)
    ]
    return form_objects
Exemplo n.º 45
0
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.RadioGroup('layout', 'tree layout options', [
            Form.RadioItem('daylight', 'equal daylight layout', True),
            Form.RadioItem('arc', 'equal arc layout'),
            Form.RadioItem('curved', 'curved branch layout')
        ]),
        Form.ImageFormat()
    ]
    return form_objects
Exemplo n.º 46
0
def get_form():
    """
    @return: the body of a form
    """
    # define the default tree string
    tree_string = g_ucsc_tree_string
    tree = Newick.parse(tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # default name selection
    default_name_selection = ('human_hg18', 'chimp_panTro1', 'rabbit_oryCun1')
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'newick tree', formatted_tree_string),
            Form.MultiLine('selection', 'selected tip names',
                '\n'.join(default_name_selection)),
            Form.RadioGroup('method', 'weighting method', [
                RadioItem('stone', 'use the method of Stone and Sidow', True),
                RadioItem('thompson', 'use the method of Thompson et al.')])]
    return form_objects
Exemplo n.º 47
0
def get_form():
    """
    @return: the body of a form
    """
    # define the tree string
    tree = Newick.parse(g_default_tree, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # get the form objects
    form_objects = [
        Form.MultiLine('tree', 'tree', formatted_tree_string),
        Form.Integer('eigenvector_index',
                     'eigenvector index (1 is Fiedler)',
                     g_default_eigenvector_index,
                     low=1),
        Form.Float('yaw', 'yaw', g_default_yaw),
        Form.Float('pitch', 'pitch', g_default_pitch),
        Form.TikzFormat()
    ]
    return form_objects
Exemplo n.º 48
0
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
Exemplo n.º 49
0
def get_form():
    """
    @return: the body of a form
    """
    # define the tree string
    tree_string = g_tree_string
    tree = Newick.parse(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 form objects
    form_objects = [
        Form.MultiLine('tree', 'newick tree', formatted_tree_string),
        Form.MultiLine('column', 'tip data',
                       '\n'.join(default_tip_data_lines)),
        Form.ImageFormat()
    ]
    return form_objects
Exemplo n.º 50
0
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 default color lines
    default_color_lines = [
            'A : ff0000',
            'B : 00ff00',
            'C : 0000ff']
    # define the form objects
    form_objects = [
            Form.MultiLine('tree', 'newick tree', formatted_tree_string),
            Form.MultiLine('coloration', 'branch colors',
                '\n'.join(default_color_lines)),
            Form.ImageFormat()]
    return form_objects
Exemplo n.º 51
0
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, 4, low=0),
            Form.CheckGroup('check_options', 'output options', [
                Form.CheckItem('draw_background', 'draw background', True),
                Form.CheckItem('draw_vertices', 'draw vertices'),
                Form.CheckItem('draw_labels', 'draw labels', True)]),
            Form.ImageFormat()]
    return form_objects
Exemplo n.º 52
0
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.RadioGroup('group1', 'output options', [
                Form.RadioItem('choice1',
                    'a simple indented format', True),
                Form.RadioItem('choice2',
                    'ascii art with branch lengths'),
                Form.RadioItem('choice3',
                    'ascii art with topology only and less whitespace'),
                Form.RadioItem('choice4',
                    'ascii art with topology only and more whitespace')])]
    return form_objects
Exemplo n.º 53
0
def get_form():
    """
    @return: the body of a form
    """
    # define the default tree string
    tree_string = g_ucsc_tree_string
    tree = Newick.parse(tree_string, Newick.NewickTree)
    formatted_tree_string = Newick.get_narrow_newick_string(tree, 60)
    # default name selection
    default_name_selection = ('human_hg18', 'chimp_panTro1', 'rabbit_oryCun1')
    # define the form objects
    form_objects = [
        Form.MultiLine('tree', 'newick tree', formatted_tree_string),
        Form.MultiLine('selection', 'selected tip names',
                       '\n'.join(default_name_selection)),
        Form.RadioGroup('method', 'weighting method', [
            RadioItem('stone', 'use the method of Stone and Sidow', True),
            RadioItem('thompson', 'use the method of Thompson et al.')
        ])
    ]
    return form_objects
Exemplo n.º 54
0
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("model", "DNA frequency mixture model", get_sample_xml_string().strip()),
        Form.Integer("ncols", "sample this many nucleotide columns", 200, low=1, high=1000),
        Form.Integer("seed", "random number seed", 314159, low=0),
        Form.RadioGroup(
            "format",
            "output format",
            [Form.RadioItem("fastaformat", "fasta alignment"), Form.RadioItem("nexusformat", "nexus alignment", True)],
        ),
    ]
    return form_objects