From 888e95f82ec96129257ff9064e9860a275fb7b15 Mon Sep 17 00:00:00 2001 From: Hao Chen Date: Thu, 9 May 2019 00:07:32 -0500 Subject: clean up --- ratspub.py | 6 ------ server.py | 12 ++++++------ templates/cytoscape.html | 3 ++- templates/index.html | 20 ++++++++++++++++++-- templates/layout.html | 6 +++--- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/ratspub.py b/ratspub.py index cc52591..345146e 100755 --- a/ratspub.py +++ b/ratspub.py @@ -2,10 +2,6 @@ from nltk.tokenize import sent_tokenize import os import re -import codecs -import sys - -#gene=sys.argv[1] ## turn dictionary (synonyms) to regular expression def undic(dic): @@ -94,8 +90,6 @@ def generate_edges(data): json0+="{ data: { id: \'" + edgeID + "\', source: \'" + source + "\', target: '" + target + "\', sentCnt: '" + str(edgeCnts[edgeID]) + "', url:'/sentences?edgeID=" + edgeID + "' } },\n" return(json0) - - addiction_d = {"reward":"reward|hedonic|incentive|intracranial self stimulation|ICSS|reinforcement|conditioned place preference|CPP|self administration|self administered|drug reinforced|operant|instrumental response", "aversion":"aversion|aversive|CTA|withdrawal|conditioned taste aversion", "relapse":"relapse|reinstatement|craving|drug seeking|seeking", diff --git a/server.py b/server.py index c9009d0..0f3d94b 100755 --- a/server.py +++ b/server.py @@ -1,6 +1,5 @@ #!/bin/env python3 from flask import Flask, render_template, request, redirect -import simplejson as json from ratspub import * app=Flask(__name__) @@ -18,6 +17,8 @@ def search(): genes=genes.replace(",", " ") genes=genes.replace(";", " ") genes=genes.split() + if len(genes)>=6: + return render_template('index.html') nodes=default_nodes edges=str() for gene in genes: @@ -30,9 +31,9 @@ def search(): e2=generate_edges(sent2) edges+=e0+e1+e2 all_sentences+=sent0+sent1+sent2 - f=open("all_sentences.tab","w") - f.write(all_sentences) - f.close() + #f=open("all_sentences.tab","w") + #f.write(all_sentences) + #f.close() return render_template('cytoscape.html', elements=nodes+edges) @app.route("/sentences") @@ -42,12 +43,11 @@ def sentences(): print (gene0 + cat0) out="
") + return render_template('sentences.html', sentences="
") if __name__ == '__main__': app.run(debug=True) diff --git a/templates/cytoscape.html b/templates/cytoscape.html index 749b042..fd2000e 100644 --- a/templates/cytoscape.html +++ b/templates/cytoscape.html @@ -1,7 +1,8 @@ {% extends "layout.html" %} {% block content %} - + +
+