-
Notifications
You must be signed in to change notification settings - Fork 7
/
owl_util_test.pl
81 lines (60 loc) · 2.48 KB
/
owl_util_test.pl
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
/**
tests direct execution on owl_util in-memory triples
*/
:- use_module(library(semweb/rdf11)).
:- use_module(library(sparqlprog)).
:- use_module(library(sparqlprog/emulate_builtins)).
:- use_module(library(sparqlprog/owl_util)).
:- use_module(library(sparqlprog/labelutils)).
:- use_module(library(sparqlprog/ontologies/owl)).
:- rdf_register_prefix(oboInOwl,'http://www.geneontology.org/formats/oboInOwl#').
:- rdf_register_prefix('BFO','http://purl.obolibrary.org/obo/BFO_').
:- rdf_register_prefix(obo,'http://purl.obolibrary.org/obo/').
:- rdf_register_prefix(part_of,'http://purl.obolibrary.org/obo/BFO_0000050').
foo('0').
:- begin_tests(owl_util_test,
[setup(load_test_file),
cleanup(rdf_retractall(_,_,_,_))]).
load_test_file :-
% load into a test-specific graph due to cache issue
rdf_load('tests/go_nucleus.ttl',[cache(false),
graph(owl_util)]).
run_test_query(N,X,G,L,L1) :-
setof(X,G,L1),
format('** ~w~n',[N]),
wl(L1),
assertion(L = L1).
wl(L) :-
forall((member(X,L),term_labelify(X,L1)),
writeln(L1)).
test(curie) :-
URI='http://purl.obolibrary.org/obo/BFO_123',
setof(Pre:Post,rdf_global_id(Pre:Post,URI),L),
assertion( L=['BFO':'123'] ),
ensure_curie(URI, CURIE),
assertion( CURIE = 'BFO:123' ),
rdf_global_id(part_of:'',PART_OF),
ensure_curie(PART_OF, CURIE2),
assertion( CURIE2 = 'part_of' ).
test(prefix) :-
G=subsumed_prefix_namespace(_,_,_,_),
setof(G,G,Gs),
assertion(Gs=[_,_,_]),
assertion( member(subsumed_prefix_namespace(obo,_,'BFO',_),Gs) ).
test(owl_edge) :-
rdf_global_id(part_of:'',PART_OF),
label_of('intracellular part',INTRACELLULAR_PART),
label_of('intracellular',INTRACELLULAR),
label_of('cell part',CELL_PART),
label_of('cell',CELL),
rdf_global_id(oboInOwl:hasExactSynonym,SYN),
run_test_query(edge,
part_of(S,O),
owl_edge(S,PART_OF,O),[part_of(INTRACELLULAR_PART,INTRACELLULAR),
part_of(CELL_PART,CELL)],_),
run_test_query(axiom_annotations,
a(P,V),
triple_axiom_annotation(CELL_PART,SYN,_,P,V),
[a('http://www.geneontology.org/formats/oboInOwl#hasDbXref',_)],
_).
:- end_tests(owl_util_test).