From efaf3a4abe2f6ae5b67578182085d18d05f25c5f Mon Sep 17 00:00:00 2001 From: Hao Chen Date: Wed, 8 May 2019 01:55:31 -0500 Subject: multiple genes allowed --- server.py | 25 ++++++++++++++++--------- templates/index.html | 14 ++++++++++++++ templates/layout.html | 46 ++++++++++++++++++++++++++++++++++++++++++++++ templates/network.html | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 122 insertions(+), 9 deletions(-) create mode 100644 templates/index.html create mode 100644 templates/layout.html create mode 100644 templates/network.html diff --git a/server.py b/server.py index 76cb63c..d65625e 100644 --- a/server.py +++ b/server.py @@ -19,14 +19,21 @@ def network(): nodes_list=[] if request.method == 'POST': term = request.form - gene=term['query'] - nodes="{ data: { id: '" + gene + "', nodecolor:'#FADBD8'} },\n" + default_nodes - tmp0=gene_addiction(gene) - e0=generate_edges(tmp0) - tmp1=gene_functional(gene) - e1=generate_edges(tmp1) - tmp2=gene_anatomical(gene) - e2=generate_edges(tmp2) - return render_template('network.html', elements=nodes+e0+e1+e2) + genes=term['query'] + genes=genes.replace(",", " ") + genes=genes.replace(";", " ") + genes=genes.split() + nodes=default_nodes + edges=str() + for gene in genes: + nodes+="{ data: { id: '" + gene + "', nodecolor:'#FADBD8', fontweight:700} },\n" + tmp0=gene_addiction(gene) + e0=generate_edges(tmp0) + tmp1=gene_functional(gene) + e1=generate_edges(tmp1) + tmp2=gene_anatomical(gene) + e2=generate_edges(tmp2) + edges+=e0+e1+e2 + return render_template('network.html', elements=nodes+edges) if __name__ == '__main__': app.run(debug=True) diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..c7bafcd --- /dev/null +++ b/templates/index.html @@ -0,0 +1,14 @@ +{% extends "layout.html" %} +{% block content %} + + +