| 12 | |
| 13 | Query: |
| 14 | {{{ |
| 15 | PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> |
| 16 | PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> |
| 17 | PREFIX owl:<http://www.w3.org/2002/07/owl#> |
| 18 | PREFIX gleen:<java:edu.washington.sig.gleen.> |
| 19 | PREFIX temp:<http://sig.biostr.washington.edu/temp#> |
| 20 | PREFIX fma:<http://sig.biostr.washington.edu/fma3.0#> |
| 21 | |
| 22 | #################################################################################### |
| 23 | # Generate the NeuroFMA |
| 24 | #################################################################################### |
| 25 | CONSTRUCT { ?x ?y ?z } |
| 26 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 27 | |
| 28 | # all parts recursively of neuraxis |
| 29 | FROM NAMEDV <top_pre_neuraxis_parts> [ |
| 30 | CONSTRUCT {temp:set temp:member ?part} |
| 31 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 32 | WHERE {fma:Neuraxis gleen:OnPath ("([fma:regional_part]|[fma:constitutional_part])*" ?part)} |
| 33 | ] |
| 34 | FROM NAMEDV <pre_neuraxis_parts> [ |
| 35 | CONSTRUCT {temp:set temp:member ?part . temp:set temp:member ?c. } |
| 36 | FROM NAMEDV <top_pre_neuraxis_parts> |
| 37 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 38 | WHERE { GRAPH <top_pre_neuraxis_parts> { ?a ?b ?part } . |
| 39 | OPTIONAL { ?part rdf:type ?c } } |
| 40 | ] |
| 41 | |
| 42 | # get all inter-part attributed relationship instances (and rels) |
| 43 | FROM NAMEDV <neuraxis_attr_rels_in> [ |
| 44 | CONSTRUCT {?p ?rel ?q} |
| 45 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 46 | WHERE { GRAPH <pre_neuraxis_parts> {temp:set temp:member ?p.}. |
| 47 | ?p ?rel ?q. |
| 48 | OPTIONAL {?q rdfs:subClassOf ?super}. FILTER(!bound(?super)). |
| 49 | FILTER((?rel = fma:attributed_part) || (?rel = fma:related_part)). } |
| 50 | ] |
| 51 | |
| 52 | # get all inter-part attributed relationship instances (and rels) |
| 53 | FROM NAMEDV <neuraxis_attr_rels_out> [ |
| 54 | CONSTRUCT {?q ?rel2 ?p2.} |
| 55 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 56 | WHERE { GRAPH <pre_neuraxis_parts> {temp:set temp:member ?p2.}. |
| 57 | ?q ?rel2 ?p2. |
| 58 | OPTIONAL {?q rdfs:subClassOf ?super}. FILTER(!bound(?super)). |
| 59 | FILTER((?rel2 = fma:attributed_part) || (?rel2 = fma:related_part)). } |
| 60 | ] |
| 61 | |
| 62 | # get all inter-part attributed relationship instances (and rels) |
| 63 | FROM NAMEDV <neuraxis_attr_rels> [ |
| 64 | CONSTRUCT {temp:set temp:member ?q. |
| 65 | temp:rel_set temp:member ?rel. |
| 66 | temp:rel_set temp:member ?rel2.} |
| 67 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 68 | WHERE { GRAPH <neuraxis_attr_rels_in> {?p ?rel ?q.}. |
| 69 | GRAPH <neuraxis_attr_rels_out> {?q ?rel2 ?p2.}. } |
| 70 | ] |
| 71 | |
| 72 | # get all inter-part attributed instances types |
| 73 | FROM NAMEDV <neuraxis_parts> [ |
| 74 | CONSTRUCT {temp:set temp:member ?p. |
| 75 | temp:set temp:member fma:Concept_name. |
| 76 | temp:set temp:member fma:Query_Atlas_term. |
| 77 | temp:set temp:member fma:Neurolex_term. |
| 78 | temp:set temp:member fma:AAL_term. } |
| 79 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 80 | WHERE { { GRAPH <pre_neuraxis_parts> {temp:set temp:member ?p} |
| 81 | } UNION { |
| 82 | GRAPH <neuraxis_attr_rels> {temp:set temp:member ?q.} |
| 83 | ?q rdf:type ?p. |
| 84 | } } |
| 85 | ] |
| 86 | |
| 87 | # build graph containing all properties of all classes identified so far |
| 88 | FROM NAMEDV <neuraxis_parts_graph> [ |
| 89 | CONSTRUCT {?p ?rel ?obj} |
| 90 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 91 | WHERE {GRAPH <neuraxis_parts> {temp:set temp:member ?p}. ?p ?rel ?obj .} |
| 92 | ] |
| 93 | |
| 94 | # get all properties which either connect two of the parts above or connects a part to a literal |
| 95 | FROM NAMEDV <neuraxis_parts_props> [ |
| 96 | CONSTRUCT { temp:set temp:member ?b. |
| 97 | temp:set temp:member ?e. |
| 98 | temp:set temp:member ?rel. |
| 99 | temp:set temp:member fma:Preferred_name. |
| 100 | temp:set temp:member fma:Synonym. |
| 101 | temp:set temp:member fma:Non-English_equivalent. |
| 102 | temp:set temp:member fma:Query_Atlas. |
| 103 | temp:set temp:member fma:Neurolex. |
| 104 | temp:set temp:member fma:AAL. } |
| 105 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 106 | WHERE { { GRAPH <neuraxis_parts_graph> {?a ?b ?c}. FILTER isLiteral(?c) |
| 107 | } UNION { |
| 108 | GRAPH <neuraxis_parts_graph> {?d ?e ?f}. |
| 109 | GRAPH <neuraxis_parts> {temp:set temp:member ?f}. |
| 110 | } UNION { |
| 111 | GRAPH <neuraxis_attr_rels> {temp:rel_set temp:member ?rel.} |
| 112 | } } |
| 113 | ] |
| 114 | |
| 115 | # Our view only includes a small number of Non-physical_anatomical_entity_template |
| 116 | # (and subClass) instances. Build up a list of things to exclude. |
| 117 | FROM NAMEDV <stoppingPoint> [ |
| 118 | CONSTRUCT { temp:set temp:member ?a .} |
| 119 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 120 | WHERE { ?a gleen:OnPath ("[rdfs:subClassOf]*" fma:Non-physical_anatomical_entity_template) . } |
| 121 | ] |
| 122 | FROM NAMEDV <exclusionTypes> [ |
| 123 | CONSTRUCT { temp:set temp:member ?b } |
| 124 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 125 | WHERE { GRAPH <stoppingPoint> { ?ts ?tm ?a . } |
| 126 | ?b rdf:type ?a . |
| 127 | FILTER ( ?b != fma:AAL_term && |
| 128 | ?b != fma:Concept_name && |
| 129 | ?b != fma:Neuro_term && |
| 130 | ?b != fma:Neurolex_term && |
| 131 | ?b != fma:Non-physical_anatomical_entity_template && |
| 132 | ?b != fma:Organ_part_of_relationship_value && |
| 133 | ?b != fma:Organ_subdivision_part_of_relationship_value && |
| 134 | ?b != fma:Part_of_relationship_value && |
| 135 | ?b != fma:Query_Atlas_term && |
| 136 | ?b != fma:Structural_relationship_value ) . } |
| 137 | ] |
| 138 | |
| 139 | # determine superclasses, superproperties, and types |
| 140 | # add nodes connected to blank nodes and recurse on these |
| 141 | FROM NAMEDV <pre_neuraxis_parts_ext> [ |
| 142 | CONSTRUCT {temp:set temp:member ?c.} |
| 143 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 144 | FROM NAMEDV <exclusionTypes> |
| 145 | WHERE { { GRAPH <neuraxis_parts> {temp:set temp:member ?c}. |
| 146 | OPTIONAL {GRAPH <exclusionTypes> {?ts temp:member ?c}.}. FILTER (!bound(?ts)) . |
| 147 | } UNION { |
| 148 | GRAPH <neuraxis_parts_props> {temp:set temp:member ?c}. |
| 149 | OPTIONAL {GRAPH <exclusionTypes> {?ts temp:member ?c}.}. FILTER (!bound(?ts)) . |
| 150 | } } |
| 151 | UNION |
| 152 | CONSTRUCT {temp:set temp:member ?v.} |
| 153 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 154 | FROM NAMEDV <exclusionTypes> |
| 155 | FROM NAMEDV <pre_neuraxis_parts_ext> |
| 156 | WHERE { GRAPH <pre_neuraxis_parts_ext> {temp:set temp:member ?c.} |
| 157 | {?c rdf:type ?v.} UNION {?c rdfs:subClassOf ?v} UNION {?c rdfs:subPropertyOf ?v} UNION |
| 158 | {?c ?rel ?v. FILTER (isBlank(?c) && !isLiteral(?v)).}. |
| 159 | OPTIONAL {GRAPH <exclusionTypes> {?ts temp:member ?v}.} . FILTER (!bound(?ts)) . } |
| 160 | ] |
| 161 | |
| 162 | # add in attributed instances |
| 163 | FROM NAMEDV <neuraxis_parts_ext> [ |
| 164 | CONSTRUCT {temp:set temp:member ?p. temp:set temp:member ?q. temp:set temp:member ?cn.} |
| 165 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 166 | WHERE { { GRAPH <pre_neuraxis_parts_ext> {temp:set temp:member ?p}. |
| 167 | OPTIONAL { {?p fma:Preferred_name ?cn.}UNION |
| 168 | {?p fma:Synonym ?cn.}UNION |
| 169 | {?p fma:Non-English_equivalent ?cn.}UNION |
| 170 | {?p fma:Query_Atlas ?cn.}UNION |
| 171 | {?p fma:Neurolex ?cn.}UNION |
| 172 | {?p fma:AAL ?cn.} } |
| 173 | } UNION { |
| 174 | GRAPH <neuraxis_attr_rels> {temp:set temp:member ?q}. |
| 175 | } } |
| 176 | ] |
| 177 | |
| 178 | # build graph containing all properties of all classes identified so far |
| 179 | FROM NAMEDV <neuraxis_parts_ext_graph> [ |
| 180 | CONSTRUCT {?p ?rel ?obj} |
| 181 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 182 | WHERE {GRAPH <neuraxis_parts_ext> {temp:set temp:member ?p}. ?p ?rel ?obj .} |
| 183 | ] |
| 184 | |
| 185 | # build graph containing only properties connecting two classes in ext or a class in ext to a literal |
| 186 | FROM NAMEDV <neuraxis_view_wo_props> [ |
| 187 | CONSTRUCT {?a ?b ?c. ?d ?e ?f.} |
| 188 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 189 | WHERE { { GRAPH <neuraxis_parts_ext_graph> {?a ?b ?c}. FILTER isLiteral(?c) |
| 190 | } UNION { |
| 191 | GRAPH <neuraxis_parts_ext_graph> {?d ?e ?f}. |
| 192 | GRAPH <neuraxis_parts_ext> {temp:set temp:member ?f}. |
| 193 | } } |
| 194 | ] |
| 195 | |
| 196 | |
| 197 | # determine superclasses, superproperties, and types |
| 198 | # add nodes connected to blank nodes and recurse on these |
| 199 | FROM NAMEDV <pre_neuraxis_parts_props_ext> [ |
| 200 | CONSTRUCT {temp:set temp:member ?c.} |
| 201 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 202 | WHERE { { # we need to define all of the properties that are going to be held in the result graph |
| 203 | GRAPH <neuraxis_view_wo_props> { ?uns ?c ?uno } |
| 204 | } UNION { # see if we had any restrictions on properties; if we did, we need to define those properties fully |
| 205 | GRAPH <pre_neuraxis_parts_ext> {temp:set temp:member ?c}. |
| 206 | ?r rdf:type owl:Restriction . ?r owl:onProperty ?c . |
| 207 | } UNION { |
| 208 | GRAPH <neuraxis_parts_props> {temp:set temp:member ?c}. |
| 209 | } } |
| 210 | UNION |
| 211 | CONSTRUCT {temp:set temp:member ?v.} |
| 212 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 213 | FROM NAMEDV <pre_neuraxis_parts_props_ext> |
| 214 | WHERE { GRAPH <pre_neuraxis_parts_props_ext> {temp:set temp:member ?c.} |
| 215 | {?c rdf:type ?v.} UNION {?c rdfs:subClassOf ?v} UNION {?c rdfs:subPropertyOf ?v} UNION |
| 216 | {?c ?rel ?v. FILTER (isBlank(?c) && !isLiteral(?v)).}. } |
| 217 | ] |
| 218 | |
| 219 | FROM NAMEDV <rec_pre_neuraxis_parts_props_ext> [ |
| 220 | CONSTRUCT { ?c ?d ?e } |
| 221 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 222 | WHERE { GRAPH <pre_neuraxis_parts_props_ext> { temp:set temp:member ?c } . |
| 223 | ?c ?d ?e . |
| 224 | OPTIONAL {GRAPH <neuraxis_parts_ext> { ?ts temp:member ?e } } . |
| 225 | FILTER (isBlank(?e) || isLiteral(?e) || bound(?ts) || |
| 226 | (!bound(?ts) && !regex(str(?e),"http://sig.biostr.washington.edu/fma3.0")) ). } |
| 227 | UNION |
| 228 | CONSTRUCT { ?e ?f ?g } |
| 229 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 230 | FROM NAMEDV <rec_pre_neuraxis_parts_props_ext> |
| 231 | WHERE { GRAPH <rec_pre_neuraxis_parts_props_ext> { ?c ?d ?e } .FILTER isBlank(?e) . |
| 232 | ?e ?f ?g . |
| 233 | OPTIONAL {GRAPH <neuraxis_parts_ext> { ?ts temp:member ?g } .} . |
| 234 | FILTER (isBlank(?g) || isLiteral(?g) || bound(?ts) || |
| 235 | (!bound(?ts) && !regex(str(?g),"http://sig.biostr.washington.edu/fma3.0")) ). } |
| 236 | ] |
| 237 | |
| 238 | FROM NAMEDV <neuraxis_view> [ |
| 239 | CONSTRUCT {?a ?b ?c. ?d ?e ?f. |
| 240 | ?ontS ?ontP owl:Ontology . ?ontS ?anyOntP ?anyOntO . |
| 241 | } |
| 242 | FROM <http://sig.biostr.washington.edu/fma3.0> |
| 243 | WHERE { { GRAPH <neuraxis_view_wo_props> {?a ?b ?c}. |
| 244 | } UNION { |
| 245 | GRAPH <rec_pre_neuraxis_parts_props_ext> {?d ?e ?f}. |
| 246 | } UNION { |
| 247 | ?ontS ?ontP owl:Ontology . |
| 248 | OPTIONAL { ?ontS ?anyOntP ?anyOntO . } |
| 249 | } } |
| 250 | ] |
| 251 | |
| 252 | #################################################################################### |
| 253 | # Fixup the generated NeuroFMA |
| 254 | #################################################################################### |
| 255 | |
| 256 | |
| 257 | # Find all of the RDF list nodes that do not have an element; |
| 258 | # recursively follow the list until it either hits a node with |
| 259 | # an element or it hits rdf:nil. Track the node that points |
| 260 | # to this errant list and the entire set of reachable nodes |
| 261 | # before the errant list has an element. |
| 262 | FROM NAMEDV <identify_rdfListEmptyNodes> [ |
| 263 | CONSTRUCT { ?a rdf:rest ?b . # to be changed |
| 264 | ?b temp:rest ?c . # to be deleted |
| 265 | ?a temp:starts ?b . # first node in rest list |
| 266 | ?a temp:reaches ?c . # reachability list |
| 267 | } |
| 268 | FROM NAMEDV <neuraxis_view> |
| 269 | WHERE { GRAPH <neuraxis_view> { |
| 270 | ?a rdf:first ?noop . |
| 271 | ?a rdf:rest ?b . |
| 272 | OPTIONAL { ?b rdf:first ?a_bogus } . FILTER(!bound(?a_bogus)) . |
| 273 | ?b rdf:rest ?c . |
| 274 | } } |
| 275 | UNION |
| 276 | CONSTRUCT { ?a ?pred ?b . # to be changed |
| 277 | ?b temp:rest ?c . # to be deleted |
| 278 | ?a temp:starts ?b . # first node in rest list |
| 279 | ?a temp:reaches ?c . # reachability list |
| 280 | } |
| 281 | FROM NAMEDV <neuraxis_view> |
| 282 | WHERE { GRAPH <neuraxis_view> { |
| 283 | ?a ?pred ?b . FILTER(?pred != rdf:rest) . |
| 284 | ?b rdf:rest ?c . |
| 285 | OPTIONAL { ?b rdf:first ?b_bogus } . FILTER(!bound(?b_bogus)) . |
| 286 | } } |
| 287 | UNION |
| 288 | CONSTRUCT { ?c temp:rest ?d . # to be deleted |
| 289 | ?a temp:reaches ?d . # reachability list |
| 290 | } |
| 291 | FROM NAMEDV <identify_rdfListEmptyNodes> |
| 292 | FROM NAMEDV <neuraxis_view> |
| 293 | WHERE { GRAPH <identify_rdfListEmptyNodes> { ?a temp:reaches ?c . } . |
| 294 | GRAPH <neuraxis_view> { |
| 295 | OPTIONAL { ?c rdf:first ?noop } . FILTER(!bound(?noop)) . |
| 296 | ?c rdf:rest ?d . |
| 297 | } } |
| 298 | ] |
| 299 | |
| 300 | # Eliminate all of the edges corresponding to RDF lists elements with no value |
| 301 | FROM NAMEDV <remove_rdfListEmptyNodes> [ |
| 302 | CONSTRUCT { ?x ?y ?z . } |
| 303 | FROM NAMEDV <identify_rdfListEmptyNodes> |
| 304 | FROM NAMEDV <neuraxis_view> |
| 305 | WHERE { GRAPH <neuraxis_view> { ?x ?y ?z . } |
| 306 | OPTIONAL { GRAPH <identify_rdfListEmptyNodes> { ?x ?ynot ?z } . |
| 307 | FILTER(?ynot=temp:rest && ?y=rdf:rest) } . |
| 308 | FILTER(!bound(?ynot)) . } |
| 309 | ] |
| 310 | |
| 311 | # Remove all of the edges to the start of RDF lists containing empty nodes; |
| 312 | # we replace these edges with new edges in <add_startEdgeRdfListEmptyNodes> |
| 313 | FROM NAMEDV <remove_startEdgeRdfListEmptyNodes> [ |
| 314 | CONSTRUCT { ?q ?r ?s .} |
| 315 | FROM NAMEDV <identify_rdfListEmptyNodes> |
| 316 | FROM NAMEDV <remove_rdfListEmptyNodes> |
| 317 | WHERE { GRAPH <remove_rdfListEmptyNodes> { ?q ?r ?s . } . |
| 318 | OPTIONAL { GRAPH <identify_rdfListEmptyNodes> { ?q ?r ?t } . FILTER(?s = ?t) } . |
| 319 | FILTER(!bound(?t)) . } |
| 320 | ] |
| 321 | |
| 322 | # Add in the new edges to the RDF lists containing empty nodes |
| 323 | FROM NAMEDV <add_startEdgeRdfListEmptyNodes> [ |
| 324 | CONSTRUCT { ?t ?u ?v . |
| 325 | ?a2 ?pred2 ?d2 . |
| 326 | } |
| 327 | FROM NAMEDV <identify_rdfListEmptyNodes> |
| 328 | FROM NAMEDV <remove_startEdgeRdfListEmptyNodes> |
| 329 | FROM NAMEDV <neuraxis_view> |
| 330 | WHERE { { GRAPH <remove_startEdgeRdfListEmptyNodes> { ?t ?u ?v } |
| 331 | } UNION { |
| 332 | GRAPH <identify_rdfListEmptyNodes> { |
| 333 | ?a2 temp:starts ?b2 . |
| 334 | ?a2 ?pred2 ?gone2 . |
| 335 | FILTER(!REGEX(str(?pred2),"http://sig.biostr.washington.edu/temp#") ) . |
| 336 | ?a2 temp:reaches ?d2 . } |
| 337 | GRAPH <neuraxis_view> { OPTIONAL { ?d2 rdf:first ?nxt2 } . } |
| 338 | FILTER( (?d2 = rdf:nil) || bound(?nxt2) ) . |
| 339 | } } |
| 340 | ] |
| 341 | |
| 342 | ######################################################################################## |
| 343 | ######################################################################################## |
| 344 | |
| 345 | # Find owl:unionOf statements that have RDF lists of 0 or 1 elements. |
| 346 | # Replace the owl:unionOf statements with either the element or rdf:nil. |
| 347 | FROM NAMEDV <removed_shortUnionOfs> [ |
| 348 | CONSTRUCT { ?q ?r ?s . |
| 349 | ?before1 ?pred1 ?c1 . |
| 350 | ?before2 ?pred2 rdf:nil . |
| 351 | } |
| 352 | FROM NAMEDV <add_startEdgeRdfListEmptyNodes> |
| 353 | # Find owl:unionOfs that have 0 or 1 element. |
| 354 | FROM NAMEDV <identify_shortUnionOfs> [ |
| 355 | CONSTRUCT { |
| 356 | ?before1 ?pred1 ?a1 . |
| 357 | ?a1 owl:unionOf ?b1 . |
| 358 | ?a1 rdf:type owl:Class . |
| 359 | ?b1 rdf:first ?c1 . |
| 360 | ?b1 rdf:rest rdf:nil . |
| 361 | ?before2 ?pred2 ?a2 . |
| 362 | ?a2 owl:unionOf ?b2 . |
| 363 | ?a2 rdf:type owl:Class . |
| 364 | ?b2 rdf:rest rdf:nil . |
| 365 | } |
| 366 | FROM NAMEDV <add_startEdgeRdfListEmptyNodes> |
| 367 | WHERE { { GRAPH <add_startEdgeRdfListEmptyNodes> { |
| 368 | ?before1 ?pred1 ?a1 . |
| 369 | ?a1 owl:unionOf ?b1 . |
| 370 | ?a1 rdf:type owl:Class . |
| 371 | ?b1 rdf:first ?c1 . |
| 372 | ?b1 rdf:rest rdf:nil . |
| 373 | } |
| 374 | } UNION { |
| 375 | GRAPH <add_startEdgeRdfListEmptyNodes> { |
| 376 | ?before2 ?pred2 ?a2 . |
| 377 | ?a2 owl:unionOf ?b2 . |
| 378 | ?a2 rdf:type owl:Class . |
| 379 | OPTIONAL { ?b2 rdf:first ?c2 . } . FILTER(!bound(?c2)) . |
| 380 | ?b2 rdf:rest rdf:nil . |
| 381 | } |
| 382 | } } |
| 383 | ] |
| 384 | WHERE { { GRAPH <add_startEdgeRdfListEmptyNodes> { ?q ?r ?s . } |
| 385 | OPTIONAL { GRAPH <identify_shortUnionOfs> { ?q ?r ?t . FILTER(?s = ?t) } } |
| 386 | FILTER(!bound(?t)) . |
| 387 | } UNION { |
| 388 | GRAPH <identify_shortUnionOfs> { |
| 389 | ?before1 ?pred1 ?a1 . |
| 390 | ?a1 owl:unionOf ?b1 . |
| 391 | ?b1 rdf:first ?c1 . |
| 392 | ?b1 rdf:rest rdf:nil . |
| 393 | } |
| 394 | } UNION { |
| 395 | GRAPH <identify_shortUnionOfs> { |
| 396 | ?before2 ?pred2 ?a2 . |
| 397 | ?a2 owl:unionOf ?b2 . |
| 398 | OPTIONAL { ?b2 rdf:first ?c2 . } . FILTER(!bound(?c2)) . } |
| 399 | ?b2 rdf:rest rdf:nil . |
| 400 | } } |
| 401 | ] |
| 402 | |
| 403 | ######################################################################################## |
| 404 | ######################################################################################## |
| 405 | |
| 406 | # Remove all owl:allValuesFrom that have empty owl:unionOf lists. |
| 407 | FROM NAMEDV <remove_emptyAllValuesFrom> [ |
| 408 | CONSTRUCT { ?a ?b ?c . } |
| 409 | FROM NAMEDV <removed_shortUnionOfs> |
| 410 | |
| 411 | # identify allValuesFrom with empty RDF lists |
| 412 | FROM NAMEDV <identify_emptyAllValuesFrom> [ |
| 413 | CONSTRUCT { ?x owl:allValuesFrom ?allB . |
| 414 | ?allB rdf:type owl:Class . |
| 415 | ?allB owl:unionOf rdf:nil . |
| 416 | } |
| 417 | FROM NAMEDV <removed_shortUnionOfs> |
| 418 | WHERE { GRAPH <removed_shortUnionOfs> { |
| 419 | ?x owl:allValuesFrom ?allB . |
| 420 | ?allB rdf:type owl:Class . |
| 421 | ?allB owl:unionOf rdf:nil . |
| 422 | } } |
| 423 | ] |
| 424 | WHERE { GRAPH <removed_shortUnionOfs> { ?a ?b ?c . } |
| 425 | OPTIONAL { GRAPH <identify_emptyAllValuesFrom> { ?a ?b ?cnot . FILTER(?c=?cnot) } } . |
| 426 | FILTER(!bound(?cnot)) . } |
| 427 | ] |
| 428 | |
| 429 | ######################################################################################## |
| 430 | ######################################################################################## |
| 431 | |
| 432 | # remove the set of owl:Restrictions that do not have values associated with |
| 433 | # owl:onProperty restrictions |
| 434 | FROM NAMEDV <remove_emptyOwlOnPropertyRestrictions> [ |
| 435 | CONSTRUCT { ?a ?b ?c . } |
| 436 | FROM NAMEDV <remove_emptyAllValuesFrom> |
| 437 | # identify the set of owl:Restrictions that do not have values associated with |
| 438 | # owl:onProperty restrictions |
| 439 | FROM NAMEDV <identify_emptyOwlOnPropertyRestrictions> [ |
| 440 | CONSTRUCT { ?x rdfs:subClassOf ?owlrestrict . |
| 441 | ?owlrestrict rdf:type owl:Restriction . |
| 442 | ?owlrestrict owl:onProperty ?onprop . |
| 443 | } |
| 444 | FROM NAMEDV <remove_emptyAllValuesFrom> |
| 445 | WHERE { |
| 446 | GRAPH <remove_emptyAllValuesFrom> { |
| 447 | ?x rdfs:subClassOf ?owlrestrict . |
| 448 | ?owlrestrict rdf:type owl:Restriction . |
| 449 | ?owlrestrict owl:onProperty ?onprop . |
| 450 | OPTIONAL { ?owlrestrict ?anyp ?anyo . |
| 451 | FILTER((?anyp!=rdf:type)&&(?anyp!=owl:onProperty)) . } |
| 452 | FILTER(!bound(?anyp)) . |
| 453 | } } |
| 454 | ] |
| 455 | WHERE { GRAPH <remove_emptyAllValuesFrom> { ?a ?b ?c . } |
| 456 | OPTIONAL { GRAPH <identify_emptyOwlOnPropertyRestrictions> { ?a ?b ?cnot . FILTER(?c=?cnot) } } . |
| 457 | FILTER(!bound(?cnot)) . } |
| 458 | ] |
| 459 | WHERE { GRAPH <remove_emptyOwlOnPropertyRestrictions> { ?x ?y ?z } } |
| 460 | }}} |