-
Notifications
You must be signed in to change notification settings - Fork 30
/
test_wd.py
44 lines (34 loc) · 1.27 KB
/
test_wd.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
from ontobio.ontol_factory import OntologyFactory
from ontobio.assoc_factory import AssociationSetFactory
from ontobio.assocmodel import AssociationSet
import ontobio.sparql.wikidata as wd
import logging
PTSD = 'DOID:2055'
def test_wd_sparql_ptsd():
"""
TODO
test using PTSD
"""
xrefs = wd.fetchall_xrefs('HP')
print("XRs: {}".format(list(xrefs.items())[:10]))
[doid] = wd.map_id(PTSD, 'DOID')
genes = wd.fetchall_sp(doid, 'genetic_association')
logging.info("GENES: {}".format(genes))
proteins = wd.canned_query('disease2protein', doid)
logging.info("PROTEINS: {}".format(proteins))
for p in proteins:
print(p)
ofactory = OntologyFactory()
afactory = AssociationSetFactory()
ont = ofactory.create('go')
aset = afactory.create(ontology=ont,
subject_category='protein',
object_category='function',
taxon='NCBITaxon:9606')
rs = aset.enrichment_test(proteins, threshold=1e-2, labels=True, direction='less')
for r in rs:
print("UNDER: "+str(r))
for p in proteins:
print("{} {}".format(p, aset.label(p)))
for t in aset.annotations(p):
print(" {} {}".format(t,ont.label(t)))