Skip to content

Create no-orphaned-subclasses.sparql#459

Merged
neilotte merged 3 commits into
developfrom
448-new-query
Sep 11, 2024
Merged

Create no-orphaned-subclasses.sparql#459
neilotte merged 3 commits into
developfrom
448-new-query

Conversation

@oliviahobai
Copy link
Copy Markdown
Contributor

There is probably some trouble with lines 10-11. When it's convenient, could somebody else look at this file, please?

There is probably some trouble with lines 10-11. When it's convenient, could somebody else look at this file, please?
@swartik
Copy link
Copy Markdown
Contributor

swartik commented Sep 3, 2024

@oliviahobai

You can delete lines 9–11.

Also, that query isn't correct. My fault: I wrote it without fully understanding how github does error-checking. If all CCO classes have a parent class, the query shouldn't return any results at all. Unless someone beats me to it, I will provide a correct query in the next few days.

?cls a owl:Class
FILTER isIRI(?cls)
FILTER NOT EXISTS { ?cls rdfs:subClassOf ?supercls }
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Insert before line 21:

   FILTER (?cls != <http://purl.obolibrary.org/obo/BFO_0000001>)

# Author:
# github.com/swartik

Severity:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete lines 10 through 12.

# Title:
# No Orphaned Subclasses
# Constraint Description:
# All classes must have some parent class. The only result otherwise should be “entity”.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace line 4 with:

#     All CCO classes must have a superclass.

# Constraint Description:
# All classes must have some parent class. The only result otherwise should be “entity”.
# Severity:
# Warning
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change Warning to Error.

Based on the updates provided by @swartik, thank you. Tell me if there are any remaining edits that need to be made.
@neilotte
Copy link
Copy Markdown
Contributor

neilotte commented Sep 7, 2024

@oliviahobai @swartik

The present query returns classes that are:
a) not identical to BFO:entity,
b) IRIs
c) not subclasses of some class.

This query doesn't restrict the target IRIs to only CCO, nor does it rule out a class being a subclass of some other class (e.g. owl:Thing, skos:altLabel, etc).

I think the desired query is that every class in CCO should be a direct or transitive subclass of a BFO class. Here's an example. Let me know what you think.

`

Title:

No CCO class should fall outside the BFO hierarchy

Constraint Description:

All CCO classes must have a superclass in BFO.

Severity:

Error

PREFIX owl: http://www.w3.org/2002/07/owl#
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#

SELECT DISTINCT ?class ?label
WHERE {
?class a owl:Class .
FILTER contains(str(?class),"http://www.ontologyrepository.com/CommonCoreOntologies/")
FILTER NOT EXISTS {?class rdfs:subClassOf+ http://purl.obolibrary.org/obo/BFO_0000001 }
OPTIONAL {?class rdfs:label ?label}
}
`

@swartik
Copy link
Copy Markdown
Contributor

swartik commented Sep 9, 2024

@neilotte

The query I proposed addressed a specific bug in a CCO version. The alternative you propose is both more general (it addresses other potential problems) and more precise (it restricts itself to CCO). It will also detect class hierarchy errors in BFO releases, which is good.

The software engineer in me likes to isolate literals. I advise adding the prefix declaration:

PREFIX cco: <http://www.ontologyrepository.com/CommonCoreOntologies/>

and changing the first filter to:

FILTER contains(str(?class), str(cco:))

Function strstarts would be more accurate than contains – but some SPARQL engines don't implement strstarts. The engine Protege v5.5 uses is one of them.

…perclass

This is a query designed by @neilotte after an issue originally raised by @swartik .
@neilotte neilotte merged commit 4d6568e into develop Sep 11, 2024
@johnbeve johnbeve deleted the 448-new-query branch September 13, 2024 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants