aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHao Chen2020-03-07 22:34:27 -0600
committerHao Chen2020-03-07 22:34:27 -0600
commitff5c5d3aff13f4f81c9b3e9a39a63e7794cb609e (patch)
tree0a0910c6733d2e3695960cbbc1e5efc17a3f488c
parentcea42615bd0c0c02bad574db42fc7c44c5ca5c66 (diff)
downloadgenecup-ff5c5d3aff13f4f81c9b3e9a39a63e7794cb609e.tar.gz
Hakan fixing the count bug
-rwxr-xr-xratspub.py27
-rwxr-xr-xserver.py2
2 files changed, 16 insertions, 13 deletions
diff --git a/ratspub.py b/ratspub.py
index 355bc1f..f3effad 100755
--- a/ratspub.py
+++ b/ratspub.py
@@ -56,38 +56,38 @@ def generate_nodes_json(nodes_d, nodetype):
return(nodes_json0)
def generate_edges(data, filename):
- pmid_temp=0
+ pmid_list=[]
json0=str()
edgeCnts={}
for line in data.split("\n"):
if len(line.strip())!=0:
(source, cat, target, pmid, sent) = line.split("\t")
edgeID=filename+"|"+source+"|"+target
- if (edgeID in edgeCnts) and (pmid != pmid_temp):
+ if (edgeID in edgeCnts) and (pmid+target not in pmid_list):
edgeCnts[edgeID]+=1
- pmid_temp = pmid
- elif (edgeID not in edgeCnts):
+ pmid_list.append(pmid+target)
+ elif (edgeID not in edgeCnts) and (pmid+target not in pmid_list):
edgeCnts[edgeID]=1
- pmid_temp = pmid
+ pmid_list.append(pmid+target)
for edgeID in edgeCnts:
(filename, source,target)=edgeID.split("|")
json0+="{ data: { id: '" + edgeID + "', source: '" + source + "', target: '" + target + "', sentCnt: " + str(edgeCnts[edgeID]) + ", url:'/sentences?edgeID=" + edgeID + "' } },\n"
return(json0)
def generate_edges_json(data, filename):
- pmid_temp=0
+ pmid_list=[]
edges_json0=str()
edgeCnts={}
for line in data.split("\n"):
if len(line.strip())!=0:
(source, cat, target, pmid, sent) = line.split("\t")
edgeID=filename+"|"+source+"|"+target
- if (edgeID in edgeCnts) and (pmid != pmid_temp):
+ if (edgeID in edgeCnts) and (pmid+target not in pmid_list):
edgeCnts[edgeID]+=1
- pmid_temp = pmid
- elif (edgeID not in edgeCnts):
+ pmid_list.append(pmid+target)
+ elif (edgeID not in edgeCnts) and (pmid+target not in pmid_list):
edgeCnts[edgeID]=1
- pmid_temp = pmid
+ pmid_list.append(pmid+target)
for edgeID in edgeCnts:
(filename, source,target)=edgeID.split("|")
edges_json0+="{ \"id\": \"" + edgeID + "\", \"source\": \"" + source + "\", \"target\": \"" + target + "\", \"sentCnt\": \"" + str(edgeCnts[edgeID]) + "\", \"url\":\"/sentences?edgeID=" + edgeID + "\" },\n"
@@ -160,10 +160,15 @@ nj4=generate_nodes_json(stress_d, 'stress')
nj5=generate_nodes_json(psychiatric_d, 'psychiatric')
nj6=generate_nodes_json(psychiatric_d, 'GWAS')
+
+pubmed_path="~/Dropbox/ChenLab/Hakan/RatsPub/PubMed/Archive"
+
+'''
host= os.popen('hostname').read().strip()
if host=="x1":
pubmed_path="/run/media/hao/PubMed/Archive/"
elif host=="hchen3":
pubmed_path="/media/hao/2d554499-6c5b-462d-85f3-5c49b25f4ac8/PubMed/Archive"
elif host=="penguin2":
- pubmed_path="/export2/PubMed/Archive" \ No newline at end of file
+ pubmed_path="/export2/PubMed/Archive"
+''' \ No newline at end of file
diff --git a/server.py b/server.py
index 90e783e..b0ba670 100755
--- a/server.py
+++ b/server.py
@@ -535,7 +535,6 @@ def cytoscape():
@app.route("/sentences")
def sentences():
- pmid_temp=""
pmid_list=[]
edge=request.args.get('edgeID')
(tf_name, gene0, cat0)=edge.split("|")
@@ -547,7 +546,6 @@ def sentences():
(gene,nouse,cat, pmid, text)=sent.split("\t")
if (gene.upper() == gene0.upper() and cat.upper() == cat0.upper() and (pmid+cat0 not in pmid_list)) :
out3+= "<li> "+ text + " <a href=\"https://www.ncbi.nlm.nih.gov/pubmed/?term=" + pmid +"\" target=_new>PMID:"+pmid+"<br></a>"
- pmid_temp = pmid
pmid_list.append(pmid+cat0)
out1="<h3>"+gene0 + " and " + cat0 + "</h3>\n"
if len(pmid_list)>1: