sparql-examples

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

View the Project on GitHub BiGCAT-UM/sparql-examples

021

rq turtle/ttl

Counts the total number of pathways classified under metabolic pathway ontology terms.

Use at

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

SELECT (count(distinct ?pathway) as ?pathwaycount)
WHERE {
  ?tag1 a owl:Class ;
  rdfs:label ?label .
  ?tag rdfs:subClassOf* ?tag1.
  ?pathway a wp:Pathway; wp:ontologyTag ?tag.
FILTER regex(str(?label), "metabolic pathway")
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v1("?label")
  v4("?pathway"):::projected 
  v5("?pathwaycount")
  v3("?tag")
  v2("?tag1")
  c6(["wp:Pathway"]):::iri 
  c3(["owl:Class"]):::iri 
  f0[["regex(str(?label),'metabolic pathway')"]]
  f0 --> v1
  v2 --"a"-->  c3
  v2 --"rdfs:label"-->  v1
  v3 --"rdfs:subClassOf"-->  v2
  v4 --"a"-->  c6
  v4 --"wp:ontologyTag"-->  v3
  bind2[/"count(?pathway)"/]
  v4 --o bind2
  bind2 --as--o v5