Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPARQL queries #3

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
0713ddc
Create aristotelian_definition_level3.sparql
giacomodecolle Sep 28, 2024
01d9fd5
Update aristotelian_definition_level3.sparql
giacomodecolle Sep 28, 2024
b00dfa5
Update aristotelian_definition_level3.sparql
giacomodecolle Sep 28, 2024
1d37d30
Update aristotelian_definition_level3.sparql
giacomodecolle Sep 28, 2024
10eedfb
Create multiple_inheritance_l5.sparql
giacomodecolle Sep 28, 2024
4cef487
Create no_superclass_level5
giacomodecolle Sep 28, 2024
1ef382b
Create inverse_property_lev4.sparql
giacomodecolle Sep 28, 2024
0d7f25b
Create untyped_properties.sparql
giacomodecolle Oct 2, 2024
784558f
Create OBO.sparql
giacomodecolle Oct 2, 2024
f0e2862
Updating difficulty level
giacomodecolle Oct 2, 2024
cfbd208
Reverting difficulty level
giacomodecolle Oct 2, 2024
b8ed88c
Changing difficulty again
giacomodecolle Oct 2, 2024
3bc75a0
Create realizations_lv6
giacomodecolle Oct 2, 2024
793ec4d
Update realizations_lv6
giacomodecolle Oct 2, 2024
56dc318
Create SDCs_lev6
giacomodecolle Oct 2, 2024
5294a40
Create GDC_lv6.sparql
giacomodecolle Oct 2, 2024
aaad274
Adding extension
giacomodecolle Oct 2, 2024
b96222c
Adding extension
giacomodecolle Oct 2, 2024
e45ef5c
Create to_check_ICE_lv3
giacomodecolle Oct 3, 2024
a9223ac
Update and rename GDC_lv6.sparql to to_check_GDC_lv6.sparql
giacomodecolle Oct 3, 2024
6cb49d1
Update and rename SDCs_lev6.sparql to to_check_SDCs_lev6.sparql
giacomodecolle Oct 3, 2024
6bebb68
Create process_boundary?lev4.sparql
giacomodecolle Oct 3, 2024
c2eb0e6
Rename process_boundary?lev4.sparql to process_boundary_lev4.sparql
giacomodecolle Oct 3, 2024
1122e50
Create second_process_boundary_lv4
giacomodecolle Oct 3, 2024
f50cb1d
Create no_subclass_lv0.sparql
giacomodecolle Oct 3, 2024
48228f0
Changing label optionality
giacomodecolle Oct 3, 2024
e397494
Fixed a typo
giacomodecolle Oct 8, 2024
908a26c
Adding error message
giacomodecolle Oct 8, 2024
839ab9c
Update aristotelian_definition_level3.sparql
giacomodecolle Oct 8, 2024
090c330
Added blanknode exceptions
giacomodecolle Oct 8, 2024
3884973
Update no_subclass_lv0.sparql
giacomodecolle Oct 8, 2024
fba04dd
editing extension
giacomodecolle Oct 8, 2024
88df7d4
Update process_boundary_lev4.sparql
giacomodecolle Oct 8, 2024
33d8a66
name change
giacomodecolle Oct 8, 2024
4805f94
Updated to axioms version
giacomodecolle Oct 9, 2024
3fcfcd6
Update and rename second_process_boundary_lv4 to second_process_bound…
giacomodecolle Oct 9, 2024
8943a65
Fixed axioms
giacomodecolle Oct 9, 2024
33a30da
adding axioms
giacomodecolle Oct 9, 2024
1c4f3d8
adding blank nodes
giacomodecolle Oct 9, 2024
61cc30e
adding blank nodes
giacomodecolle Oct 9, 2024
83f514b
adding axioms
giacomodecolle Oct 9, 2024
4e30b5a
Now it should run
giacomodecolle Oct 9, 2024
7fb486b
Create review.md
giacomodecolle Oct 10, 2024
dca0b76
Adding review version of sparql queries
giacomodecolle Oct 10, 2024
185330d
Update to_check_ICE_lv3.sparql
giacomodecolle Oct 10, 2024
26fe34a
Update multiple_inheritance_l5.sparql
giacomodecolle Oct 10, 2024
a6eb670
Update SDCs_lev6.sparql
giacomodecolle Oct 10, 2024
9888dc3
Update GDC_lv6.sparql
giacomodecolle Oct 10, 2024
85c136e
Update and rename OBO.sparql to OBO_lev6.sparql
giacomodecolle Oct 10, 2024
74e68a5
Update and rename no_subclass_lv0.sparql to no_subclass_lv8.sparql
giacomodecolle Oct 10, 2024
4e24c08
changing level
giacomodecolle Oct 10, 2024
6d24828
Changing level
giacomodecolle Oct 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions projects/project-2/assignment/GDC_lv6.sparql
giacomodecolle marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# checking whether all GDCs are generically depending on something
#There is probably a conceptual mistake here, since this should be axioms and not direct connections between classes
# lv 6


PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX obo: <http://purl.obolibrary.org/obo/>

SELECT ?GDC (CONCAT("Warning: Generically Dependent Entity ", STR(?label), " doesn't generically depend on some entity.") AS ?warningMessage)
WHERE {
#get all the subclasses of GDC
?GDC rdfs:subClassOf+ obo:BFO_0000031 .
?GDC rdfs:label ?label .
FILTER (!ISBLANK(?GDC)) .

# check whether it doesn't generically depend on something
FILTER NOT EXISTS {
?GDC rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:onProperty obo:BFO_0000084 ;
owl:someValuesFrom ?targetClass
].
}
}
28 changes: 28 additions & 0 deletions projects/project-2/assignment/OBO.sparql
giacomodecolle marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Checks that no common OBO Foundry properties are used
# Level 5

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX obo: <http://purl.obolibrary.org/obo/>

SELECT DISTINCT ?subject ?predicate ?object
WHERE {
?subject ?predicate ?object .

FILTER (?predicate = obo:IAO_0000115 ||
?predicate = obo:IAO_0000119 ||
?predicate = obo:IAO_0000116 ||
?predicate = obo:IAO_0000111 ||
?predicate = obo:IAO_0000600 ||
?predicate = obo:IAO_0010000 ||
?predicate = obo:IAO_0000601 ||
?predicate = obo:IAO_0000602 ||
?predicate = obo:IAO_0000232
)

OPTIONAL {
?predicate rdfs:label ?label .
}
BIND (CONCAT("Error: Property ", STR(?predicate), " is an OBO property.") AS ?errorMessage)

}
24 changes: 24 additions & 0 deletions projects/project-2/assignment/SDCs_lev6.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Checking whether all SDCs are depending on some entity
#There is probably a conceptual mistake here, since this should be axioms and not direct connections between classes
# lev 6

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX obo: <http://purl.obolibrary.org/obo/>

SELECT ?SDC (CONCAT("Warning: Specifically Dependent Entity ", STR(?label), " doesn't specifically depend on some entity.") AS ?warningMessage)
WHERE {
?SDC rdfs:subClassOf+ obo:BFO_0000020 .
FILTER (!ISBLANK(?SDC)) .

FILTER NOT EXISTS {
?subclass rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:onProperty obo:BFO_0000195 ;
owl:someValuesFrom ?targetClass
].
}
OPTIONAL {
?SDC rdfs:label ?label .
}
}
giacomodecolle marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

# Find subjects with definitions
# Get the parent class of the subject
# Get the label of the parent class
# Get the label of the subject
# Check whether the name of the parent class label appears in the definition, followed by that, who, where or inhering.
# Suggested difficulty is level 3 (20 points)

PREFIX cco: <http://www.ontologyrepository.com/CommonCoreOntologies/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?subject ?parentClass ?definition ?subjectLabel ?error
WHERE {
?subject cco:definition ?definition .
?subject rdfs:subClassOf ?parentClass .
?parentClass rdfs:label ?parentClassLabel .
?subject rdfs:label ?subjectLabel .

# Ensure subject is not blank
FILTER (!ISBLANK(?subject)) .

# Filter for non-Aristotelian definitions (that don't match the parent class label patterns)
FILTER NOT EXISTS {
FILTER(REGEX(LCASE(STR(?definition)), CONCAT(LCASE(STR(?parentClassLabel)), " (that|who|where|inhering)")))
} .

# Create the error message
BIND (concat("WARNING: Possible non-Aristotelian definition format for the following definition: ", str(?definition)) AS ?error)
}
27 changes: 27 additions & 0 deletions projects/project-2/assignment/inverse_property_lev4.sparql
giacomodecolle marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Checking whether the object property has an inverse property or is the inverse property of a property.
# This assumes we want to have inverses for all object properties
# Level 4

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

SELECT ?property ?propertyLabel ?error
WHERE {
# Find all object properties
?property a owl:ObjectProperty .

# Check if the property does NOT have an inverse or is not the inverse of something else
FILTER (!ISBLANK (?property)) .
FILTER NOT EXISTS {
?inverseproperty owl:inverseOf ?property .
}
FILTER NOT EXISTS {
?property owl:inverseOf ?inverseproperty .
}
# Optional: get the label of the property

?property rdfs:label ?propertyLabel .

FILTER regex(str(?property), "http://www.ontologyrepository.com/CommonCoreOntologies/")
BIND (concat("ERROR: There is no inverse property for the CCO property: ", str(?class)) AS ?error)
}
21 changes: 21 additions & 0 deletions projects/project-2/assignment/multiple_inheritance_l5.sparql
giacomodecolle marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#Check whether a class has more than on parent class
#suggested difficulty level 5 (5 points)

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?subject ?error
WHERE {
?subject rdfs:subClassOf ?parentClass .

# Ensure that the subject is not blank
FILTER (!ISBLANK(?subject)) .
FILTER (!ISBLANK(?parentClass)) .

# Filter for classes within the CCO namespace
FILTER regex(str(?subject), "http://www.ontologyrepository.com/CommonCoreOntologies/")

# Create an error message
BIND (concat("ERROR: Class ", str(?subject), " has multiple parent classes: ", str(?parentClass)) AS ?error)
}
GROUP BY ?subject
HAVING (COUNT(?parentClass) > 1)
21 changes: 21 additions & 0 deletions projects/project-2/assignment/no_subclass_lv0.sparql
giacomodecolle marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#checking that classes are not subclasses of themselves
# lv0

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

SELECT ?class ?warningMessage
WHERE {
# Find all entities that have an axiom connecting them through BFO_0000199 to a subclass of BFO_0000148
?classEntity a owl:Class

FILTER (!ISBLANK(?classEntity)) .

?classEntity rdfs:subClassOf ?classEntity.

# Create a warning message
?classEntity rdfs:label ?label .

BIND (CONCAT("Warning: Class ", STR(?label), " is a subclass of itself") AS ?warningMessage)
}
22 changes: 22 additions & 0 deletions projects/project-2/assignment/no_superclass_level5.sparql

Choose a reason for hiding this comment

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

this seems pretty useful even outside CCO queries, at least for NCOR members. The level is apt.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# checks if there are classes outside the BFO hierarchy
#difficulty level 5 (5 points)

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX obo: <http://purl.obolibrary.org/obo/>

SELECT ?class ?label ?error
WHERE {
# Find all classes in the ontology
?class a owl:Class .
FILTER(?class != obo:BFO_0000001)
FILTER NOT EXISTS {
?class rdfs:subClassOf ?superclass .
}
OPTIONAL {
?class rdfs:label ?label .
}
FILTER (!ISBLANK (?class)) .
FILTER regex(str(?class), "http://www.ontologyrepository.com/CommonCoreOntologies/")
BIND (concat("ERROR: There is a class which is not in the BFO hierarchy ", str(?class)) AS ?error)
}
31 changes: 31 additions & 0 deletions projects/project-2/assignment/process_boundary_lev4.sparql

Choose a reason for hiding this comment

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

this is more like a lever 3, with the + and * operator on classes.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#checks whether subclasses of process boundary are connected to a zero-dimensional temporal region
#lev 4


PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX obo: <http://purl.obolibrary.org/obo/>

SELECT ?entity ?warningMessage
WHERE {
# Find all classes or subclasses of BFO_0000035
?entity rdfs:subClassOf+ obo:BFO_0000035 .

# Ensure the target class is a subclass of zero-dimensional temporal region
?targetClass rdfs:subClassOf* obo:BFO_0000148 .

# Check if they do NOT have the axiom connecting them through "occupies temporal region" to a subclass of zero-dimensional temporal region
FILTER NOT EXISTS {
?entity rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:onProperty obo:BFO_0000199 ;
owl:someValuesFrom ?targetClass
] .
}

# Create a warning message
OPTIONAL {
?entity rdfs:label ?label .
}
BIND(CONCAT("Warning: Class ", STR(COALESCE(?label, ?entity)), " is a process boundary but doesn't have occupy a zero-dimensional temporal region.") AS ?warningMessage)
}
22 changes: 22 additions & 0 deletions projects/project-2/assignment/realizations_lv6.sparql
giacomodecolle marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This checks whether all the realizable entities are connected to a process through "has realization"
# Level 6

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX obo: <http://purl.obolibrary.org/obo/>

SELECT ?subclass (CONCAT("Error: Realizable entity ", STR(?label), " doesn't have a process realizing it.") AS ?errorMessage)
WHERE {
?subclass rdfs:subClassOf+ obo:BFO_0000017 .
?subclass rdfs:label ?label.
FILTER (!ISBLANK(?subclass)) .

FILTER NOT EXISTS {
?subclass rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:onProperty obo:BFO_0000054 ;
owl:someValuesFrom ?targetClass
].
}
}
24 changes: 24 additions & 0 deletions projects/project-2/assignment/reviewers/GDC_lv6.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# checking whether all GDCs are generically depending on something

Choose a reason for hiding this comment

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

