sparql-examples

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

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

55_Number_of_compounds_according_to_their_category

rq turtle/ttl

Number of compounds according to their category (Small molecule, Generic compound, Polymer)

Use at

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh: <http://rdf.rhea-db.org/>

SELECT 
  ?compoundCategory 
  ?compoundCategoryLabel?genericCategory
WHERE
{
  VALUES (?compoundCategory) {(rh:GenericCompound) (rh:Polymer) (rh:SmallMolecule)}
  ?compoundCategory rdfs:subClassOf rh:Compound .
  ?compoundCategory rdfs:label ?compoundCategoryLabel .
}
ORDER BY ?genericCategory DESC(?compound)

graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v2("?compound")
  v3("?compoundCategory"):::projected 
  v4("?compoundCategoryLabel"):::projected 
  v1("?genericCategory"):::projected 
  c2(["rh:Compound"]):::iri 
  bind0[/VALUES ?compoundCategory/]
  bind0-->v3
  bind00(["rh:GenericCompound"])
  bind00 --> bind0
  bind01(["rh:Polymer"])
  bind01 --> bind0
  bind02(["rh:SmallMolecule"])
  bind02 --> bind0
  v3 --"rdfs:subClassOf"-->  c2
  v3 --"rdfs:label"-->  v4