aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHao Chen2019-05-08 15:58:09 -0500
committerHao Chen2019-05-08 15:58:09 -0500
commit02311e25a43d9a9443149a0402279f0f8a48ce50 (patch)
treecba0025742bf0f38837e0fa1c326e58d70ef6bbc
parentcd948b1ccf6781c17c9e4b4899ada9d654f16e83 (diff)
downloadgenecup-02311e25a43d9a9443149a0402279f0f8a48ce50.tar.gz
improved ontology
-rwxr-xr-xratspub.py42
-rwxr-xr-x[-rw-r--r--]server.py12
-rw-r--r--templates/cytoscape.html6
-rw-r--r--templates/index.html3
-rw-r--r--templates/layout.html12
5 files changed, 33 insertions, 42 deletions
diff --git a/ratspub.py b/ratspub.py
index 0670726..7400488 100755
--- a/ratspub.py
+++ b/ratspub.py
@@ -15,7 +15,7 @@ def findWholeWord(w):
return re.compile(r'\b({0})\b'.format(w), flags=re.IGNORECASE).search
def getSentences(query, gene):
- abstracts = os.popen("esearch -db pubmed -query " + query + " | efetch -format uid |fetch-pubmed -path /run/media/hao/PubMed/Archive/ | xtract -pattern PubmedArticle -element MedlineCitation/PMID,ArticleTitle,AbstractText").read()
+ abstracts = os.popen("esearch -db pubmed -query " + query + " | efetch -format uid |fetch-pubmed -path /run/media/hao/PubMed/Archive/ | xtract -pattern PubmedArticle -element MedlineCitation/PMID,ArticleTitle,AbstractText|sed \"s/-/ /g\"").read()
out=str()
for row in abstracts.split("\n"):
tiab=row.split("\t")
@@ -25,7 +25,7 @@ def getSentences(query, gene):
## keep the sentence only if it contains the gene
for sent in sentences:
if findWholeWord(gene)(sent):
- sent=re.sub(r'\b(%s)\b' % gene, r'<b>\1</b>', sent, flags=re.I)
+ sent=re.sub(r'\b(%s)\b' % gene, r'<strong>\1</strong>', sent, flags=re.I)
out+=pmid+"\t"+sent+"\n"
return(out)
@@ -40,8 +40,8 @@ def gene_addiction(gene):
sent=re.sub(r'\b(%s)\b' % drug_d[drug0], r'<b>\1</b>', sent, flags=re.I)
out+=gene+"\t"+"drug\t" + drug0+"\t"+sent+"\n"
for add0 in addiction_d:
- if findWholeWord(add0)(sent) :
- sent=re.sub(r'\b(%s)\b' % add0, r'<b>\1</b>', sent, flags=re.I)
+ if findWholeWord(addiction_d[add0])(sent) :
+ sent=re.sub(r'\b(%s)\b' % addiction_d[add0], r'<b>\1</b>', sent, flags=re.I)
out+=gene+"\t"+"addiction\t"+add0+"\t"+sent+"\n"
return(out)
@@ -92,39 +92,39 @@ def generate_edges(data):
-addiction_d = {"reward":"reward|reinforcement|conditioned place preference|CPP|self-administration|self-administered",
- "aversion":"aversion|aversive|CTA|withdrawal",
- "relapse":"relapse|reinstatement|craving|drug seeking",
+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",
"sensitization":"sensitization",
- "addiction":"addiction|drug abuse",
+ "addiction":"addiction|dependence|addictive|drug abuse|punishment|compulsive|escalation",
"intoxication":"intoxication|binge"
}
addiction=undic(addiction_d)
-drug_d = {"alcohol":"alcohol|alcoholism",
+drug_d = {"alcohol":"alcohol|alcoholism|alcoholic",
"nicotine":"smoking|nicotine|tobacco",
"cocaine":"cocaine",
- "opioid":"opioid|fentanyl|oxycodone|oxycontin|heroin|morphine",
+ "opioid":"opioid|opioids|fentanyl|oxycodone|oxycontin|heroin|morphine|methadone|buprenorphine",
"amphetamine":"methamphetamine|amphetamine|METH",
- "cannabinoid":"marijuana|cannabinoid|tetrahydrocannabinol|thc|thc-9"
+ "cannabinoid":"endocannabinoid|cannabinoids|endocannabinoids|marijuana|cannabidiol|cannabinoid|tetrahydrocannabinol|thc|thc 9|Oleoylethanolamide|palmitoylethanolamide|acylethanolamides"
}
drug=undic(drug_d)
-brain_d ={"cortex":"cortex|pfc|vmpfc|il|pl|prelimbic|infralimbic",
- "striatum":"striatum|STR",
- "accumbens":"shell|core|NAcc|acbs|acbc",
- "hippocampus":"hippocampus|hipp|hip|ca1|ca3|dentate|gyrus",
- "amygadala":"amygadala|cea|bla|amy",
- "vta":"ventral tegmental|vta|pvta"
+brain_d ={"cortex":"cortex|prefrontal|pfc|mPFC|vmpfc|corticostriatal|cortico limbic|corticolimbic|prl|prelimbic|infralimbic|orbitofrontal|cingulate|cerebral|insular|insula",
+ "striatum":"striatum|STR|striatal|caudate|putamen",
+ "accumbens":"accumbens|accumbal|shell|core|Nacc|NacSh|acbs|acbc",
+ "hippocampus":"hippocampus|hippocampal|hipp|hip|ca1|ca3|dentate gyrus|subiculum|vhipp",
+ "amygdala":"amygdala|cea|bla|amy",
+ "vta":"ventral tegmental|vta|pvta|mesolimbic|limbic|midbrain|mesoaccumbens"
}
# brain region has too many short acronyms to just use the undic function, so search PubMed using the following
brain="cortex|accumbens|striatum|amygadala|hippocampus|tegmental|mesolimbic|infralimbic|prelimbic"
-function_d={"plasticity":"LTP|LTD|plasticity|synaptic|epsp|epsc",
- "signalling":"signalling|phosphorylation|glycosylation",
+function_d={"neuroplasticity":"neuroplasticity|plasticity|long term potentiation|LTP|long term depression|LTD|synaptic|epsp|epsc|neurite|neurogenesis|boutons|mIPSC|IPSC|IPSP",
+ "signalling":"signalling|signaling|phosphorylation|glycosylation",
# "regulation":"increased|decreased|regulated|inhibited|stimulated",
- "transcription":"transcription|methylation|histone|ribosome",
- "neurotransmission": "neurotransmission|glutamate|GABA|cholinergic|serotoninergic",
+ "transcription":"transcription|methylation|hypomethylation|hypermethylation|histone|ribosome",
+ "neurotransmission": "neurotransmission|neuropeptides|neuropeptide|glutamate|glutamatergic|GABA|GABAergic|dopamine|dopaminergic|DAergic|cholinergic|nicotinic|muscarinic|serotonergic|serotonin|5 ht|acetylcholine",
}
function=undic(function_d)
diff --git a/server.py b/server.py
index 4eaf911..c9009d0 100644..100755
--- a/server.py
+++ b/server.py
@@ -1,3 +1,4 @@
+#!/bin/env python3
from flask import Flask, render_template, request, redirect
import simplejson as json
from ratspub import *
@@ -9,10 +10,6 @@ app.config['SECRET_KEY'] = '#DtfrL98G5t1dC*4'
def root():
return render_template('index.html')
-@app.route("/home")
-def home():
- return render_template('index.html')
-
@app.route("/search")
def search():
global all_sentences
@@ -33,6 +30,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()
return render_template('cytoscape.html', elements=nodes+edges)
@app.route("/sentences")
@@ -40,14 +40,14 @@ def sentences():
edge=request.args.get('edgeID')
(gene0, cat0)=edge.split("|")
print (gene0 + cat0)
- out=str()
+ 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)
+ return render_template('sentences.html', sentences=out+"<p>")
if __name__ == '__main__':
app.run(debug=True)
diff --git a/templates/cytoscape.html b/templates/cytoscape.html
index ab30562..749b042 100644
--- a/templates/cytoscape.html
+++ b/templates/cytoscape.html
@@ -20,7 +20,8 @@
{ selector: 'edge',
css: {
'content': 'data(sentCnt)',
- 'curve-style': 'bezier'
+ 'curve-style': 'bezier',
+ 'opacity': '0.3'
}
},
{ selector: 'node.highlight',
@@ -35,7 +36,8 @@
},
{
selector: 'edge.highlight',
- style: { 'mid-target-arrow-color': '#FFF' }
+ style: { 'mid-target-arrow-color': '#FFF' },
+ style:{ 'opacity': '0.9' }
},
{
selector: 'edge.semitransp',
diff --git a/templates/index.html b/templates/index.html
index 4f19269..27455fb 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -1,8 +1,7 @@
{% extends "layout.html" %}
{% block content %}
+<p>
-
-<h3> Searching PubMed to find sentences related to addiction</h3>
<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">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
diff --git a/templates/layout.html b/templates/layout.html
index 421798e..0d3021e 100644
--- a/templates/layout.html
+++ b/templates/layout.html
@@ -15,20 +15,10 @@
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
- <a class="navbar-brand" href="#">RatsPub</a>
+ <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">
<span class="navbar-toggler-icon"></span>
</button>
-
- <div class="collapse navbar-collapse" id="navbarSupportedContent">
- <ul class="navbar-nav mr-auto">
- <li class="nav-item active">
- <a class="nav-link" href="/home">Search <span class="sr-only">(current)</span></a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="/result">Result</a>
- </li>
- </div>
</nav>
<div class="container">