Esempio n. 1
0
def go_term_info(goid=None):
    if goid is None:
        flash("That page needs a GOID")
        return redirect(url_for("homepage"))

    go_info = es.go_info(goid)
    genes = es.go_to_gene(goid)
    if go_info is None or genes is None:
        if go_info is None:
            flash("You need to implement <code>go_info()</code>")
        if genes is None:
            flash("You need to implement <code>go_to_gene()</code>")
        return redirect(url_for('homepage'))

    genes = [(gene, es.gene_name(gene)) for gene in es.go_to_gene(goid)]

    local_network = hs.go_network(goid, True, 1)
    if local_network is None:
        flash("You could maybe implement <code>go_network()</code>")
    elif len(local_network['nodes']) > 1000:
        flash("Too many nodes to plot a network, forget it")
        local_network = {'nodes': [], 'links': []}

    return render_template("go_term.html", go_info=go_info, genes=genes,
                           local_network=local_network)
Esempio n. 2
0
def go_term_info(goid):
    go_info = es.go_info(goid)
    genes = es.go_to_gene(goid)
    if go_info is None or genes is None:
        if go_info is None:
            flash("You need to implement <code>go_info()</code>")
        if genes is None:
            flash("You need to implement <code>go_to_gene()</code>")
        return redirect(url_for('homepage'))

    genes = [(gene, es.gene_name(gene)) for gene in es.go_to_gene(goid)]

    return render_template("go_term.html", go_info=go_info, genes=genes)
Esempio n. 3
0
def enrichment(exp, aspect, n=100):
    aspect = set(aspect)

    if not aspect.intersection('CFP'):
        flash("That's not a valid aspect, try C, F, and/or P")
        return redirect(url_for('experiment', exp=exp))

    exp_data = es.experiment()

    if exp_data is not None:
        exp_data = exp_data[exp]
    else:
        flash("You need to implement <code>experiment()</code> first!")
        return redirect(url_for('experiment', exp=exp))

    go_list = [es.go_aspect(a) for a in aspect]
    if None in go_list:
        flash("You need to implement <code>go_aspect()</code> first!")
        return redirect(url_for('experiment', exp=exp))

    go_list = list(reduce(set.union, go_list, set()))
    go_info = {goid:es.go_info(goid) for goid in go_list}
    go_dict = {gene:es.go_to_gene(gene) for gene in go_list}

    scores = hs.calculate_enrichment(exp_data, go_dict, n)

    return render_template("enrichment.html", exp=exp, go_info=go_info,
                           e_scores=scores[0][:10], ne_scores=scores[1][:10])
Esempio n. 4
0
def enrichment(exp, aspect, n=100):
    aspect = set(aspect)

    if not aspect.intersection('CFP'):
        flash("That's not a valid aspect, try C, F, and/or P")
        return redirect(url_for('experiment', exp=exp))

    exp_data = es.experiment()

    if exp_data is not None:
        exp_data = exp_data[exp]
    else:
        flash("You need to implement <code>experiment()</code> first!")
        return redirect(url_for('experiment', exp=exp))

    go_list = list(reduce(set.union, (es.go_aspect(a) for a in aspect), set()))
    go_info = {goid:es.go_info(goid) for goid in go_list}
    go_dict = {gene:es.go_to_gene(gene) for gene in go_list}

    scores = hs.calculate_enrichment(exp_data, go_dict, n)

    return render_template("enrichment.html", exp=exp, go_info=go_info,
                           e_scores=scores[0][:10], ne_scores=scores[1][:10])