1
|
|
|
#!/usr/bin/env python |
2
|
|
|
"""Ensure that alternate GO IDs are in the go-basic.obo DAG go2obj dictionary.""" |
3
|
|
|
|
4
|
|
|
from goatools.base import get_godag |
5
|
|
|
from goatools.gosubdag.gosubdag import GoSubDag |
6
|
|
|
from goatools.grouper.grprdflts import GrouperDflts |
7
|
|
|
from goatools.grouper.hdrgos import HdrgosSections |
8
|
|
|
from goatools.grouper.grprobj import Grouper |
9
|
|
|
|
10
|
|
|
def test_alt_id(): |
11
|
|
|
"""Ensure that alternate GO IDs.""" |
12
|
|
|
obo_dag = get_godag("go-basic.obo") |
13
|
|
|
# Create/Initialize GoSubDag |
14
|
|
|
goids = _get_data0() |
15
|
|
|
gosubdag = GoSubDag(obo_dag.keys(), obo_dag) |
16
|
|
|
grprdflt = GrouperDflts(gosubdag) |
17
|
|
|
# Create/Initialize Grouper |
18
|
|
|
hdrobj = HdrgosSections(grprdflt.gosubdag, grprdflt.hdrgos_dflt, sections=None, hdrgos=None) |
19
|
|
|
Grouper("test_altid_gosubdag", goids, hdrobj, grprdflt.gosubdag, go2nt=None) |
20
|
|
|
alt_ids = _get_altids(obo_dag) |
21
|
|
|
obo_goids = obo_dag.keys() |
22
|
|
|
obo_goids_set = set(obo_goids) |
23
|
|
|
assert len(alt_ids.intersection(obo_goids_set)) == len(alt_ids) |
24
|
|
|
|
25
|
|
|
def _get_altids(obo_dag): |
26
|
|
|
"""Get all alternate GO ids.""" |
27
|
|
|
alt_ids_all = set() |
28
|
|
|
for goobj in obo_dag.values(): |
29
|
|
|
alt_ids_cur = goobj.alt_ids |
30
|
|
|
if alt_ids_cur: |
31
|
|
|
alt_ids_all |= set(alt_ids_cur) |
32
|
|
|
return alt_ids_all |
33
|
|
|
|
34
|
|
|
def _get_data0(): |
35
|
|
|
"""Nature GO ids. 196 unique GO IDs. 228 printed.""" |
36
|
|
|
return [ |
37
|
|
|
"GO:0007049", "GO:0022402", "GO:0022403", "GO:0000279", "GO:0006259", |
38
|
|
|
"GO:0000278", "GO:0051301", "GO:0000087", "GO:0007067", "GO:0000280", |
39
|
|
|
"GO:0048285", "GO:0006996", "GO:0006260", "GO:0006974", "GO:0033554", |
40
|
|
|
"GO:0006281", "GO:0016043", "GO:0051716", "GO:0009987", "GO:0006323", |
41
|
|
|
"GO:0051276", "GO:0007059", "GO:0006139", "GO:0065004", "GO:0051726", |
42
|
|
|
"GO:0007017", "GO:0031497", "GO:0034728", "GO:0006950", "GO:0034641", |
43
|
|
|
"GO:0006334", "GO:0006333", "GO:0034621", "GO:0006807", "GO:0006261", |
44
|
|
|
"GO:0007126", "GO:0051327", "GO:0051321", "GO:0034622", "GO:0044260", |
45
|
|
|
"GO:0043933", "GO:0000226", "GO:0042770", "GO:0000075", "GO:0006270", |
46
|
|
|
"GO:0065003", "GO:0006310", "GO:0010564", "GO:0022607", "GO:0006325", |
47
|
|
|
"GO:0043170", "GO:0008629", "GO:0007346", "GO:0044085", "GO:0008630", |
48
|
|
|
"GO:0051052", "GO:0050896", "GO:0031570", "GO:0051053", "GO:0007018", |
49
|
|
|
"GO:0007051", "GO:0007093", "GO:0006275", "GO:0009411", "GO:0034645", |
50
|
|
|
"GO:0000910", "GO:0009059", "GO:0044237", "GO:0010212", "GO:0000077", |
51
|
|
|
"GO:0030261", "GO:0009615", "GO:0002376", "GO:0006955", "GO:0006952", |
52
|
|
|
"GO:0002682", "GO:0050896", "GO:0048518", "GO:0048002", "GO:0050776", |
53
|
|
|
"GO:0009605", "GO:0048583", "GO:0050778", "GO:0051707", "GO:0048584", |
54
|
|
|
"GO:0019882", "GO:0009607", "GO:0019884", "GO:0002684", "GO:0048522", |
55
|
|
|
"GO:0009611", "GO:0051704", "GO:0002252", "GO:0001819", "GO:0006954", |
56
|
|
|
"GO:0002478", "GO:0002474", "GO:0030029", "GO:0006950", "GO:0030036", |
57
|
|
|
"GO:0007155", "GO:0022610", "GO:0048856", "GO:0050793", "GO:0048731", |
58
|
|
|
"GO:0048518", "GO:0006629", "GO:0007275", "GO:0032502", "GO:0051239", |
59
|
|
|
"GO:0048513", "GO:0048522", "GO:0044255", "GO:0048869", "GO:0009611", |
60
|
|
|
"GO:0031589", "GO:0009605", "GO:0010646", "GO:0002376", "GO:0043436", |
61
|
|
|
"GO:0019752", "GO:0006082", "GO:0032787", "GO:0042127", "GO:0009987", |
62
|
|
|
"GO:0030154", "GO:0042180", "GO:0001944", "GO:0065008", "GO:0006631", |
63
|
|
|
"GO:0009966", "GO:0048583", "GO:0002682", "GO:0001568", "GO:0009653", |
64
|
|
|
"GO:0007399", "GO:0007160", "GO:0045321", "GO:0001775", "GO:0080134", |
65
|
|
|
"GO:0051093", "GO:0048519", "GO:0030155", "GO:0007167", "GO:0042221", |
66
|
|
|
"GO:0045595", "GO:0048514", "GO:0042060", "GO:0030029", "GO:0048523", |
67
|
|
|
"GO:0002684", "GO:0051234", "GO:0006810", "GO:0051179", "GO:0007268", |
68
|
|
|
"GO:0019226", "GO:0051649", "GO:0051641", "GO:0009987", "GO:0007267", |
69
|
|
|
"GO:0006811", "GO:0007154", "GO:0007611", "GO:0015672", "GO:0006812", |
70
|
|
|
"GO:0006813", "GO:0046907", "GO:0006793", "GO:0006796", "GO:0030001", |
71
|
|
|
"GO:0006091", "GO:0007612", "GO:0015031", "GO:0043632", "GO:0019941", |
72
|
|
|
"GO:0045184", "GO:0045333", "GO:0031175", "GO:0048812", "GO:0044057", |
73
|
|
|
"GO:0048858", "GO:0007399", "GO:0007409", "GO:0030030", "GO:0010646", |
74
|
|
|
"GO:0032990", "GO:0006816", "GO:0048666", "GO:0051179", "GO:0048667", |
75
|
|
|
"GO:0048699", "GO:0030001", "GO:0006811", "GO:0022008", "GO:0050804", |
76
|
|
|
"GO:0009987", "GO:0006812", "GO:0000904", "GO:0031644", "GO:0006796", |
77
|
|
|
"GO:0006793", "GO:0051969", "GO:0030182", "GO:0016310", "GO:0015674", |
78
|
|
|
"GO:0007242", "GO:0006468", "GO:0006810", "GO:0051234", "GO:0007268", |
79
|
|
|
"GO:0000902", "GO:0019226", "GO:0051056", "GO:0043687", "GO:0032989", |
80
|
|
|
"GO:0006464", "GO:0016192", "GO:0016043", "GO:0007411", "GO:0043412", |
81
|
|
|
"GO:0007610", "GO:0007267", "GO:0009966", "GO:0048468", "GO:0007154", |
82
|
|
|
"GO:0048731", "GO:0006928", "GO:0015672"] |
83
|
|
|
|
84
|
|
|
if __name__ == '__main__': |
85
|
|
|
test_alt_id() |
86
|
|
|
|