robot icon indicating copy to clipboard operation
robot copied to clipboard

Weird query evaluation behaviour

Open psiotwo opened this issue 2 years ago • 7 comments

Given the following input:

@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix obo: <http://purl.obolibrary.org/obo/> .
@prefix oboInOwl: <http://www.geneontology.org/formats/oboInOwl#> .

oboInOwl:hasDbXref a owl:AnnotationProperty .

obo:PR_Q9NTK1 a owl:Class .

[
    a owl:Axiom ;
    owl:annotatedSource obo:PR_Q9NTK1 ;
    owl:annotatedProperty oboInOwl:hasRelatedSynonym ;
    owl:annotatedTarget "C10orf10" ;
    oboInOwl:hasDbXref "UniProtKB:Q9NTK1" ;
] .

the presence of triple oboInOwl:hasDbXref a owl:AnnotationProperty . (T1) does affect the result of a simple query:

PREFIX oboInOwl: <http://www.geneontology.org/formats/oboInOwl#>

DELETE {
    ?concept oboInOwl:hasRelatedSynonym ?synonym .
} WHERE {
    ?concept oboInOwl:hasRelatedSynonym ?synonym
}

With T1 in, the query robot query -i input.ttl -u query.rq -o output.ttl evaluation materializes the reified axiom as :

obo:PR_Q9NTK1 a owl:Class ;
     oboInOwl:hasRelatedSynonym "C10orf10" .

Without T1, the query evaluation removes the related synonym.

I consider this behaviour inconsistent. Would expect the query to behave the same no matter whether hasDbXref is marked explicitely as AnnotationProperty or not.

psiotwo avatar Apr 20 '23 19:04 psiotwo

In order to support various OWL formats and imports, ROBOT loads all input data through OWLAPI, and then sends it to Apache Jena if SPARQL operations are required.

My understanding is that your OWL Axiom Annotation implies that there's a triple to annotate, and your example is not well-formed as you presented it. So I guess that OWLAPI is adding the triple when input.ttl is loaded.

jamesaoverton avatar Apr 20 '23 20:04 jamesaoverton

Maybe I didn't quite understand. OWL Axiom Annotations require the predicate to be declared as an OWL Annotation Property, which is a common source of confusion that you can see elsewhere on this tracker.

jamesaoverton avatar Apr 20 '23 20:04 jamesaoverton

Yes, I am aware of this - this seems just another example of a mismatch of the RDF-entailment over OWL. The query behaves

  1. intuitively for invalid OWL
  2. counterintuitively for valid OWL

psiotwo avatar Apr 20 '23 22:04 psiotwo

SPARQL UPDATE is an RDF operation, not an OWL operation. How do you suggest that ROBOT should handle it?

jamesaoverton avatar Apr 20 '23 22:04 jamesaoverton

OWL entailment regime might help (e.g. for handling the reified axioms) as an opt-in switch - https://www.w3.org/TR/sparql11-entailment/#OWLRDFBSEntRegime.

psiotwo avatar Apr 20 '23 22:04 psiotwo

What tool would we use to implement that?

jamesaoverton avatar Apr 20 '23 22:04 jamesaoverton

At some point I was working on https://github.com/kbss-cvut/owl2query - it is pretty dormant at present, but will try to look around for some other solutions and propose something here if any.

psiotwo avatar Apr 21 '23 06:04 psiotwo