This repository was archived by the owner on Apr 7, 2021. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
78 lines (66 loc) · 2.61 KB
/
Copy pathmain.py
File metadata and controls
78 lines (66 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# -*- encoding: utf-8 -*-
"""
The main module
"""
import argparse
import utils
def main():
orpha_genes = {}
hyb_db = {}
hyb_db_gene = {}
hyb_db_annotation = {}
biogrid_db = {}
ap = argparse.ArgumentParser()
ap.add_argument('--xml')
ap.add_argument('--hyb_db')
ap.add_argument('--biogrid')
ap.add_argument('--output')
args = ap.parse_args()
orpha_genes = utils.load_orpha_genes(args.xml)
hyb_db = utils.load_hyb_db_genes(args.hyb_db)
biogrid_db = utils.load_biogrid_genes(args.biogrid)
i = 0
hyb_db_list = sorted(hyb_db.keys())
while i <= len(hyb_db):
uplimit = i+500
if uplimit > len(hyb_db_list):
uplimit = len(hyb_db_list)
tmp_list = hyb_db_list[i:uplimit]
gene_symbol_list = utils.convert_entrez_to_gene_symbol(tmp_list)
i=i+500
print(str(i))
for line in gene_symbol_list.iter_lines():
line = line.decode('utf-8')
gene = line.split("\t")[0]
description = line.split("\t")[1]
entrez = line.split("\t")[2]
hyb_db_gene[entrez] = hyb_db[entrez]
hyb_db_annotation[entrez] = [gene,description]
output = open(args.output, 'w')
for entrez in hyb_db_gene:
bio = ""
if hyb_db_annotation[entrez][0] in orpha_genes:
for hyb_inter in hyb_db_gene[entrez]:
if entrez in biogrid_db:
for biogrid_inter in biogrid_db[entrez]:
if hyb_inter == biogrid_inter:
bio = "*"
break
output.write(bio +"\t")
output.write(entrez+"\t")
output.write(hyb_inter+"\t")
output.write(hyb_db_annotation[entrez][0]+"\t")
if hyb_inter in hyb_db_annotation:
output.write(hyb_db_annotation[hyb_inter][0]+"\t")
else:
output.write("No hit\t")
output.write(hyb_db_annotation[entrez][1]+"\t")
if hyb_inter in hyb_db_annotation:
output.write(hyb_db_annotation[hyb_inter][1]+"\t")
else:
output.write("No hit\t")
output.write(orpha_genes[hyb_db_annotation[entrez][0]][0]+"\t")
output.write(orpha_genes[hyb_db_annotation[entrez][0]][1]+"\thttp://www.orpha.net/consor/cgi-bin/Disease_Search_Simple.php?lng=EN&Disease_Disease_Search_diseaseGroup="+orpha_genes[hyb_db_annotation[entrez][0]][0]+"&Disease_Disease_Search_diseaseType=ORPHA\n")
output.close()
if __name__ == '__main__':
main()