Esempio n. 1
0
def get_form():
    """
    @return: the body of a form
    """
    # define the default xml string
    default_xml_string = DirectRna.get_sample_xml_string()
    # define the form objects
    return [Form.MultiLine('model', 'mixture model', default_xml_string)]
Esempio n. 2
0
def get_form():
    """
    @return: the body of a form
    """
    # define the default xml string
    default_xml_string = DirectRna.get_sample_xml_string()
    # define the form objects
    return [Form.MultiLine('model', 'mixture model', default_xml_string)]
Esempio n. 3
0
def get_response_content(fs):
    # get the tree
    tree = Newick.parse(fs.tree, Newick.NewickTree)
    tree.assert_valid()
    # get the nucleotide alignment
    try:
        alignment = Fasta.Alignment(fs.alignment.splitlines())
        alignment.force_nucleotide()
    except Fasta.AlignmentError as e:
        raise HandlingError(e)
    # get the normalized Direct RNA mixture model
    mixture_model = DirectRna.deserialize_mixture_model(fs.model)
    mixture_model.normalize()
    # return the html string
    return do_analysis(mixture_model, alignment, tree) + '\n'
Esempio n. 4
0
def get_response_content(fs):
    # get the tree
    tree = Newick.parse(fs.tree, Newick.NewickTree)
    tree.assert_valid()
    # get the nucleotide alignment
    try:
        alignment = Fasta.Alignment(fs.alignment.splitlines())
        alignment.force_nucleotide()
    except Fasta.AlignmentError as e:
        raise HandlingError(e)
    # get the normalized Direct RNA mixture model
    mixture_model = DirectRna.deserialize_mixture_model(fs.model)
    mixture_model.normalize()
    # return the html string
    return do_analysis(mixture_model, alignment, tree) + '\n'
Esempio n. 5
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
Esempio n. 6
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
Esempio n. 7
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
Esempio n. 8
0
def get_response_content(fs):
    # deserialize the xml data to create a DirectRnaMixture
    try:
        mixture_model = DirectRna.deserialize_mixture_model(fs.model)
    except ValueError as e:
        raise HandlingError(e)
    expected_rate = mixture_model.get_expected_rate()
    nt_distribution = mixture_model.get_nt_stationary_distribution()
    # write the summary
    out = StringIO()
    print >> out, 'expected substitution rate:'
    print >> out, expected_rate
    print >> out, ''
    print >> out, 'nucleotide distribution:'
    for nt, proportion in zip(Codon.g_nt_letters, nt_distribution):
        print >> out, '%s : %s' % (nt, proportion)
    # return the summary
    return out.getvalue()
Esempio n. 9
0
def get_response_content(fs):
    # deserialize the xml data to create a DirectRnaMixture
    try:
        mixture_model = DirectRna.deserialize_mixture_model(fs.model)
    except ValueError as e:
        raise HandlingError(e)
    expected_rate = mixture_model.get_expected_rate()
    nt_distribution = mixture_model.get_nt_stationary_distribution()
    # write the summary
    out = StringIO()
    print >> out, 'expected substitution rate:'
    print >> out, expected_rate
    print >> out, ''
    print >> out, 'nucleotide distribution:'
    for nt, proportion in zip(Codon.g_nt_letters, nt_distribution):
        print >> out, '%s : %s' % (nt, proportion)
    # return the summary
    return out.getvalue()
Esempio n. 10
0
def get_response_content(fs):
    # get the tree
    tree = Newick.parse(fs.tree, Newick.NewickTree)
    tree.assert_valid()
    # get the normalized Direct RNA mixture model
    mixture_model = DirectRna.deserialize_mixture_model(fs.model)
    mixture_model.normalize()
    # simulate the alignment
    try:
        alignment = PhyLikelihood.simulate_alignment(tree, mixture_model,
                                                     fs.ncols)
    except PhyLikelihood.SimulationError as e:
        raise HandlingError(e)
    # get the alignment
    arr = []
    for node in tree.gen_tips():
        arr.append(alignment.get_fasta_sequence(node.name))
    # return the alignment string
    return '\n'.join(arr) + '\n'
Esempio n. 11
0
def get_response_content(fs):
    # get the tree
    tree = Newick.parse(fs.tree, Newick.NewickTree)
    tree.assert_valid()
    # get the normalized Direct RNA mixture model
    mixture_model = DirectRna.deserialize_mixture_model(fs.model)
    mixture_model.normalize()
    # simulate the alignment
    try:
        alignment = PhyLikelihood.simulate_alignment(tree,
                mixture_model, fs.ncols)
    except PhyLikelihood.SimulationError as e:
        raise HandlingError(e)
    # get the alignment
    arr = []
    for node in tree.gen_tips():
        arr.append(alignment.get_fasta_sequence(node.name))
    # return the alignment string
    return '\n'.join(arr) + '\n'
Esempio n. 12
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