about summary refs log tree commit diff
path: root/utility/process_gwas.py
diff options
context:
space:
mode:
authorHao Chen2020-04-22 08:24:19 -0500
committerHao Chen2020-04-22 08:24:19 -0500
commit5acb78ce96b7f47f0827838a5cc58d0527953f74 (patch)
tree8557ed9f7c1b26dd40667ecc8189143c48ad8123 /utility/process_gwas.py
parent2f58b4d9989cd319cca86b24edcc6eaa45a49c7b (diff)
parent4999cb684b2db9ddc16dbbbbf600df0ff947ae07 (diff)
downloadgenecup-5acb78ce96b7f47f0827838a5cc58d0527953f74.tar.gz
Merge branch 'master' of https://github.com/chen42/atpub
Diffstat (limited to 'utility/process_gwas.py')
-rw-r--r--utility/process_gwas.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/utility/process_gwas.py b/utility/process_gwas.py
new file mode 100644
index 0000000..eba59c0
--- /dev/null
+++ b/utility/process_gwas.py
@@ -0,0 +1,48 @@
+import re
+
+with open("./addiction_gwas.tsv", "r") as f:
+    for line in f:
+        try:
+            (pmid, trait0, gene0, gene1, snp, pval, trait1)=line.strip().split("\t")
+        except:
+            next
+        key1="unassigned"
+        key2="unassigned"
+        trait=trait0+"; "+trait1
+        genes=gene0+";"+gene1
+        if re.search('cocaine', trait, flags=re.I):
+            key1="addiction"
+            key2="cocaine"
+        elif re.search('smoking|congestive|nicotine', trait, flags=re.I):
+            key1="addiction"
+            key2="nicotine"
+        elif re.search('opioid|morphin|heroin|methadone', trait, flags=re.I):
+            key1="addiction"
+            key2="opioid"
+        elif re.search('amphetam', trait, flags=re.I):
+            key1="addiction"
+            key2="amphetamine"
+        elif re.search('canabis', trait, flags=re.I):
+            key1="addiction"
+            key2="canabis"
+        elif re.search('food', trait, flags=re.I):
+            key1="addiction"
+            key2="food"
+        elif re.search('alcohol', trait, flags=re.I):
+            key1="addiction"
+            key2="alcohol"
+        elif re.search('addiction|abuse', trait, flags=re.I):
+            key1="addiction"
+            key2="addiction"
+        else:
+            key1="behavior"
+            key2="psychiatric"
+        genes=genes.replace(" - ", ";")
+        genes=genes.replace(",", ";")
+        printed=dict()
+        for gene in genes.split(";"):
+            gene=gene.replace(" ","")
+            if gene !="NR" and gene not in  printed:
+                text="SNP:<b>"+snp+"</b>, P value: <b>"+pval+"</b>, Disease/trait:<b> "+trait0+"</b>, Mapped trait:<b> "+trait1+"</b>"
+                print (gene+"\t"+"GWAS"+"\t"+key2+"_GWAS\t"+pmid+"\t"+text)
+            printed[gene]=1