sparql-examples

A set of SPARQL examples that are used in different SIB resources

View the Project on GitHub sib-swiss/sparql-examples

Query_168

rq turtle/ttl

Super class and equivalent class of each class defined in the cello ontology

Use at


PREFIX cello: <https://purl.expasy.org/cellosaurus/rdf/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
select ?cello_class ?hasSuperClass ?rdfs_superClass ?hasEqClass ?owl_equivalentClass  where {
  ?cello_class a owl:Class .
  ?cello_class rdfs:isDefinedBy cello: .
  optional { ?cello_class owl:equivalentClass ?owl_equivalentClass . }
  optional { ?cello_class rdfs:subClassOf ?rdfs_superClass . }
  bind(if(bound(?owl_equivalentClass),"yes", "no") as ?hasEqClass)
  bind(if(bound(?rdfs_superClass),"yes", "no") as ?hasSuperClass)
}
order by ?rdfs_superClass ?owl_equivalentClass ?parent ?cello_class
    
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v4("?cello_class"):::projected 
  v5("?hasEqClass"):::projected 
  v6("?hasSuperClass"):::projected 
  v2("?owl_equivalentClass"):::projected 
  v3("?parent")
  v1("?rdfs_superClass"):::projected 
  c4(["cello:"]):::iri 
  c2(["owl:Class"]):::iri 
  v4 --"a"-->  c2
  v4 --"rdfs:isDefinedBy"-->  c4
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v4 -."owl:equivalentClass".->  v2
  end
  subgraph optional1["(optional)"]
  style optional1 fill:#bbf,stroke-dasharray: 5 5;
    v4 -."rdfs:subClassOf".->  v1
  end
  bind0[/"if(bound(?owl_equivalentClass),'yes','no')"/]
  v2 --o bind0
  bind0 --as--o v5
  bind1[/"if(bound(?rdfs_superClass),'yes','no')"/]
  v1 --o bind1
  bind1 --as--o v6