-
Notifications
You must be signed in to change notification settings - Fork 1
/
go-cargo.py
81 lines (72 loc) · 2.06 KB
/
go-cargo.py
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
79
80
import pronto, six, csv
from sys import *
reader = csv.DictReader(open('chebi.tab', 'r'), delimiter='\t')
qs = {}
dups = set()
for item in reader:
iturl = item.get('item')
qit = iturl[iturl.rfind('/')+1:]
chid = 'CHEBI:' + item.get('ch')
g = qs.get(chid)
if g is None:
qs[chid] = qit
else:
dups.add(chid)
reader = csv.DictReader(open('goid.tab', 'r'), delimiter='\t')
efs = {}
for item in reader:
go = item.get('goid')
iturl = item.get('item')
it = iturl[iturl.rfind('/')+1:]
git = efs.get(go)
if git is None:
efs[go] = it
else:
print('============= {}'.format(go))
ignore = {'425228', '144646', '27941'}
secondary = {'365419':'64090', '12800':'46570', '24036':'72010',
'425228':'29484', '578003':'65172', '22318':'134249',
'30410':'42121', '3736':'48947', '593038':'49537',
'198346':'41688', '22473':'32988', '3669':'16822',
'23008':'16646', '3736':'48947', '578003':'65172'}
"""has_input
has_intermediate
has_output
has_participant
has_primary_input
has_primary_input_or_output
has_primary_output"""
ont = pronto.Ontology('/home/ralf/go-ontology/src/ontology/go-edit.obo')
check = True
for term in ont.terms.values():
goid = term.id
if goid[:3] != 'GO:':
continue
goit = efs.get(goid)
if goit is None:
continue
ns = term.other.get('namespace')
if ns is None:
continue
if ns[0] != 'biological_process' and ns[0] != 'molecular_function':
continue
l = []
ix = term.other.get('intersection_of')
if ix is not None:
l = l + ix
ix = term.other.get('relationship')
if ix is not None:
l = l + ix
if len(l) == 0:
continue
for cstr in l:
if cstr[:11] != 'transports_':
continue
chid = cstr.split()[1]
chit = qs.get(chid)
if chid in dups or chit is None:
continue
print('{}|P527|{}|P3831|Q75152245|S248|Q75154902'.format(goit, chit))
print('{}|P361|{}|P2868|Q75152245|S248|Q75154902'.format(chit, goit))
"""
"""