Last active
September 3, 2021 16:08
-
-
Save balhoff/9792489 to your computer and use it in GitHub Desktop.
Retrieve the nearest common ancestors for two terms using SPARQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | |
PREFIX Term1: <http://purl.obolibrary.org/obo/PATO_0000587> | |
PREFIX Term2: <http://purl.obolibrary.org/obo/PATO_0000586> | |
SELECT ?nearest | |
FROM <http://purl.obolibrary.org/obo/pato.owl> | |
WHERE { | |
Term1: rdfs:subClassOf* ?nearest . | |
Term2: rdfs:subClassOf* ?nearest . | |
Term1: rdfs:subClassOf* ?indirect . | |
Term2: rdfs:subClassOf* ?indirect . | |
?indirect rdfs:subClassOf* ?nearest . | |
} | |
GROUP BY ?nearest | |
HAVING(COUNT(DISTINCT ?indirect) = 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment