From 02311e25a43d9a9443149a0402279f0f8a48ce50 Mon Sep 17 00:00:00 2001 From: Hao Chen Date: Wed, 8 May 2019 15:58:09 -0500 Subject: improved ontology --- ratspub.py | 42 +++++++++++++++++++++--------------------- server.py | 12 ++++++------ templates/cytoscape.html | 6 ++++-- templates/index.html | 3 +-- templates/layout.html | 12 +----------- 5 files changed, 33 insertions(+), 42 deletions(-) mode change 100644 => 100755 server.py 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'\1', sent, flags=re.I) + sent=re.sub(r'\b(%s)\b' % gene, r'\1', 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'\1', 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'\1', sent, flags=re.I) + if findWholeWord(addiction_d[add0])(sent) : + sent=re.sub(r'\b(%s)\b' % addiction_d[add0], r'\1', 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 old mode 100644 new mode 100755 index 4eaf911..c9009d0 --- 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="

"+gene0 + " and " + cat0 + "

\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+= "
  • "+ text + " PMID:"+pmid+"
    " - return render_template('sentences.html', sentences=out) + return render_template('sentences.html', sentences=out+"

    ") 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 %} +

    - -

    Searching PubMed to find sentences related to addiction

    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 @@
    -- cgit v1.2.3