From d453c78f6d7e65667d8cbeabcdafd36ce1a9a475 Mon Sep 17 00:00:00 2001 From: Hao Chen Date: Mon, 13 May 2019 10:29:50 -0500 Subject: all links work now --- ratspub.py | 7 +- server.py | 32 +++++++- templates/topAddictionGene.html | 158 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+), 7 deletions(-) create mode 100644 templates/topAddictionGene.html 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+= "
  • "+ text + " PMID:"+pmid+"
    " return render_template('sentences.html', sentences="
      "+out+"

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

  • FOS
    +
  • BDNF
    +
  • DRD2
    +
  • OPRM1
    +
  • TH
    +
  • ALDH2
    +
  • TNF
    +
  • CHRNA5
    +
  • NPY
    +
  • FAAH
    +
  • CCK
    +
  • COMT
    +
  • CYP2A6
    +
  • DRD4
    +
  • ARC
    +
  • CHRNA3
    +
  • FOSB
    +
  • CRH
    +
  • TLR4
    +
  • TAT
    +
  • APP
    +
  • TRPV1
    +
  • GABRA2
    +
  • CYP2E1
    +
  • CYP2D6
    +
  • ANKK1
    +
  • CORT
    +
  • PDYN
    +
  • POMC
    +
  • CNR1
    +
  • CNR1
    +
  • CHRNB4
    +
  • SLC6A3
    +
  • HTT
    +
  • JUN
    +
  • NGF
    +
  • GDNF
    +
  • DBH
    +
  • GFAP
    +
  • AVP
    +
  • MTOR
    +
  • DRD3
    +
  • SLC6A4
    +
  • MAOA
    +
  • CYP2B6
    +
  • TRH
    +
  • OPRK1
    +
  • DRD1
    +
  • OPRD1
    +
  • CDK5
    +
  • BCHE
    +
  • CRP
    +
  • BAX
    +
  • PENK
    +
  • CHRNA4
    +
  • CHAT
    +
  • NPFF
    +
  • SRC
    +
  • CYP3A4
    +
  • ABCB1
    +
  • MECP2
    +
  • HOMER2
    +
  • TAAR1
    +
  • EGFR
    +
  • TPH2
    +
  • HTR2A
    +
  • CCL2
    +
  • OXT
    +
  • HCRT
    +
  • CHRNB3
    +
  • CHRNB2
    +
  • RGS9
    +
  • PER2
    +
  • CRHR1
    +
  • RGS4
    +
  • MIF
    +
  • SIRT1
    +
  • DBI
    +
  • CHRM2
    +
  • MIP
    +
  • CCL4
    +
  • APOE
    +
  • SNCA
    +
  • PTH
    +
  • PER1
    +
  • GSTM1
    +
  • CHRNA6
    +
  • HTR1B
    +
  • HMGB1
    +
  • ANG
    +
  • HDAC2
    +
  • GPR55
    +
  • FYN
    +
  • AGRP
    +
  • STAT3
    +
  • MTHFR
    +
  • HOMER1
    +
  • GRIN1
    +
  • GAD1
    +
  • GABRA1
    +
  • FKBP5
    +
  • EGR1
    +
  • CYP2C19
    +
  • VIP
    +
  • TRPA1
    +
  • NLRP3
    +
  • GRK2
    +
  • GRIN2B
    +
  • ARRB2
    +
  • ALDH1A1
    +
  • CYP1A2
    +
  • CYP1A1
    +
  • CNR2
    +
  • MBP
    +
  • JUNB
    +
  • GRIN2A
    +
  • GRIA1
    +
  • FGF2
    +
  • SP1
    +
  • NTRK2
    +
  • HTR3A
    +
  • OPRL1
    +
  • NR4A2
    +
  • EGF
    +
  • ALK
    +
  • NCAM1
    +
  • GAD2
    +
  • CD14
    +
  • MAP2
    +
  • HTR1A
    +
  • GRM3
    +
  • CCL5
    +
  • TACR1
    +
  • NOS1
    +
  • KCNJ6
    +
  • HCRTR1
    +
  • CREM
    +
  • CREB1
    +
  • BCL2
    +
  • SOD2
    +
  • SNAP25
    +
  • DLG4
    +
  • SLC18A2
    +
  • MGLL
    +
  • IL4
    +
  • IL1B
    +
  • IL10
    +
  • GRM7
    +
  • GRIA2
    +
  • DNMT1
    + +{% endblock %} -- cgit v1.2.3