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)
def gene_info(gene=None):
    if gene is None:
        flash("That page needs a gene ID")
        return redirect(url_for("homepage"))

    gene_name = es.gene_name(gene)
    gene_info = es.gene_info(gene)
    if gene_name is None or gene_info is None:
        if gene_name is None:
            flash("You need to implement <code>gene_name()</code>")
        if gene_info is None:
            flash("You need to implement <code>gene_info()</code>")
        return redirect(url_for('homepage'))

    go_terms = es.gene_to_go(gene)
    if go_terms is None:
        flash("You need to implement <code>gene_to_go()</code>")
        go_terms = []
    else:
        go_terms = [(goid, es.go_info(goid)) for goid in go_terms]
        if go_terms and go_terms[0][1] is None:
            flash("You need to implement <code>go_info()</code>")

    gene_data = es.gene_data(gene)
    if gene_data is None:
        flash("You need to implement <code>gene_data()</code>")
        hist_data = None
    else:
        gene_hist,bins = np.histogram(gene_data, bins=np.linspace(-8, 8, 33))
        hist_data = zip(bins[:-1], gene_hist)

    local_network = hs.go_network(gene, False, 2)
    if local_network is None:
        flash("You should 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("gene.html", gene_name=gene_name,
                           gene_info=gene_info, go_terms=go_terms,
                           hist_data=hist_data, local_network=local_network)