aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xserver.py94
1 files changed, 47 insertions, 47 deletions
diff --git a/server.py b/server.py
index 331bb60..3cdb307 100755
--- a/server.py
+++ b/server.py
@@ -127,7 +127,7 @@ def root():
onto_cont=open("addiction.onto","r").read()
dict_onto=ast.literal_eval(onto_cont)
- return render_template('index.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
@app.route("/login", methods=["POST", "GET"])
@@ -154,8 +154,8 @@ def login():
onto_list = session['onto_list']
else:
flash("Invalid username or password!", "inval")
- return render_template('signup.html')
- return render_template('index.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('signup.html',version=version())
+ return render_template('index.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
@app.route("/signup", methods=["POST", "GET"])
@@ -173,7 +173,7 @@ def signup():
if (found_user and (bcrypt.checkpw(password.encode('utf8'), found_user.password)==False)):
flash("Already registered, but wrong password!", "inval")
- return render_template('signup.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('signup.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
session['email'] = email
session['hashed_email'] = hashlib.md5(session['email'] .encode('utf-8')).hexdigest()
@@ -199,12 +199,12 @@ def signup():
os.makedirs(session['user_folder']+"/ontology/")
flash("Login Succesful!")
- return render_template('index.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
else:
if 'email' in session:
flash("Already Logged In!")
- return render_template('index.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
- return render_template('signup.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
+ return render_template('signup.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
@app.route("/signin", methods=["POST", "GET"])
@@ -228,11 +228,11 @@ def signin():
onto_len_dir = session['onto_len_dir']
onto_list = session['onto_list']
dict_onto=ast.literal_eval(onto_cont)
- return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
else:
flash("Invalid username or password!", "inval")
- return render_template('signup.html')
- return render_template('signin.html')
+ return render_template('signup.html',version=version())
+ return render_template('signin.html',version=version())
# change password
@app.route("/<nm_passwd>", methods=["POST", "GET"])
@@ -258,7 +258,7 @@ def profile(nm_passwd):
onto_list = ''
onto_cont=open("addiction.onto","r").read()
dict_onto=ast.literal_eval(onto_cont)
- return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
# remove reserved characters from the hashed passwords
reserved = (";", "/", "?", ":", "@", "=", "&", ".")
def replace_reserved(fullstring):
@@ -268,7 +268,7 @@ def profile(nm_passwd):
replaced_passwd = replace_reserved(str(found_user.password))
if replaced_passwd == user_passwd:
- return render_template("/passwd_change.html", name=user_name)
+ return render_template("/passwd_change.html", name=user_name,version=version())
else:
return "This url does not exist"
else:
@@ -293,12 +293,12 @@ def logout():
flash("You have been logged out, {user1}", "inval")
session.pop('email', None)
session.clear()
- return render_template('index.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
@app.route("/about")
def about():
- return render_template('about.html',version=version())
+ return render_template('about.html',version=version)
# Ontology selection
@app.route("/index_ontology", methods=["POST", "GET"])
@@ -319,7 +319,7 @@ def index_ontology():
dict_onto=ast.literal_eval(onto_cont)
onto_len_dir = session['onto_len_dir']
onto_list = session['onto_list']
- return render_template('index.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = session['namecat'], dict_onto=dict_onto )
+ return render_template('index.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = session['namecat'], dict_onto=dict_onto ,version=version())
@app.route("/ontology", methods=["POST", "GET"])
@@ -567,7 +567,7 @@ def ontology():
else:
onto_len_dir=0
onto_list=''
- return render_template('ontology.html',dict_onto=dict_onto, namecat=name_to_html, onto_len_dir=onto_len_dir, onto_list=onto_list)
+ return render_template('ontology.html',dict_onto=dict_onto, namecat=name_to_html, onto_len_dir=onto_len_dir, onto_list=onto_list,version=version())
@app.route("/ontoarchive")
@@ -581,7 +581,7 @@ def ontoarchive():
onto_list = ''
onto_cont=open("addiction.onto","r").read()
dict_onto=ast.literal_eval(onto_cont)
- return render_template('index.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
else:
session['user_folder'] = datadir+"/user/"+str(session['hashed_email'])
else:
@@ -590,7 +590,7 @@ def ontoarchive():
onto_list = ''
onto_cont=open("addiction.onto","r").read()
dict_onto=ast.literal_eval(onto_cont)
- return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
session_id=session['id']
def sorted_alphanumeric(data):
@@ -616,7 +616,7 @@ def ontoarchive():
session['onto_len_dir'] = onto_len_dir
session['onto_list'] = onto_list
message3="<ul><li> Click on the Date/Time to view archived results. <li>The Date/Time are based on US Central time zone.</ul> "
- return render_template('ontoarchive.html', onto_len_dir=onto_len_dir, onto_list = onto_list, onto_folder_list=onto_folder_list, onto_directory_list=onto_directory_list, session_id=session_id, message3=message3)
+ return render_template('ontoarchive.html', onto_len_dir=onto_len_dir, onto_list = onto_list, onto_folder_list=onto_folder_list, onto_directory_list=onto_directory_list, session_id=session_id, message3=message3,version=version())
# Remove an ontology folder
@@ -632,7 +632,7 @@ def removeonto():
onto_list = ''
onto_cont=open("addiction.onto","r").read()
dict_onto=ast.literal_eval(onto_cont)
- return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
@app.route('/progress')
@@ -662,7 +662,7 @@ def progress():
onto_cont=open("addiction.onto","r").read()
dict_onto=ast.literal_eval(onto_cont)
message="<span class='text-danger'>Up to 200 terms can be searched at a time</span>"
- return render_template('index.html' ,onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto, message=message)
+ return render_template('index.html' ,onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto, message=message,version=version())
if len(genes)==0:
if ('email' in session):
@@ -674,7 +674,7 @@ def progress():
onto_cont=open("addiction.onto","r").read()
dict_onto=ast.literal_eval(onto_cont)
message="<span class='text-danger'>Please enter a search term </span>"
- return render_template('index.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto, message=message)
+ return render_template('index.html',onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto, message=message,version=version())
tf_path=tempfile.gettempdir()
genes_for_folder_name =""
@@ -762,7 +762,7 @@ def progress():
genes_session += str(gen) + "_"
genes_session = genes_session[:-1]
session['query']=genes
- return render_template('progress.html', url_in="search", url_out="cytoscape/?rnd="+rnd+"&genequery="+genes_session)
+ return render_template('progress.html', url_in="search", url_out="cytoscape/?rnd="+rnd+"&genequery="+genes_session,version=version())
@app.route("/search")
@@ -991,7 +991,7 @@ def tableview():
onto_list = ''
onto_cont=open("addiction.onto","r").read()
dict_onto=ast.literal_eval(onto_cont)
- return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
jedges =''
file_edges = open(datadir+gene_url_tmp +'/edges.json', 'r')
@@ -1015,7 +1015,7 @@ def tableview():
onto_list = ''
onto_cont=open("addiction.onto","r").read()
dict_onto=ast.literal_eval(onto_cont)
- return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
jedges =''
file_edges = open(gene_url_tmp +'/edges.json', 'r')
for line in file_edges.readlines():
@@ -1039,7 +1039,7 @@ def tableview():
num_gene = gene_name.count(',')+1
message3="<ul><li> <font color=\"#E74C3C\">Click on the abstract count to read sentences linking the keyword and the gene</font> <li> Click on a keyword to see the terms included in the search. <li>View the results in <a href='\\cytoscape/?rnd={}&genequery={}'\ ><b> a graph.</b></a> </ul> Links will be preserved when the table is copy-n-pasted into a spreadsheet.".format(rnd_url,genes_url)
- return render_template('tableview.html', genes_session_tmp = genes_session_tmp, nodata_temp=nodata_temp, num_gene=num_gene, jedges=jedges, jnodes=jnodes,gene_name=gene_name, message3=message3, rnd_url=rnd_url, genes_url=genes_url)
+ return render_template('tableview.html', genes_session_tmp = genes_session_tmp, nodata_temp=nodata_temp, num_gene=num_gene, jedges=jedges, jnodes=jnodes,gene_name=gene_name, message3=message3, rnd_url=rnd_url, genes_url=genes_url,version=version())
# Table for the zero abstract counts
@@ -1062,7 +1062,7 @@ def tableview0():
onto_list = ''
onto_cont=open("addiction.onto","r").read()
dict_onto=ast.literal_eval(onto_cont)
- return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
jedges =''
file_edges = open(datadir+gene_url_tmp+'/edges.json', 'r')
@@ -1086,7 +1086,7 @@ def tableview0():
onto_list = ''
onto_cont=open("addiction.onto","r").read()
dict_onto=ast.literal_eval(onto_cont)
- return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
jedges =''
file_edges = open(gene_url_tmp+'/edges.json', 'r')
@@ -1112,7 +1112,7 @@ def tableview0():
gene_name = gene_name+added
num_gene = gene_name.count(',')+1
message4="<b> Notes: </b><li> These are the keywords that have <b>zero</b> abstract counts. <li>View all the results in <a href='\\cytoscape/?rnd={}&genequery={}'><b> a graph.</b></a> ".format(rnd_url,genes_url)
- return render_template('tableview0.html',nodata_temp=nodata_temp, num_gene=num_gene, jedges=jedges, jnodes=jnodes,gene_name=gene_name, message4=message4)
+ return render_template('tableview0.html',nodata_temp=nodata_temp, num_gene=num_gene, jedges=jedges, jnodes=jnodes,gene_name=gene_name, message4=message4,version=version())
@app.route("/userarchive")
@@ -1125,7 +1125,7 @@ def userarchive():
if ('email' in session):
if os.path.exists(datadir+"/user/"+str(session['hashed_email'])) == False:
flash("Search history doesn't exist!")
- return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
else:
session['user_folder'] = datadir+"/user/"+str(session['hashed_email'])
else:
@@ -1135,7 +1135,7 @@ def userarchive():
onto_list = ''
onto_cont=open("addiction.onto","r").read()
dict_onto=ast.literal_eval(onto_cont)
- return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
session_id=session['id']
def sorted_alphanumeric(data):
@@ -1165,7 +1165,7 @@ def userarchive():
directory_list.append(filename)
len_dir = len(directory_list)
message3="<ul><li> Click on the Date/Time to view archived results. <li>The Date/Time are based on US Central time zone.</ul> "
- return render_template('userarchive.html', len_dir=len_dir, gene_list = gene_list, onto_list = onto_list, folder_list=folder_list, directory_list=directory_list, session_id=session_id, message3=message3)
+ return render_template('userarchive.html', len_dir=len_dir, gene_list = gene_list, onto_list = onto_list, folder_list=folder_list, directory_list=directory_list, session_id=session_id, message3=message3,version=version())
# Remove the search directory
@@ -1181,7 +1181,7 @@ def remove():
onto_list = ''
onto_cont=open("addiction.onto","r").read()
dict_onto=ast.literal_eval(onto_cont)
- return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
@app.route('/date', methods=['GET', 'POST'])
@@ -1242,9 +1242,9 @@ def date():
onto_list = ''
onto_cont=open("addiction.onto","r").read()
dict_onto=ast.literal_eval(onto_cont)
- return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
message3="<ul><li> <font color=\"#E74C3C\">Click on the abstract count to read sentences linking the keyword and the gene</font> <li> Click on a keyword to see the terms included in the search. <li>View the results in <a href='\\cytoscape/?rnd={}&genequery={}'\ ><b> a graph.</b></a> </ul> Links will be preserved when the table is copy-n-pasted into a spreadsheet.".format(select_date,genes_session)
- return render_template('tableview.html',nodata_temp=nodata_temp, num_gene=num_gene,genes_session_tmp = genes_session_tmp, rnd_url=select_date ,jedges=jedges, jnodes=jnodes,gene_name=gene_name, genes_url=genes_session, message3=message3)
+ return render_template('tableview.html',nodata_temp=nodata_temp, num_gene=num_gene,genes_session_tmp = genes_session_tmp, rnd_url=select_date ,jedges=jedges, jnodes=jnodes,gene_name=gene_name, genes_url=genes_session, message3=message3,version=version())
@app.route('/cytoscape/')
def cytoscape():
@@ -1267,7 +1267,7 @@ def cytoscape():
onto_list = ''
onto_cont=open("addiction.onto","r").read()
dict_onto=ast.literal_eval(onto_cont)
- return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
with open(rnd_url_tmp+"_0link","r") as z:
zeroLink=z.read()
@@ -1285,13 +1285,13 @@ def cytoscape():
onto_list = ''
onto_cont=open("addiction.onto","r").read()
dict_onto=ast.literal_eval(onto_cont)
- return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto)
+ return render_template('index.html', onto_len_dir=onto_len_dir, onto_list=onto_list, ontol = 'addiction', dict_onto = dict_onto,version=version())
with open(rnd_url_tmp+"_0link","r") as z:
zeroLink=z.read()
if (len(zeroLink)>0):
message2+="<span style=\"color:darkred;\">No result was found for these genes: " + zeroLink + "</span>"
- return render_template('cytoscape.html', elements=elements, message2=message2)
+ return render_template('cytoscape.html', elements=elements, message2=message2,version=version())
@app.route("/sentences")
@@ -1359,7 +1359,7 @@ def sentences():
elif(out_neg != "" and out_pos == ""):
out = out1 +out2+stress_cellular+out_neg
K.clear_session()
- return render_template('sentences.html', sentences="<ol>"+out+"</ol><p>")
+ return render_template('sentences.html', sentences="<ol>"+out+"</ol><p>",version=version())
# Show the cytoscape graph for one gene from the top gene list
@@ -1368,7 +1368,7 @@ def showTopGene():
query=request.args.get('topGene')
nodesEdges=searchArchived('topGene',query, 'cys','','')[0]
message2="<li><strong>"+query + "</strong> is one of the top addiction genes. <li> An archived search is shown. Click on the blue circle to update the results and include keywords for brain region and gene function. <strong> The update may take a long time to finish.</strong> "
- return render_template("cytoscape.html", elements=nodesEdges, message="Top addiction genes", message2=message2)
+ return render_template("cytoscape.html", elements=nodesEdges, message="Top addiction genes", message2=message2,version=version())
@app.route("/shownode")
@@ -1385,7 +1385,7 @@ def shownode():
for ky in dictionary.keys():
if node in dictionary[ky].keys():
out="<p>"+node.upper()+"<hr><li>"+ next(iter(dictionary[ky][node])).replace("|", "<li>")
- return render_template('sentences.html', sentences=out+"<p>")
+ return render_template('sentences.html', sentences=out+"<p>",version=version())
@app.route("/synonyms")
@@ -1401,23 +1401,23 @@ def synonyms():
synonym_list_str = ';'.join([str(syn) for syn in synonym_list])
synonym_list_str +=';' + node
case = 1
- return render_template('genenames.html', case = case, gene = node.upper(), synonym_list = synonym_list, synonym_list_str=synonym_list_str)
+ return render_template('genenames.html', case = case, gene = node.upper(,version=version()), synonym_list = synonym_list, synonym_list_str=synonym_list_str)
except:
try:
synonym_list = session['synonym_list']
synonym_list_str = ';'.join([str(syn) for syn in synonym_list])
synonym_list_str +=';' + node
case = 1
- return render_template('genenames.html', case=case, gene = session['main_gene'] , synonym_list = synonym_list, synonym_list_str=synonym_list_str)
+ return render_template('genenames.html', case=case, gene = session['main_gene'] , synonym_list = synonym_list, synonym_list_str=synonym_list_str,version=version())
except:
case = 2
- return render_template('genenames.html', gene = node, case = case)
+ return render_template('genenames.html', gene = node, case = case,version=version())
@app.route("/startGeneGene")
def startGeneGene():
session['forTopGene']=request.args.get('forTopGene')
- return render_template('progress.html', url_in="searchGeneGene", url_out="showGeneTopGene")
+ return render_template('progress.html', url_in="searchGeneGene", url_out="showGeneTopGene",version=version())
@app.route("/searchGeneGene")
@@ -1501,13 +1501,13 @@ def gene_gene():
def showGeneTopGene ():
with open(session['path']+"_ggResult", "r") as result_f:
results=result_f.read()
- return render_template('sentences.html', sentences=results+"<p><br>")
+ return render_template('sentences.html', sentences=results+"<p><br>",version=version())
# Generate a page that lists all the top 150 addiction genes with links to cytoscape graph.
@app.route("/allTopGenes")
def top150genes():
- return render_template("topAddictionGene.html")
+ return render_template("topAddictionGene.html",version=version())
if __name__ == '__main__':