From 9ae000688c40f7a4f4f7aa6dd7358c8c8ebeb580 Mon Sep 17 00:00:00 2001 From: Jim Balhoff Date: Sat, 28 Oct 2023 15:13:07 -0400 Subject: [PATCH] Improve redundancy check for computed never-in-taxon. --- ...n-constraints-never-in-taxon-annotation.rq | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/sparql/taxon-constraints-never-in-taxon-annotation.rq b/src/sparql/taxon-constraints-never-in-taxon-annotation.rq index 7b489cbba4..b973c8f11d 100644 --- a/src/sparql/taxon-constraints-never-in-taxon-annotation.rq +++ b/src/sparql/taxon-constraints-never-in-taxon-annotation.rq @@ -42,16 +42,34 @@ WHERE { FILTER(STRENDS(STR(?taxon_complement), "#NOT")) BIND(IRI(STRBEFORE(STR(?taxon_complement), "#NOT")) AS ?taxon) FILTER ( - EXISTS { - ?term rdfs:subClassOf+ [ - a owl:Restriction ; - owl:onProperty in_taxon: ; - owl:someValuesFrom ?super_taxon - ] . - FILTER(!STRENDS(STR(?super_taxon), "#NOT")) - ?taxon rdfs:subClassOf+ ?super_taxon . - } + # only include computed never-in-taxon if... + ( + # there is a computed in-taxon that is a superclass of the never... + EXISTS { + ?term rdfs:subClassOf+ [ + a owl:Restriction ; + owl:onProperty in_taxon: ; + owl:someValuesFrom ?super_taxon + ] . + FILTER(!STRENDS(STR(?super_taxon), "#NOT")) + ?taxon rdfs:subClassOf+ ?super_taxon . + } + && + # and there is not another computed in-taxon that is not a superclass of the never... + NOT EXISTS { + ?term rdfs:subClassOf+ [ + a owl:Restriction ; + owl:onProperty in_taxon: ; + owl:someValuesFrom ?super_taxon + ] . + FILTER(!STRENDS(STR(?super_taxon), "#NOT")) + FILTER NOT EXISTS { + ?taxon rdfs:subClassOf+ ?super_taxon . + } + } + ) || + # or else if there are no computed in-taxon NOT EXISTS { ?term rdfs:subClassOf+ [ a owl:Restriction ;