line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
75
|
|
2
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
224
|
|
3
|
|
|
|
|
|
|
package Conclave::OTK::Queries::OWL; |
4
|
|
|
|
|
|
|
# ABSTRACT: templates for OTK queries using OWL language |
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
2341
|
use parent qw/Template::Provider/; |
|
3
|
|
|
|
|
838
|
|
|
3
|
|
|
|
|
21
|
|
7
|
3
|
|
|
3
|
|
170
|
no warnings qw/redefine/; |
|
3
|
|
|
|
|
23
|
|
|
3
|
|
|
|
|
892
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $templates = { |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
'add_class' => <<'EOT' |
12
|
|
|
|
|
|
|
[% FOREACH p IN prefixes.keys -%] |
13
|
|
|
|
|
|
|
PREFIX [% p %]: <[% prefixes.item(p) %]> |
14
|
|
|
|
|
|
|
[% END -%] |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
INSERT DATA { |
17
|
|
|
|
|
|
|
GRAPH <[% graph %]> { |
18
|
|
|
|
|
|
|
[% name %] rdf:type owl:Class . |
19
|
|
|
|
|
|
|
[% FOREACH c IN parents -%] |
20
|
|
|
|
|
|
|
[% name %] rdfs:subClassOf [% c %] . |
21
|
|
|
|
|
|
|
[%- END %] |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
EOT |
25
|
|
|
|
|
|
|
, |
26
|
|
|
|
|
|
|
'get_classes' => <<'EOT' |
27
|
|
|
|
|
|
|
[% FOREACH p IN prefixes.keys -%] |
28
|
|
|
|
|
|
|
PREFIX [% p %]: <[% prefixes.item(p) %]> |
29
|
|
|
|
|
|
|
[% END -%] |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
SELECT ?c |
32
|
|
|
|
|
|
|
FROM <[% graph %]> |
33
|
|
|
|
|
|
|
WHERE { |
34
|
|
|
|
|
|
|
?c rdf:type owl:Class |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
EOT |
37
|
|
|
|
|
|
|
, |
38
|
|
|
|
|
|
|
'get_subclasses' => <<'EOT' |
39
|
|
|
|
|
|
|
[% FOREACH p IN prefixes.keys -%] |
40
|
|
|
|
|
|
|
PREFIX [% p %]: <[% prefixes.item(p) %]> |
41
|
|
|
|
|
|
|
[% END -%] |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
SELECT ?c FROM <[% graph %]> |
44
|
|
|
|
|
|
|
WHERE { |
45
|
|
|
|
|
|
|
?c rdf:type owl:Class . |
46
|
|
|
|
|
|
|
?c rdfs:subClassOf [% class %] . |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
EOT |
49
|
|
|
|
|
|
|
, |
50
|
|
|
|
|
|
|
'get_instance_classes' => <<'EOT' |
51
|
|
|
|
|
|
|
[% FOREACH p IN prefixes.keys -%] |
52
|
|
|
|
|
|
|
PREFIX [% p %]: <[% prefixes.item(p) %]> |
53
|
|
|
|
|
|
|
[% END -%] |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
SELECT DISTINCT ?c |
56
|
|
|
|
|
|
|
FROM <[% graph %]> |
57
|
|
|
|
|
|
|
WHERE { |
58
|
|
|
|
|
|
|
<[%- i -%]> rdf:type ?c . |
59
|
|
|
|
|
|
|
FILTER regex(str(?c), 'program#', '') |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
EOT |
62
|
|
|
|
|
|
|
, |
63
|
|
|
|
|
|
|
'add_instance' => <<'EOT' |
64
|
|
|
|
|
|
|
[% FOREACH p IN prefixes.keys -%] |
65
|
|
|
|
|
|
|
PREFIX [% p %]: <[% prefixes.item(p) %]> |
66
|
|
|
|
|
|
|
[% END -%] |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
INSERT DATA { |
69
|
|
|
|
|
|
|
GRAPH <[% graph %]> { |
70
|
|
|
|
|
|
|
[% name %] rdf:type [% class %] ; |
71
|
|
|
|
|
|
|
rdf:type owl:NamedIndividual . |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
EOT |
75
|
|
|
|
|
|
|
, |
76
|
|
|
|
|
|
|
'get_instances' => <<'EOT' |
77
|
|
|
|
|
|
|
[% FOREACH p IN prefixes.keys -%] |
78
|
|
|
|
|
|
|
PREFIX [% p %]: <[% prefixes.item(p) %]> |
79
|
|
|
|
|
|
|
[% END -%] |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
SELECT ?i |
82
|
|
|
|
|
|
|
FROM <[% graph %]> |
83
|
|
|
|
|
|
|
WHERE { |
84
|
|
|
|
|
|
|
?i rdf:type [% class %] |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
EOT |
87
|
|
|
|
|
|
|
, |
88
|
|
|
|
|
|
|
'add_obj_prop' => <<'EOT' |
89
|
|
|
|
|
|
|
[% FOREACH p IN prefixes.keys -%] |
90
|
|
|
|
|
|
|
PREFIX [% p %]: <[% prefixes.item(p) %]> |
91
|
|
|
|
|
|
|
[% END -%] |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
INSERT DATA { |
94
|
|
|
|
|
|
|
GRAPH <[% graph %]> { |
95
|
|
|
|
|
|
|
[% subject %] [% relation %] [% target %] . |
96
|
|
|
|
|
|
|
[% relation %] rdf:type owl:ObjectProperty . |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
EOT |
100
|
|
|
|
|
|
|
, |
101
|
|
|
|
|
|
|
'add_data_prop' => <<'EOT' |
102
|
|
|
|
|
|
|
[% FOREACH p IN prefixes.keys -%] |
103
|
|
|
|
|
|
|
PREFIX [% p %]: <[% prefixes.item(p) %]> |
104
|
|
|
|
|
|
|
[% END -%] |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
INSERT DATA { |
107
|
|
|
|
|
|
|
GRAPH <[% graph %]> { |
108
|
|
|
|
|
|
|
[% subject %] [% relation %] "[% target %]"^^xsd:[% type %] . |
109
|
|
|
|
|
|
|
[% relation %] rdf:type owl:DatatypeProperty . |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
EOT |
113
|
|
|
|
|
|
|
, |
114
|
|
|
|
|
|
|
'select_from_graph' => <<'EOT' |
115
|
|
|
|
|
|
|
[% FOREACH p IN prefixes.keys -%] |
116
|
|
|
|
|
|
|
PREFIX [% p %]: <[% prefixes.item(p) %]> |
117
|
|
|
|
|
|
|
[% END -%] |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
SELECT ?s ?p ?r |
120
|
|
|
|
|
|
|
FROM <[% graph %]> |
121
|
|
|
|
|
|
|
WHERE { |
122
|
|
|
|
|
|
|
?s ?p ?r |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
EOT |
125
|
|
|
|
|
|
|
, |
126
|
|
|
|
|
|
|
'graph_dump_rdf' => <<'EOT' |
127
|
|
|
|
|
|
|
CONSTRUCT { ?s ?p ?o } WHERE { GRAPH <[% graph %]> { ?s ?p ?o } } |
128
|
|
|
|
|
|
|
EOT |
129
|
|
|
|
|
|
|
, |
130
|
|
|
|
|
|
|
'get_children' => <<'EOT' |
131
|
|
|
|
|
|
|
[% FOREACH p IN prefixes.keys -%] |
132
|
|
|
|
|
|
|
PREFIX [% p %]: <[% prefixes.item(p) %]> |
133
|
|
|
|
|
|
|
[% END -%] |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
CONSTRUCT { ?c rdfs:subClassOf [% parent %] } |
136
|
|
|
|
|
|
|
WHERE { GRAPH <[% graph %]> { ?c rdfs:subClassOf [% parent %] } } |
137
|
|
|
|
|
|
|
EOT |
138
|
|
|
|
|
|
|
, |
139
|
|
|
|
|
|
|
'get_obj_props' => <<'EOT' |
140
|
|
|
|
|
|
|
[% FOREACH p IN prefixes.keys -%] |
141
|
|
|
|
|
|
|
PREFIX [% p %]: <[% prefixes.item(p) %]> |
142
|
|
|
|
|
|
|
[% END -%] |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
SELECT DISTINCT ?n ?p ?v |
145
|
|
|
|
|
|
|
FROM <[% graph %]> |
146
|
|
|
|
|
|
|
WHERE { |
147
|
|
|
|
|
|
|
?n ?p ?v . |
148
|
|
|
|
|
|
|
?p rdf:type owl:ObjectProperty . |
149
|
|
|
|
|
|
|
FILTER ( |
150
|
|
|
|
|
|
|
REGEX(str(?n), "^<?[% instance %]>?$") || |
151
|
|
|
|
|
|
|
REGEX(str(?v), "^<?[% instance %]>?$") |
152
|
|
|
|
|
|
|
) |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
EOT |
155
|
|
|
|
|
|
|
, |
156
|
|
|
|
|
|
|
'get_obj_props_for' => <<'EOT' |
157
|
|
|
|
|
|
|
[% FOREACH p IN prefixes.keys -%] |
158
|
|
|
|
|
|
|
PREFIX [% p %]: <[% prefixes.item(p) %]> |
159
|
|
|
|
|
|
|
[% END -%] |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
SELECT DISTINCT ?o |
162
|
|
|
|
|
|
|
FROM <[% graph %]> |
163
|
|
|
|
|
|
|
WHERE { |
164
|
|
|
|
|
|
|
?o [% rel %] [% el %] |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
EOT |
167
|
|
|
|
|
|
|
, |
168
|
|
|
|
|
|
|
'get_data_props' => <<'EOT' |
169
|
|
|
|
|
|
|
[% FOREACH p IN prefixes.keys -%] |
170
|
|
|
|
|
|
|
PREFIX [% p %]: <[% prefixes.item(p) %]> |
171
|
|
|
|
|
|
|
[% END -%] |
172
|
|
|
|
|
|
|
SELECT DISTINCT ?n ?p ?v |
173
|
|
|
|
|
|
|
FROM <[% graph %]> |
174
|
|
|
|
|
|
|
WHERE { |
175
|
|
|
|
|
|
|
?n ?p ?v . |
176
|
|
|
|
|
|
|
?p rdf:type owl:DatatypeProperty . |
177
|
|
|
|
|
|
|
FILTER ( |
178
|
|
|
|
|
|
|
REGEX(str(?n), "^<?[% instance.remove('(<|>)') %]>?$") || |
179
|
|
|
|
|
|
|
REGEX(str(?v), "^<?[% instance.remove('(<|>)') %]>?$") |
180
|
|
|
|
|
|
|
) |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
EOT |
183
|
|
|
|
|
|
|
, |
184
|
|
|
|
|
|
|
'get_ranges' => <<'EOT' |
185
|
|
|
|
|
|
|
[% FOREACH p IN prefixes.keys -%] |
186
|
|
|
|
|
|
|
PREFIX [% p %]: <[% prefixes.item(p) %]> |
187
|
|
|
|
|
|
|
[% END -%] |
188
|
|
|
|
|
|
|
SELECT DISTINCT ?p ?r |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
FROM <[% graph %]> |
191
|
|
|
|
|
|
|
WHERE { |
192
|
|
|
|
|
|
|
?p rdf:type owl:ObjectProperty . |
193
|
|
|
|
|
|
|
?p rdfs:range ?r . |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
EOT |
196
|
|
|
|
|
|
|
}; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub _template_modified { |
199
|
23
|
|
|
23
|
|
89413
|
my($self,$path) = @_; |
200
|
|
|
|
|
|
|
|
201
|
23
|
|
|
|
|
75
|
return 1; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub _template_content { |
205
|
10
|
|
|
10
|
|
59
|
my($self,$path) = @_; |
206
|
|
|
|
|
|
|
|
207
|
10
|
|
|
|
|
55
|
$path =~ s#^templates/##; |
208
|
10
|
50
|
|
|
|
48
|
$self->debug("get $path") if $self->{DEBUG}; |
209
|
|
|
|
|
|
|
|
210
|
10
|
|
|
|
|
35
|
my $data = $templates->{$path}; |
211
|
10
|
|
|
|
|
43
|
my $error = "error: $path not found"; |
212
|
10
|
|
|
|
|
20
|
my $mod_date = 1; |
213
|
|
|
|
|
|
|
|
214
|
10
|
|
|
|
|
40
|
return $data; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
1; |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
__END__ |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=pod |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=encoding UTF-8 |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head1 NAME |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Conclave::OTK::Queries::OWL - templates for OTK queries using OWL language |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head1 VERSION |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
version 0.01 |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 SYNOPSIS |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
TODO |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head1 DESCRIPTION |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
TODO |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 AUTHOR |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Nuno Carvalho <smash@cpan.org> |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
This software is copyright (c) 2014-2015 by Nuno Carvalho <smash@cpan.org>. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
250
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=cut |