sparql-examples

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

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

005

rq turtle/ttl

List all diseases and the number of pathways they are linked to, in decreasing order.

Use at

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

SELECT ?diseaseLabel ?disease (COUNT(DISTINCT ?pathway) AS ?count)
WHERE {
  ?pathway wp:diseaseOntologyTag ?disease ; 
           a wp:Pathway .
  ?disease rdfs:label ?diseaseLabel .
} GROUP BY ?diseaseLabel ?disease
  ORDER BY DESC(?count)
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v5("?count")
  v3("?disease"):::projected 
  v4("?diseaseLabel"):::projected 
  v2("?pathway"):::projected 
  c3(["wp:Pathway"]):::iri 
  v2 --"wp:diseaseOntologyTag"-->  v3
  v2 --"a"-->  c3
  v3 --"rdfs:label"-->  v4
  bind1[/"count(?pathway)"/]
  v2 --o bind1
  bind1 --as--o v5