sparql-examples

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

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

016

rq turtle/ttl

Counts the number of distinct entities linked to each external database (ChEBI, ChemSpider, HMDB, PubChem, Ensembl, NCBI Gene, HGNC, Rhea, UniProt).

Use at

PREFIX wp: <http://vocabularies.wikipathways.org/wp#>

SELECT ?pred (COUNT(DISTINCT ?entity) AS ?count) WHERE {
  VALUES ?pred {
    # metabolites
    wp:bdbChEBI wp:bdbChemspider wp:bdbHmdb wp:bdbPubChem
    # gene products
    wp:bdbEnsembl wp:bdbEntrezGene wp:bdbHgncSymbol
    # interactions
    wp:bdbRhea wp:bdbUniprot
  }
  ?entity ?pred []
} GROUP BY ?pred
  ORDER BY DESC(?count)
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v4("?count")
  v3("?entity"):::projected 
  v2("?pred"):::projected 
  a1((" "))
  bind0[/VALUES ?pred/]
  bind0-->v2
  bind00(["wp:bdbChEBI"])
  bind00 --> bind0
  bind01(["wp:bdbChemspider"])
  bind01 --> bind0
  bind02(["wp:bdbHmdb"])
  bind02 --> bind0
  bind03(["wp:bdbPubChem"])
  bind03 --> bind0
  bind04(["wp:bdbEnsembl"])
  bind04 --> bind0
  bind05(["wp:bdbEntrezGene"])
  bind05 --> bind0
  bind06(["wp:bdbHgncSymbol"])
  bind06 --> bind0
  bind07(["wp:bdbRhea"])
  bind07 --> bind0
  bind08(["wp:bdbUniprot"])
  bind08 --> bind0
  v3 -->v2--> a1
  bind2[/"count(?entity)"/]
  v3 --o bind2
  bind2 --as--o v4