180_subcellular_location_ancestors
- subcellular location
- hierarchy
Find every broader subcellular location reachable from a given one (here, Endosome membrane, locations:100). The location hierarchy mixes rdfs:subClassOf (is-a) and up:partOf (part-of) edges, so both have to be chained together - rdfs:subClassOf*/up:partOf+/rdfs:subClassOf* - to reach the full set of ancestors; using only one of the two misses e.g. Endosome (is-a) or Membrane (part-of, then is-a)
Use at
PREFIX up: <http://purl.uniprot.org/core/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT
DISTINCT
?ancestor
?ancestorName
WHERE {
GRAPH <http://sparql.uniprot.org/locations> {
<http://purl.uniprot.org/locations/100> rdfs:subClassOf*/up:partOf+/rdfs:subClassOf* ?ancestor .
?ancestor skos:prefLabel ?ancestorName .
}
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?ancestor"):::projected
v2("?ancestorName"):::projected
a1((" "))
a2((" "))
c1([http://purl.uniprot.org/locations/100]):::iri
c1 --"rdfs:subClassOf"--> a1
a1 --"up:partOf"--> a2
a2 --"rdfs:subClassOf"--> v1
v1 --"skos:prefLabel"--> v2