aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcnt_gene_addiction_abstracts.py33
-rwxr-xr-xratspub.py2
2 files changed, 34 insertions, 1 deletions
diff --git a/cnt_gene_addiction_abstracts.py b/cnt_gene_addiction_abstracts.py
new file mode 100755
index 0000000..c216862
--- /dev/null
+++ b/cnt_gene_addiction_abstracts.py
@@ -0,0 +1,33 @@
+#!/bin/env python3
+import os
+import re
+import time
+from ratspub import *
+## turn dictionary (synonyms) to regular expression
+
+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()
+ return (count)
+
+out=open("gene_addiction_cnt_result_part1.tab", "w+")
+
+cnt=0
+with open ("./ncbi_gene_symb_syno_txid9606_part1.txt", "r") as f:
+ for line in f:
+ line=re.sub(r"\)|\(|\[|\]|\*|\'","",line)
+ (gene, synoms)=line.strip().split("\t")
+ if (gene[0:3] != "LOC"):
+ cnt+=1
+ for syno in synoms.split("|"):
+ if len(syno)>3:
+ gene+="|"+syno
+ gene_q=gene.replace("|", " [tiab] OR ")
+ gene_q+="[tiab]"
+ count=gene_addiction_cnt(gene_q)
+ if (len(count)==0):
+ print("pause")
+ time.sleep(10)
+ print(gene+"\t"+count)
+ out.write(gene+"\t"+count)
+
diff --git a/ratspub.py b/ratspub.py
index dd20f67..70877b6 100755
--- a/ratspub.py
+++ b/ratspub.py
@@ -105,7 +105,7 @@ addiction=undic(addiction_d)
drug_d = {"alcohol":"alcohol|alcoholism|alcoholic",
"nicotine":"smoking|nicotine|tobacco",
"cocaine":"cocaine",
- "opioid":"opioid|opioids|fentanyl|oxycodone|oxycontin|heroin|morphine|methadone|buprenorphine",
+ "opioid":"opioid|opioids|fentanyl|oxycodone|oxycontin|heroin|morphine|methadone|buprenorphine|vicodin|hydrocodone|hycodan|kadian|percoset|hydromorphone|naloxone|codeine|suboxone|tramadol|kratom",
"amphetamine":"methamphetamine|amphetamine|METH",
"cannabinoid":"endocannabinoid|cannabinoids|endocannabinoids|marijuana|cannabidiol|cannabinoid|tetrahydrocannabinol|thc|thc 9|Oleoylethanolamide|palmitoylethanolamide|acylethanolamides"
}