about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xratspub.py7
-rwxr-xr-xserver.py32
-rw-r--r--templates/topAddictionGene.html158
3 files changed, 190 insertions, 7 deletions
diff --git a/ratspub.py b/ratspub.py
index 355679c..79abc87 100755
--- a/ratspub.py
+++ b/ratspub.py
@@ -70,7 +70,6 @@ def gene_functional(gene):
     return(out)
 
 def generate_nodes(nodes_d, nodetype):
-    nodecolor={'function':"#A9CCE3", 'addiction': "#D7BDE2", 'drug': "#F9E79F", 'brain':"#A3E4D7"}
     # include all search terms even if there are no edges, just to show negative result 
     json0 =str()
     for node in nodes_d:
@@ -93,6 +92,7 @@ def generate_edges(data, filename):
         json0+="{ data: { id: '" + edgeID + "', source: '" + source + "', target: '" + target + "', sentCnt: " + str(edgeCnts[edgeID]) + ",  url:'/sentences?edgeID=" + edgeID + "' } },\n"
     return(json0)
 
+nodecolor={'function':"#A9CCE3", 'addiction': "#D7BDE2", 'drug': "#F9E79F", 'brain':"#A3E4D7"}
 addiction_d = {"reward":"reward|hedonic|incentive|intracranial self stimulation|ICSS|reinforcement|reinforcing|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",
@@ -101,7 +101,6 @@ addiction_d = {"reward":"reward|hedonic|incentive|intracranial self stimulation|
         "intoxication":"intoxication|binge"
         }
 addiction=undic(addiction_d)
-
 drug_d = {"alcohol":"alcohol|alcoholism|alcoholic|alcoholics",
         "nicotine":"smoking|nicotine|tobacco|smoker|smokers",
         "cocaine":"cocaine",
@@ -110,7 +109,6 @@ drug_d = {"alcohol":"alcohol|alcoholism|alcoholic|alcoholics",
         "cannabinoid":"endocannabinoid|cannabinoids|cannabis|endocannabinoids|marijuana|cannabidiol|cannabinoid|tetrahydrocannabinol|thc|thc 9|Oleoylethanolamide|palmitoylethanolamide|acylethanolamides"
         }
 drug=undic(drug_d)
-
 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|basal ganglia|globus pallidus|GPI",
           "accumbens":"accumbens|accumbal|shell|core|Nacc|NacSh|acbs|acbc",
@@ -120,7 +118,6 @@ brain_d ={"cortex":"cortex|prefrontal|pfc|mPFC|vmpfc|corticostriatal|cortico lim
           }
 # 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={"signalling":"signalling|signaling|phosphorylation|glycosylation",
             "transcription":"transcription|methylation|hypomethylation|hypermethylation|histone|ribosome",
             "neuroplasticity":"neuroplasticity|plasticity|long term potentiation|LTP|long term depression|LTD|synaptic|epsp|epsc|neurite|neurogenesis|boutons|mIPSC|IPSC|IPSP",
@@ -129,8 +126,6 @@ function_d={"signalling":"signalling|signaling|phosphorylation|glycosylation",
             }
 function=undic(function_d)
 
-
-
 #https://htmlcolorcodes.com/
 n0=generate_nodes(function_d, 'function')
 n1=generate_nodes(addiction_d, 'addiction')
diff --git a/server.py b/server.py
index 286f071..29aa66c 100755
--- a/server.py
+++ b/server.py
@@ -91,6 +91,32 @@ def sentences():
                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="<ol>"+out+"</ol><p>")
 
+## show the cytoscape graph for one gene from the top gene list
+@app.route("/showTopGene")
+def showTopGene():
+    topGene=request.args.get('topGene')
+    topGeneSentFile="gene_addiction_sentences_cnt.tab"
+    with open(topGeneSentFile, "r") as sents:
+        catCnt={}
+        for sent in sents:
+            (symb, cat0, cat1, pmid, sent)=sent.split("\t")
+            if (symb == topGene) :
+                if cat1 in catCnt.keys():
+                    catCnt[cat1]+=1
+                else:
+                    catCnt[cat1]=1
+    nodes= "{ data: { id: '" + topGene +  "', nodecolor: '" + "#2471A3" + "', fontweight:700, url:'/progress?query="+topGene+"' } },\n"
+    edges=str()
+    for key in catCnt.keys():
+        if ( key in drug_d.keys()):
+            nc=nodecolor["drug"]
+        else:
+            nc=nodecolor["addiction"]
+        nodes += "{ data: { id: '" + key +  "', nodecolor: '" + nc + "', nodetype: 'top150', url:'/shownode?node="+key+"' } },\n"
+        edgeID=topGeneSentFile+"|"+topGene+"|"+key
+        edges+="{ data: { id: '" + edgeID+ "', source: '" + topGene + "', target: '" + key + "', sentCnt: " + str(catCnt[key]) + ",  url:'/sentences?edgeID=" + edgeID + "' } },\n"
+    return render_template("cytoscape.html", elements=nodes+edges)
+
 @app.route("/shownode")
 def shownode():
     node=request.args.get('node')
@@ -139,11 +165,15 @@ def gene_gene():
     edges=str()
     for key in hitGenes.keys():
         #nodes += "{ data: { id: '" + key +  "', nodecolor: '" + nodecolor['top150'] + "', nodetype: 'top150', fontcolor:'#F2D7D5', url:'/shownode?nodetype=top150&node="+key+"' } },\n"
-        nodes += "{ data: { id: '" + key +  "', nodecolor: '" + nodecolor['top150'] + "', nodetype: 'top150', url:'/shownode?nodetype=top150&node="+key+"' } },\n"
+        nodes += "{ data: { id: '" + key +  "', nodecolor: '" + nodecolor['top150'] + "', nodetype: 'top150', url:'/showTopGene?topGene="+key+"' } },\n"
         edgeID=gg_file+"|"+query+"|"+key
         edges+="{ data: { id: '" + edgeID+ "', source: '" + query + "', target: '" + key + "', sentCnt: " + str(hitGenes[key]) + ",  url:'/sentences?edgeID=" + edgeID + "' } },\n"
     return render_template("cytoscape.html", elements=nodes+edges)
 
+## 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")
 
 if __name__ == '__main__':
     app.run(debug=True)
diff --git a/templates/topAddictionGene.html b/templates/topAddictionGene.html
new file mode 100644
index 0000000..0608378
--- /dev/null
+++ b/templates/topAddictionGene.html
@@ -0,0 +1,158 @@
+{% extends "layout.html" %}
+{% block content %}
+ 
+
+
+
+<li><a href="/showTopGene?topGene=FOS">FOS</a><br>
+<li><a href="/showTopGene?topGene=BDNF">BDNF</a><br>
+<li><a href="/showTopGene?topGene=DRD2">DRD2</a><br>
+<li><a href="/showTopGene?topGene=OPRM1">OPRM1</a><br>
+<li><a href="/showTopGene?topGene=TH">TH</a><br>
+<li><a href="/showTopGene?topGene=ALDH2">ALDH2</a><br>
+<li><a href="/showTopGene?topGene=TNF">TNF</a><br>
+<li><a href="/showTopGene?topGene=CHRNA5">CHRNA5</a><br>
+<li><a href="/showTopGene?topGene=NPY">NPY</a><br>
+<li><a href="/showTopGene?topGene=FAAH">FAAH</a><br>
+<li><a href="/showTopGene?topGene=CCK">CCK</a><br>
+<li><a href="/showTopGene?topGene=COMT">COMT</a><br>
+<li><a href="/showTopGene?topGene=CYP2A6">CYP2A6</a><br>
+<li><a href="/showTopGene?topGene=DRD4">DRD4</a><br>
+<li><a href="/showTopGene?topGene=ARC">ARC</a><br>
+<li><a href="/showTopGene?topGene=CHRNA3">CHRNA3</a><br>
+<li><a href="/showTopGene?topGene=FOSB">FOSB</a><br>
+<li><a href="/showTopGene?topGene=CRH">CRH</a><br>
+<li><a href="/showTopGene?topGene=TLR4">TLR4</a><br>
+<li><a href="/showTopGene?topGene=TAT">TAT</a><br>
+<li><a href="/showTopGene?topGene=APP">APP</a><br>
+<li><a href="/showTopGene?topGene=TRPV1">TRPV1</a><br>
+<li><a href="/showTopGene?topGene=GABRA2">GABRA2</a><br>
+<li><a href="/showTopGene?topGene=CYP2E1">CYP2E1</a><br>
+<li><a href="/showTopGene?topGene=CYP2D6">CYP2D6</a><br>
+<li><a href="/showTopGene?topGene=ANKK1">ANKK1</a><br>
+<li><a href="/showTopGene?topGene=CORT">CORT</a><br>
+<li><a href="/showTopGene?topGene=PDYN">PDYN</a><br>
+<li><a href="/showTopGene?topGene=POMC">POMC</a><br>
+<li><a href="/showTopGene?topGene=CNR1">CNR1</a><br>
+<li><a href="/showTopGene?topGene=CNR1">CNR1</a><br>
+<li><a href="/showTopGene?topGene=CHRNB4">CHRNB4</a><br>
+<li><a href="/showTopGene?topGene=SLC6A3">SLC6A3</a><br>
+<li><a href="/showTopGene?topGene=HTT">HTT</a><br>
+<li><a href="/showTopGene?topGene=JUN">JUN</a><br>
+<li><a href="/showTopGene?topGene=NGF">NGF</a><br>
+<li><a href="/showTopGene?topGene=GDNF">GDNF</a><br>
+<li><a href="/showTopGene?topGene=DBH">DBH</a><br>
+<li><a href="/showTopGene?topGene=GFAP">GFAP</a><br>
+<li><a href="/showTopGene?topGene=AVP">AVP</a><br>
+<li><a href="/showTopGene?topGene=MTOR">MTOR</a><br>
+<li><a href="/showTopGene?topGene=DRD3">DRD3</a><br>
+<li><a href="/showTopGene?topGene=SLC6A4">SLC6A4</a><br>
+<li><a href="/showTopGene?topGene=MAOA">MAOA</a><br>
+<li><a href="/showTopGene?topGene=CYP2B6">CYP2B6</a><br>
+<li><a href="/showTopGene?topGene=TRH">TRH</a><br>
+<li><a href="/showTopGene?topGene=OPRK1">OPRK1</a><br>
+<li><a href="/showTopGene?topGene=DRD1">DRD1</a><br>
+<li><a href="/showTopGene?topGene=OPRD1">OPRD1</a><br>
+<li><a href="/showTopGene?topGene=CDK5">CDK5</a><br>
+<li><a href="/showTopGene?topGene=BCHE">BCHE</a><br>
+<li><a href="/showTopGene?topGene=CRP">CRP</a><br>
+<li><a href="/showTopGene?topGene=BAX">BAX</a><br>
+<li><a href="/showTopGene?topGene=PENK">PENK</a><br>
+<li><a href="/showTopGene?topGene=CHRNA4">CHRNA4</a><br>
+<li><a href="/showTopGene?topGene=CHAT">CHAT</a><br>
+<li><a href="/showTopGene?topGene=NPFF">NPFF</a><br>
+<li><a href="/showTopGene?topGene=SRC">SRC</a><br>
+<li><a href="/showTopGene?topGene=CYP3A4">CYP3A4</a><br>
+<li><a href="/showTopGene?topGene=ABCB1">ABCB1</a><br>
+<li><a href="/showTopGene?topGene=MECP2">MECP2</a><br>
+<li><a href="/showTopGene?topGene=HOMER2">HOMER2</a><br>
+<li><a href="/showTopGene?topGene=TAAR1">TAAR1</a><br>
+<li><a href="/showTopGene?topGene=EGFR">EGFR</a><br>
+<li><a href="/showTopGene?topGene=TPH2">TPH2</a><br>
+<li><a href="/showTopGene?topGene=HTR2A">HTR2A</a><br>
+<li><a href="/showTopGene?topGene=CCL2">CCL2</a><br>
+<li><a href="/showTopGene?topGene=OXT">OXT</a><br>
+<li><a href="/showTopGene?topGene=HCRT">HCRT</a><br>
+<li><a href="/showTopGene?topGene=CHRNB3">CHRNB3</a><br>
+<li><a href="/showTopGene?topGene=CHRNB2">CHRNB2</a><br>
+<li><a href="/showTopGene?topGene=RGS9">RGS9</a><br>
+<li><a href="/showTopGene?topGene=PER2">PER2</a><br>
+<li><a href="/showTopGene?topGene=CRHR1">CRHR1</a><br>
+<li><a href="/showTopGene?topGene=RGS4">RGS4</a><br>
+<li><a href="/showTopGene?topGene=MIF">MIF</a><br>
+<li><a href="/showTopGene?topGene=SIRT1">SIRT1</a><br>
+<li><a href="/showTopGene?topGene=DBI">DBI</a><br>
+<li><a href="/showTopGene?topGene=CHRM2">CHRM2</a><br>
+<li><a href="/showTopGene?topGene=MIP">MIP</a><br>
+<li><a href="/showTopGene?topGene=CCL4">CCL4</a><br>
+<li><a href="/showTopGene?topGene=APOE">APOE</a><br>
+<li><a href="/showTopGene?topGene=SNCA">SNCA</a><br>
+<li><a href="/showTopGene?topGene=PTH">PTH</a><br>
+<li><a href="/showTopGene?topGene=PER1">PER1</a><br>
+<li><a href="/showTopGene?topGene=GSTM1">GSTM1</a><br>
+<li><a href="/showTopGene?topGene=CHRNA6">CHRNA6</a><br>
+<li><a href="/showTopGene?topGene=HTR1B">HTR1B</a><br>
+<li><a href="/showTopGene?topGene=HMGB1">HMGB1</a><br>
+<li><a href="/showTopGene?topGene=ANG">ANG</a><br>
+<li><a href="/showTopGene?topGene=HDAC2">HDAC2</a><br>
+<li><a href="/showTopGene?topGene=GPR55">GPR55</a><br>
+<li><a href="/showTopGene?topGene=FYN">FYN</a><br>
+<li><a href="/showTopGene?topGene=AGRP">AGRP</a><br>
+<li><a href="/showTopGene?topGene=STAT3">STAT3</a><br>
+<li><a href="/showTopGene?topGene=MTHFR">MTHFR</a><br>
+<li><a href="/showTopGene?topGene=HOMER1">HOMER1</a><br>
+<li><a href="/showTopGene?topGene=GRIN1">GRIN1</a><br>
+<li><a href="/showTopGene?topGene=GAD1">GAD1</a><br>
+<li><a href="/showTopGene?topGene=GABRA1">GABRA1</a><br>
+<li><a href="/showTopGene?topGene=FKBP5">FKBP5</a><br>
+<li><a href="/showTopGene?topGene=EGR1">EGR1</a><br>
+<li><a href="/showTopGene?topGene=CYP2C19">CYP2C19</a><br>
+<li><a href="/showTopGene?topGene=VIP">VIP</a><br>
+<li><a href="/showTopGene?topGene=TRPA1">TRPA1</a><br>
+<li><a href="/showTopGene?topGene=NLRP3">NLRP3</a><br>
+<li><a href="/showTopGene?topGene=GRK2">GRK2</a><br>
+<li><a href="/showTopGene?topGene=GRIN2B">GRIN2B</a><br>
+<li><a href="/showTopGene?topGene=ARRB2">ARRB2</a><br>
+<li><a href="/showTopGene?topGene=ALDH1A1">ALDH1A1</a><br>
+<li><a href="/showTopGene?topGene=CYP1A2">CYP1A2</a><br>
+<li><a href="/showTopGene?topGene=CYP1A1">CYP1A1</a><br>
+<li><a href="/showTopGene?topGene=CNR2">CNR2</a><br>
+<li><a href="/showTopGene?topGene=MBP">MBP</a><br>
+<li><a href="/showTopGene?topGene=JUNB">JUNB</a><br>
+<li><a href="/showTopGene?topGene=GRIN2A">GRIN2A</a><br>
+<li><a href="/showTopGene?topGene=GRIA1">GRIA1</a><br>
+<li><a href="/showTopGene?topGene=FGF2">FGF2</a><br>
+<li><a href="/showTopGene?topGene=SP1">SP1</a><br>
+<li><a href="/showTopGene?topGene=NTRK2">NTRK2</a><br>
+<li><a href="/showTopGene?topGene=HTR3A">HTR3A</a><br>
+<li><a href="/showTopGene?topGene=OPRL1">OPRL1</a><br>
+<li><a href="/showTopGene?topGene=NR4A2">NR4A2</a><br>
+<li><a href="/showTopGene?topGene=EGF">EGF</a><br>
+<li><a href="/showTopGene?topGene=ALK">ALK</a><br>
+<li><a href="/showTopGene?topGene=NCAM1">NCAM1</a><br>
+<li><a href="/showTopGene?topGene=GAD2">GAD2</a><br>
+<li><a href="/showTopGene?topGene=CD14">CD14</a><br>
+<li><a href="/showTopGene?topGene=MAP2">MAP2</a><br>
+<li><a href="/showTopGene?topGene=HTR1A">HTR1A</a><br>
+<li><a href="/showTopGene?topGene=GRM3">GRM3</a><br>
+<li><a href="/showTopGene?topGene=CCL5">CCL5</a><br>
+<li><a href="/showTopGene?topGene=TACR1">TACR1</a><br>
+<li><a href="/showTopGene?topGene=NOS1">NOS1</a><br>
+<li><a href="/showTopGene?topGene=KCNJ6">KCNJ6</a><br>
+<li><a href="/showTopGene?topGene=HCRTR1">HCRTR1</a><br>
+<li><a href="/showTopGene?topGene=CREM">CREM</a><br>
+<li><a href="/showTopGene?topGene=CREB1">CREB1</a><br>
+<li><a href="/showTopGene?topGene=BCL2">BCL2</a><br>
+<li><a href="/showTopGene?topGene=SOD2">SOD2</a><br>
+<li><a href="/showTopGene?topGene=SNAP25">SNAP25</a><br>
+<li><a href="/showTopGene?topGene=DLG4">DLG4</a><br>
+<li><a href="/showTopGene?topGene=SLC18A2">SLC18A2</a><br>
+<li><a href="/showTopGene?topGene=MGLL">MGLL</a><br>
+<li><a href="/showTopGene?topGene=IL4">IL4</a><br>
+<li><a href="/showTopGene?topGene=IL1B">IL1B</a><br>
+<li><a href="/showTopGene?topGene=IL10">IL10</a><br>
+<li><a href="/showTopGene?topGene=GRM7">GRM7</a><br>
+<li><a href="/showTopGene?topGene=GRIA2">GRIA2</a><br>
+<li><a href="/showTopGene?topGene=DNMT1">DNMT1</a><br>
+
+{% endblock %}