aboutsummaryrefslogtreecommitdiff
path: root/topGene_step1_cnt_abstracts.py
diff options
context:
space:
mode:
authorHao Chen2019-05-14 22:47:16 -0500
committerHao Chen2019-05-14 22:47:16 -0500
commit7699060b030394399fd7aff9c1f3e2840f5b834f (patch)
tree69531f1b33e651f863634061d41f22fd757d233f /topGene_step1_cnt_abstracts.py
parent72bb5dd7ff7e9b2c098042843d62b96e6c09f497 (diff)
downloadgenecup-7699060b030394399fd7aff9c1f3e2840f5b834f.tar.gz
step 1 in topgene
Diffstat (limited to 'topGene_step1_cnt_abstracts.py')
-rwxr-xr-xtopGene_step1_cnt_abstracts.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/topGene_step1_cnt_abstracts.py b/topGene_step1_cnt_abstracts.py
new file mode 100755
index 0000000..0880aff
--- /dev/null
+++ b/topGene_step1_cnt_abstracts.py
@@ -0,0 +1,37 @@
+#!/bin/env python3
+import os
+import re
+import time
+from ratspub import *
+
+def gene_addiction_cnt(gene):
+ q="\"(" + addiction.replace("|", "[tiab] OR ") + ") AND (" + drug.replace("|", "[tiab] OR ", ) + ") AND (" + gene + ")\""
+ count=os.popen('esearch -db pubmed -query ' + q + ' | xtract -pattern ENTREZ_DIRECT -element Count ').read()
+ if (len(count)==0):
+ print("pause")
+ time.sleep(15)
+ return gene_addiction_cnt(gene)
+ else:
+ return (count)
+
+out=open("gene_addiction_abstract_cnt_result.tab", "w+")
+
+with open ("./ncbi_gene_symb_syno_name_txid9606.txt", "r") as f:
+ for line in f:
+ line=re.sub(r"\)|\(|\[|\]|\*|\'","",line.strip())
+ if "\t" in line:
+ (gene, synostring)=line.strip().split("\t")
+ if "|" in synostring:
+ synos=synostring.split("|")
+ elif len(synostring)>3:
+ synos=synostring
+ for syno in synos:
+ if len(syno)>3:
+ gene+="|"+syno
+ else:
+ gene=line.strip()
+ gene_q=gene.replace("|", " [tiab] OR ")
+ gene_q+="[tiab]"
+ count=gene_addiction_cnt(gene_q)
+ print(gene+"\t"+count)
+ out.write(gene+"\t"+count)