aboutsummaryrefslogtreecommitdiff
path: root/server.py
diff options
context:
space:
mode:
Diffstat (limited to 'server.py')
-rw-r--r--server.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/server.py b/server.py
index 6a28e0b..4eaf911 100644
--- a/server.py
+++ b/server.py
@@ -15,6 +15,8 @@ def home():
@app.route("/search")
def search():
+ global all_sentences
+ all_sentences=str()
genes=request.args.get('query')
genes=genes.replace(",", " ")
genes=genes.replace(";", " ")
@@ -23,14 +25,29 @@ def search():
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)
+ sent0=gene_addiction(gene)
+ e0=generate_edges(sent0)
+ sent1=gene_functional(gene)
+ e1=generate_edges(sent1)
+ sent2=gene_anatomical(gene)
+ e2=generate_edges(sent2)
edges+=e0+e1+e2
+ all_sentences+=sent0+sent1+sent2
return render_template('cytoscape.html', elements=nodes+edges)
+@app.route("/sentences")
+def sentences():
+ edge=request.args.get('edgeID')
+ (gene0, cat0)=edge.split("|")
+ print (gene0 + cat0)
+ out=str()
+ for sent in all_sentences.split("\n"):
+ #print (sent)
+ if len(sent.strip())!=0:
+ (gene,nouse,cat, pmid, text)=sent.split("\t")
+ if (gene == gene0 and cat == cat0) :
+ out+= "<li> "+ text + " <a href=\"https://www.ncbi.nlm.nih.gov/pubmed/?term=" + pmid +"\" target=_new>PMID:"+pmid+"<br></a>"
+ return render_template('sentences.html', sentences=out)
+
if __name__ == '__main__':
app.run(debug=True)