aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHao Chen2019-05-09 00:07:32 -0500
committerHao Chen2019-05-09 00:07:32 -0500
commit888e95f82ec96129257ff9064e9860a275fb7b15 (patch)
tree607903cb4711517101c86e9119a8419b14a4c7d9
parent502008d20887f69557e223129e2f520d51272c2a (diff)
downloadgenecup-888e95f82ec96129257ff9064e9860a275fb7b15.tar.gz
clean up
-rwxr-xr-xratspub.py6
-rwxr-xr-xserver.py12
-rw-r--r--templates/cytoscape.html3
-rw-r--r--templates/index.html20
-rw-r--r--templates/layout.html6
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="<h3>"+gene0 + " and " + cat0 + "</h3>\n"
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+"<p>")
+ return render_template('sentences.html', sentences="<ol>"+out+"</ol><p>")
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 %}
-<script type="text/javascript" src="{{ url_for('static', filename='cytoscape.min.js') }}"></script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.6.0/cytoscape.min.js" integrity="sha256-uZV2wRlscgr52q3Wb3Oew0rKCPsM3g4aBTv46sF4qzg=" crossorigin="anonymous"></script>
+
<div id="cy"></div>
<script>
var cy = cytoscape({
diff --git a/templates/index.html b/templates/index.html
index 27455fb..ba18e0c 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -2,10 +2,26 @@
{% block content %}
<p>
- <form class="form-inline my-2 my-lg-0" action="/search">
- <input name="query" class="form-control mr-sm-2" type="search" placeholder="Rgma Nrxn3" aria-label="search" value="Rgma Nrxn3">
+ <form action="/search">
+ <input name="query" class="form-control form-control-lg" type="search" placeholder="e.g., Rgma Nrxn3, up to 5 terms are allowed" aria-label="search" value="">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
+ <br>
+ This app searches PubMed to find <u>sentences</u> that contain the query terms (e.g., gene symbols) and a drug addiction related keyword. <a href="https://github.com/chen42/RatsPub/blob/master/ratspub.py#L95-L129">These keywords</a> belong to the following categories:
+<ul>
+<li> names of abused drugs, e.g., opioids</li>
+<li> terms describing addiction, e.g., relapse </li>
+<li> key brain regions implicated in addiction, e.g., ventral striatum </li>
+<li> neurotrasmission, e.g., dopaminergic </li>
+<li> synaptic plasticity, e.g., long term potentiation </li>
+<li> intracellular signaling, e.g., phosphorylation </li>
+</ul>
+
+<br>
+Live searches are conducted through PubMed to get relevant PMIDs, which are then used to retrieve the abstracts from a <a href="https://dataguide.nlm.nih.gov/edirect/archive.html">local archive</a>. The relationships are presented as an interactive <a href="https://js.cytoscape.org" >cytoscape</a> graph. The nodes can be moved around to better reveal the connections. Clicking on the links will bring up the corresponding sentences in a new browser window.
+<p>
+<hr>
+<a href="https://github.com/chen42/ratspub"> Source code </a>
{% endblock %}
diff --git a/templates/layout.html b/templates/layout.html
index 0d3021e..d64b331 100644
--- a/templates/layout.html
+++ b/templates/layout.html
@@ -9,14 +9,13 @@
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}">
-
<title>RatsPub: Relationship with Addiction Through Searches of PubMed</title>
</head>
<body>
-<nav class="navbar navbar-expand-lg navbar-light bg-light">
+ <nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="/">RatsPub:</br> <span style="font-size:small"> <u>R</u>elationship with <u>A</u>ddiction <u>T</u>hrough <u>S</u>earches of <u>Pub</u>Med </span></a>
- <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
+ <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</nav>
@@ -27,6 +26,7 @@
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.6.0/cytoscape.min.js" integrity="sha256-uZV2wRlscgr52q3Wb3Oew0rKCPsM3g4aBTv46sF4qzg=" crossorigin="anonymous"></script>
</body>