It seems to me that your queries are much more complex than mine and the others I have reviewed, we may have to see how to adjust the complexity levels.
I have left comments where protege gives me an error in the execution.
The only thing I would consider is whether to add a short description of the functionality to each one (at least it seemed to me that the assignment required title + description)

#There is probably a conceptual mistake here, since this should be axioms and not direct connections between classes
# lv 6


PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX obo: <http://purl.obolibrary.org/obo/>

SELECT ?GDC (CONCAT("Warning: Generically Dependent Entity ", STR(?label), " doesn't generically depend on some entity.") AS ?warningMessage)
WHERE {
#get all the subclasses of GDC
?GDC rdfs:subClassOf+ obo:BFO_0000031 .
?GDC rdfs:label ?label .
FILTER (!ISBLANK(?GDC)) .

# check whether it doesn't generically depend on something
FILTER NOT EXISTS {
?GDC rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:onProperty obo:BFO_0000084 ;
owl:someValuesFrom ?targetClass
].
}
giacomodecolle marked this conversation as resolved.
Show resolved Hide resolved
28 changes: 28 additions & 0 deletions projects/project-2/assignment/reviewers/OBO.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Checks that no common OBO Foundry properties are used
# Level 5

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX obo: <http://purl.obolibrary.org/obo/>

SELECT DISTINCT ?subject ?predicate ?object
WHERE {
?subject ?predicate ?object .

FILTER (?predicate = obo:IAO_0000115 ||
?predicate = obo:IAO_0000119 ||
?predicate = obo:IAO_0000116 ||
?predicate = obo:IAO_0000111 ||
?predicate = obo:IAO_0000600 ||
?predicate = obo:IAO_0010000 ||
?predicate = obo:IAO_0000601 ||
?predicate = obo:IAO_0000602 ||
?predicate = obo:IAO_0000232
)

OPTIONAL {
?predicate rdfs:label ?label .
}
BIND (CONCAT("Error: Property ", STR(?predicate), " is an OBO property.") AS ?errorMessage)

}
24 changes: 24 additions & 0 deletions projects/project-2/assignment/reviewers/SDCs_lev6.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Checking whether all SDCs are depending on some entity
#There is probably a conceptual mistake here, since this should be axioms and not direct connections between classes
# lev 6

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX obo: <http://purl.obolibrary.org/obo/>

SELECT ?SDC (CONCAT("Warning: Specifically Dependent Entity ", STR(?label), " doesn't specifically depend on some entity.") AS ?warningMessage)
WHERE {
?SDC rdfs:subClassOf+ obo:BFO_0000020 .
FILTER (!ISBLANK(?SDC)) .

FILTER NOT EXISTS {
?subclass rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:onProperty obo:BFO_0000195 ;
owl:someValuesFrom ?targetClass
].

OPTIONAL {
?SDC rdfs:label ?label .
}
}
giacomodecolle marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

# Find subjects with definitions
# Get the parent class of the subject
# Get the label of the parent class
# Get the label of the subject
# Check whether the name of the parent class label appears in the definition, followed by that, who, where or inhering.
# Suggested difficulty is level 3 (20 points)

PREFIX cco: <http://www.ontologyrepository.com/CommonCoreOntologies/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?subject ?parentClass ?definition ?subjectLabel ?error
WHERE {
?subject cco:definition ?definition .
?subject rdfs:subClassOf ?parentClass .
?parentClass rdfs:label ?parentClassLabel .
?subject rdfs:label ?subjectLabel .

# Ensure subject is not blank
FILTER (!ISBLANK(?subject)) .

# Filter for non-Aristotelian definitions (that don't match the parent class label patterns)
FILTER NOT EXISTS {
FILTER(REGEX(LCASE(STR(?definition)), CONCAT(LCASE(STR(?parentClassLabel)), " (that|who|where|inhering)")))
} .

# Create the error message
BIND (concat("WARNING: Possible non-Aristotelian definition format for the following definition: ", str(?definition)) AS ?error)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Checking whether the object property has an inverse property or is the inverse property of a property.
# This assumes we want to have inverses for all object properties
# Level 4

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

SELECT ?property ?propertyLabel ?error
WHERE {
# Find all object properties
?property a owl:ObjectProperty .

# Check if the property does NOT have an inverse or is not the inverse of something else
FILTER (!ISBLANK (?property)) .
FILTER NOT EXISTS {
?inverseproperty owl:inverseOf ?property .
}
FILTER NOT EXISTS {
?property owl:inverseOf ?inverseproperty .
}
# Optional: get the label of the property

?property rdfs:label ?propertyLabel .

FILTER regex(str(?property), "http://www.ontologyrepository.com/CommonCoreOntologies/")
BIND (concat("ERROR: There is no inverse property for the CCO property: ", str(?class)) AS ?error)
}
Loading