Ejemplo n.º 1
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'
Ejemplo n.º 2
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'
Ejemplo n.º 3
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()
Ejemplo n.º 4
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()
Ejemplo n.º 5
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'
Ejemplo n.º 6
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'