forked from conceptsinmotion/thea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
owl2_obo_parser.pl
46 lines (37 loc) · 1.32 KB
/
owl2_obo_parser.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
/* -*- Mode: Prolog -*- */
:- module(owl2_obo_parser,
[
owl_parse_obo_syntax_file/2
]).
:- use_module(owl2_io).
:- multifile owl2_io:suffix_format/2.
owl2_io:suffix_format(obo,obo).
:- multifile owl2_io:load_axioms_hook/3.
owl2_io:load_axioms_hook(File,obo,Opts) :-
owl_parse_obo_syntax_file(File,Opts).
owl_parse_obo_syntax_file(File,Opts) :-
absolute_file_name(File,Abs),
atom_concat(Abs,'.owl',OwlFile),
atom_concat('file://',OwlFile,OwlURI),
debug(obo,'obo2owl ~w ==> ~w URI: ~w',[File,OwlFile,OwlURI]),
obo2owl(File,OwlFile,OwlURI,Opts).
obo2owl(In,Out,URI,Opts) :-
\+ exists_file(Out),
!,
debug(obo,'creating new owl file: ~w',[URI]),
run_obo2owl(In,Out,URI,Opts).
obo2owl(In,Out,_URI,Opts) :-
time_file(In,InTime),
time_file(Out,OutTime),
debug(obo,'comparing ~w < ~w',[InTime,OutTime]),
InTime < OutTime,
\+ member(force(true),Opts),
!,
debug(obo,'~w < ~w -- using existing owl file',[InTime,OutTime]),
load_axioms(Out,owl,Opts).
obo2owl(In,Out,URI,Opts) :-
run_obo2owl(In,Out,URI,Opts).
run_obo2owl(In,Out,URI,Opts) :-
concat_atom(['obolib-obo2owl','-o',URI,In,'>/dev/null'],' ',Cmd),
shell(Cmd),
load_axioms(Out,owl,Opts).