sparql-examples

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

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

49

Retrieve the UniProtKB proteins, their catalyzed Rhea reactions, their encoding genes (Ensembl) and the anatomic entities where the genes are expressed (UBERON anatomic entites from Bgee expression data resource).

Use at

PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_>
PREFIX genex: <http://purl.org/genex#>
PREFIX lscr: <http://purl.org/lscr#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX up: <http://purl.uniprot.org/core/>

SELECT DISTINCT ?protein ?ensemblGene ?reaction ?anatomicEntityLabel ?anatomicEntity
WHERE {
  # federated query to Rhea enadpoint
  {
    SELECT DISTINCT ?reaction WHERE {
      SERVICE <https://sparql.rhea-db.org/sparql> {
        ?reaction rdfs:subClassOf rh:Reaction ;
          rh:equation ?reactionEquation ;
          rh:side ?reactionSide .
        ?reactionSide rh:contains ?participant .
        ?participant rh:compound ?compound .
        # compound constraint (CHEBI:16113 == cholesterol)
        ?compound rh:chebi CHEBI:16113 .
      }
    }
  }
  # taxonomy constraint (taxon:9606 == Homo sapiens)
  ?protein up:organism taxon:9606 ;
    up:annotation ?a ;
    rdfs:seeAlso / up:transcribedFrom ?ensemblGene .
  ?a a up:Catalytic_Activity_Annotation ;
    up:catalyticActivity ?ca .
  ?ca up:catalyzedReaction ?reaction .
  # federated query to Bgee (expression data)
  BIND(IRI(REPLACE(STR(?ensemblGene), "\\.[0-9]+$", "")) AS ?ensemblGeneNoVersion)
  SERVICE <https://www.bgee.org/sparql> {
    ?gene lscr:xrefEnsemblGene ?ensemblGeneNoVersion ;
      genex:isExpressedIn ?anatomicEntity .
    ?anatomicEntity rdfs:label ?anatomicEntityLabel .
  }
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v7("?a")
  v12("?anatomicEntity"):::projected 
  v13("?anatomicEntityLabel"):::projected 
  v9("?ca")
  v5("?compound")
  v8("?ensemblGene"):::projected 
  v10("?ensemblGeneNoVersion")
  v11("?gene")
  v4("?participant")
  v6("?protein"):::projected 
  v1("?reaction"):::projected 
  v2("?reactionEquation")
  v3("?reactionSide")
  a1((" "))
  c11(["taxon:9606"]):::iri 
  c9(["CHEBI:16113"]):::iri 
  c3(["rh:Reaction"]):::iri 
  c16(["up:Catalytic_Activity_Annotation"]):::iri 
  subgraph s1["https://sparql.rhea-db.org/sparql"]
    style s1 stroke-width:4px;
    v1 --"rdfs:subClassOf"-->  c3
    v1 --"rh:equation"-->  v2
    v1 --"rh:side"-->  v3
    v3 --"rh:contains"-->  v4
    v4 --"rh:compound"-->  v5
    v5 --"rh:chebi"-->  c9
  end
  v6 --"up:organism"-->  c11
  v6 --"up:annotation"-->  v7
  v6 --"rdfs:seeAlso"-->  a1
  a1 --"up:transcribedFrom"-->  v8
  v7 --"a"-->  c16
  v7 --"up:catalyticActivity"-->  v9
  v9 --"up:catalyzedReaction"-->  v1
  bind0[/"replace(str(?ensemblGene),'\.#91;0-9#93;+$','')"/]
  v8 --o bind0
  bind0 --as--o v10
  subgraph s2["https://www.bgee.org/sparql"]
    style s2 stroke-width:4px;
    v11 --"lscr:xrefEnsemblGene"-->  v10
    v11 --"genex:isExpressedIn"-->  v12
    v12 --"rdfs:label"-->  v13
  end