SPARQL example query
16: Select all Rhea reactions that have a pair of ChEBI IDs as reaction participant and in opposite side
PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_> PREFIX rh: <http://rdf.rhea-db.org/> PREFIX up: <http://purl.uniprot.org/core/> # Query 16 # Select all Rhea reactions that have a pair of ChEBI IDs as reaction participant and in opposite side # Return Rhea reactions that have CHEBI:29985 (L-glutamate) as reaction participant in one side # and CHEBI:58359 (L-glutamine) in the other side # # This query cannot be expressed in the Rhea website SELECT ?chebi1 ?name1 ?chebi2 ?name2 ?rhea ?equation WHERE { VALUES (?chebi1) { (CHEBI:29985) } ?chebi1 up:name ?name1 . ?rhea rh:side ?reactionSide1 . ?reactionSide1 rh:contains / rh:compound / rh:chebi ?chebi1 . VALUES (?chebi2) { (CHEBI:58359) } ?chebi2 up:name ?name2 . ?rhea rh:side ?reactionSide2 . ?reactionSide2 rh:contains / rh:compound / rh:chebi ?chebi2 . ?reactionSide1 rh:transformableTo ?reactionSide2 . ?rhea rh:equation ?equation . }Use17: Select all Rhea reactions that involve a lipid, i.e. children of CHEBI:18059 in the ChEBI hierarchy.
PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_> PREFIX chebihash: <http://purl.obolibrary.org/obo/chebi#> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh: <http://rdf.rhea-db.org/> PREFIX up: <http://purl.uniprot.org/core/> # Query 17 # Select all Rhea reactions that involve a lipid, i.e. children of CHEBI:18059 in the ChEBI hierarchy. # # This query corresponds to the Rhea website query: # https://www.rhea-db.org/rhea?query=chebi:18059 # SELECT distinct ?chebi ?name ?rhea ?equation WHERE { ?rhea rdfs:subClassOf rh:Reaction . ?rhea rh:equation ?equation . ?rhea rh:side/rh:contains/rh:compound ?compound . # # the ChEBI can be used either as a small molecule, the reactive part of a macromolecule or as a polymer. # { ?chebi rdfs:subClassOf* CHEBI:18059 . # lipid ?compound (rh:chebi|(rh:reactivePart/rh:chebi)|(rh:underlyingChebi/rh:chebi)) ?chebi . } UNION { # add non-pH 7.3 species ?not7_3 rdfs:subClassOf* CHEBI:18059 . # lipid ?not7_3 rdfs:subClassOf ?chebiRestriction . ?chebiRestriction a owl:Restriction . ?chebiRestriction owl:onProperty chebihash:has_major_microspecies_at_pH_7_3 . ?chebiRestriction owl:someValuesFrom ?chebi . ?compound (rh:chebi|(rh:reactivePart/rh:chebi)|(rh:underlyingChebi/rh:chebi)) ?chebi . } ?chebi up:name ?name . }Use18: Use IDSM Sachem to find ChEBIs with a a Cholestane skeleton (in SMILES). Then match returned ChEBIs to Rhea undirected reactions.
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh: <http://rdf.rhea-db.org/> PREFIX sachem: <http://bioinfo.uochb.cas.cz/rdf/v1.0/sachem#> SELECT ?rhea ?chebi WHERE { SERVICE <https://idsm.elixir-czech.cz/sparql/endpoint/chebi> { ?chebi sachem:substructureSearch [ sachem:query "[C@]12(CCC3CCCC[C@]3(C)[C@@]1([H])CC[C@]1(C)[C@@]([H])([C@@](C)([H])CCCC(C)C)CC[C@@]21[H])[H]" ]. } ?rhea rh:side/rh:contains/rh:compound/rdfs:subClassOf ?chebi . }Use100_Get_the_number_of_ChEBI_participant_with_at_least_one_xref_to_CAS_number_as_provided_by_ChEBI: Get the number of ChEBI participant with at least one xref to CAS number as provided by ChEBI
PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX allie: <http://allie.dbcls.jp/> PREFIX GO: <http://purl.obolibrary.org/obo/GO_> PREFIX rh:<http://rdf.rhea-db.org/> PREFIX CHEBI:<http://purl.obolibrary.org/obo/CHEBI_> PREFIX chebihash:<http://purl.obolibrary.org/obo/chebi#> PREFIX oboInOwl:<http://www.geneontology.org/formats/oboInOwl#> SELECT (count(distinct ?chebi) as ?chebiCount) (count(distinct ?dbXref) as ?xrefCount) WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . ?reaction rh:side ?reactionSide . ?reactionSide rh:contains ?participant . ?participant rh:compound ?compound . { ?compound rh:chebi ?chebi . ?chebi oboInOwl:hasDbXref ?dbXref . FILTER (regex(?dbXref,'^CAS:')) } UNION { ?compound rh:chebi ?chebi . ?chebi2 rdfs:subClassOf ?chebiRestriction . ?chebiRestriction a owl:Restriction . ?chebiRestriction owl:onProperty chebihash:has_major_microspecies_at_pH_7_3 . ?chebiRestriction owl:someValuesFrom ?chebi . ?chebi2 oboInOwl:hasDbXref ?dbXref . FILTER (regex(?dbXref,'^CAS:')) } }Use101_Pairs_of_reaction_participants_that_belong_to_the_same_reaction_but_on_distinct_sides_and_number_of_reactions_in_which_they_occur: Pairs of reaction participants that belong to the same reaction but on distinct sides and number of reactions in which they occur
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh:<http://rdf.rhea-db.org/> SELECT ?chebi1 ?compound1Name ?chebi2 ?compound2Name (count(distinct ?reaction) as ?reactionCount) WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . ?reaction rh:side ?reactionSide1 . ?reactionSide1 rh:contains ?participant1 . ?participant1 rh:compound ?compound1 . ?compound1 rh:name ?compound1Name . ?compound1 rh:chebi ?chebi1 . ?reaction rh:side ?reactionSide2 . ?reactionSide2 rh:contains ?participant2 . ?participant2 rh:compound ?compound2 . ?compound2 rh:name ?compound2Name . ?compound2 rh:chebi ?chebi2 . ?reactionSide1 rh:transformableTo ?reactionSide2 FILTER(?chebi1<?chebi2) } GROUP BY ?chebi1 ?chebi2 ?compound1Name ?compound2Name ORDER BY DESC (?reactionCount) LIMIT 100Use103_Select_all_approved_reactions_linked_to_a_given_EC_number: Select all approved reactions linked to a given EC number (EC 1.1.1.353)
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh:<http://rdf.rhea-db.org/> PREFIX ec:<http://purl.uniprot.org/enzyme/> SELECT ?reaction ?reactionEquation WHERE { BIND(ec:1.1.1.353 AS ?ecNumber) ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . ?reaction rh:equation ?reactionEquation . ?reaction rh:ec ?ecNumber } ORDER BY ?reactionUse104_Select_the_number_of_reactions_linked_to_EC_numbers: Select the number of reactions linked to EC numbers
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh:<http://rdf.rhea-db.org/> SELECT (count(?reaction) as ?reactionCount) WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:ec ?ecNumber }Use105_Select_all_reactions_linked_to_EC_numbers: Select all reactions linked to EC numbers
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh:<http://rdf.rhea-db.org/> SELECT ?reaction ?ecNumber WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:ec ?ecNumber } ORDER BY ?reactionUse106_Select_all_reactions_linked_to_more_than_one_EC_number: Select all reactions linked to more than one EC number
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh:<http://rdf.rhea-db.org/> SELECT ?reaction (count(?ecNumber) as ?ecCount) WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:ec ?ecNumber } GROUP BY ?reaction HAVING (count(?ecNumber) > 1) ORDER BY DESC(?ecCount)Use107_Select_the_number_of_reactions_with_no_links_to_EC_numbers: Select the number of reactions with no links to EC numbers
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh:<http://rdf.rhea-db.org/> SELECT (count(?reaction) as ?reactionCount) WHERE { ?reaction rdfs:subClassOf rh:Reaction . FILTER (NOT EXISTS {?reaction rh:ec ?ecNumber .}) }Use108_Select_all_reactions_with_no_links_to_EC_numbers: Select all reactions with no links to EC numbers
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh:<http://rdf.rhea-db.org/> SELECT ?reaction WHERE { ?reaction rdfs:subClassOf rh:Reaction . FILTER (NOT EXISTS {?reaction rh:ec ?ecNumber .}) } ORDER BY ?reactionUse109_Distribution_of_reactions_according_to_the_first_level_of_enzyme_classification: Distribution of reactions according to the first level of enzyme classification
PREFIX rh:<http://rdf.rhea-db.org/> PREFIX ec:<http://purl.uniprot.org/enzyme/> PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> PREFIX skos:<http://www.w3.org/2004/02/skos/core#> SELECT ?ecClass (str(?ecName) as ?ecClassName) (count(?reaction) as ?reactionCount) WHERE { SERVICE <http://sparql.uniprot.org/sparql> { VALUES (?ecClass) { (ec:1.-.-.-)(ec:2.-.-.-)(ec:3.-.-.-)(ec:4.-.-.-)(ec:5.-.-.-) (ec:6.-.-.-) (ec:7.-.-.-) } ?ecNumber rdfs:subClassOf ?ecClass . ?ecClass skos:prefLabel ?ecName . } ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:ec ?ecNumber . } GROUP BY ?ecClass ?ecNameUse110_Select_reaction_ec_protein_for_a_given_reaction: Select
111_Select_reaction_ec_protein_for_a_given_EC_number: Select
112_Total_number_of_reaction_ec_protein_links: Total number of
113_Number_of_distinct_rhea_EC_number_UniProtKB_Swiss-Prot_entries_involved_in_reaction_ec_protein_links: Number of distinct rhea, EC number, UniProtKB/Swiss-Prot entries involved in (
114_Retrieve_the_set_of_reactions_catalyzed_by_enzymes_of_the_ECOLI_reference_proteome_reaction-EC-protein: Retrieve the set of reactions catalyzed by enzymes of the ECOLI reference proteome (
115_Retrieve_the_set_of_metabolites_involved_in_reactions_catalyzed_by_human_genes_HUMAN_reference_proteome: Retrieve the set of metabolites involved in reactions catalyzed by human genes (HUMAN reference proteome)
PREFIX rh:<http://rdf.rhea-db.org/> PREFIX taxon:<http://purl.uniprot.org/taxonomy/> PREFIX ec:<http://purl.uniprot.org/enzyme/> PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> PREFIX up:<http://purl.uniprot.org/core/> PREFIX keywords:<http://purl.uniprot.org/keywords/> SELECT ?chebi ?reaction ?ecNumber ?protein ?ensemblTranscript ?ensemblGene WHERE { SERVICE <https://sparql.uniprot.org/sparql> { ?protein a up:Protein . ?protein up:reviewed true . ?protein up:organism taxon:9606 . ?protein up:classifiedWith keywords:1185 . ?protein rdfs:seeAlso ?ensemblTranscript . ?ensemblTranscript a up:Transcript_Resource . ?ensemblTranscript up:database <http://purl.uniprot.org/database/Ensembl> . ?ensemblTranscript up:transcribedFrom ?ensemblGene . {?protein up:enzyme ?ecNumber .} UNION {?protein up:domain/up:enzyme ?ecNumber .} UNION {?protein up:component/up:enzyme ?ecNumber .} } ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . ?reaction rh:ec ?ecNumber . ?reaction rh:side ?reactionSide . ?reactionSide rh:contains ?participant . ?participant rh:compound ?compound . ?compound rh:chebi ?chebi . # only considering small molecules participants }Use116_Retrieve_the_set_of_reactions_catalyzed_by_human_enzymes_reactions_EC_proteins_from_HUMAN_reference_proteome: Retrieve the set of reactions catalyzed by human enzymes (reactions - EC - proteins from HUMAN reference proteome)
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh:<http://rdf.rhea-db.org/> PREFIX CHEBI:<http://purl.obolibrary.org/obo/CHEBI_> PREFIX ec:<http://purl.uniprot.org/enzyme/> PREFIX up:<http://purl.uniprot.org/core/> PREFIX taxon:<http://purl.uniprot.org/taxonomy/> PREFIX keywords:<http://purl.uniprot.org/keywords/> SELECT ?protein ?ecNumber ?reaction WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . ?reaction rh:ec ?ecNumber . ?reaction rh:side ?reactionSide . ?reactionSide rh:contains ?participant . ?participant rh:compound ?compound . # ?compound rh:chebi CHEBI:57970 . ?compound rh:chebi ?chebi . ?chebi rdfs:subClassOf+ CHEBI:18059 . SERVICE <https://sparql.uniprot.org/sparql> { ?protein a up:Protein ; up:reviewed true ; up:organism taxon:83333 ; up:classifiedWith keywords:1185 . {?protein up:enzyme ?ecNumber} UNION {?protein up:domain/up:enzyme ?ecNumber} UNION {?protein up:component/up:enzyme ?ecNumber} . } }Use117_Retrieve_parent_reactions_and_their_catalyzing_enzymes_for_a_metabolite_that_is_not_directly_involved_in_a_reaction: Retrieve parent reactions (and their catalyzing enzymes) for a metabolite that is not directly involved in a reaction (ex: CHEBI:83137).
PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh:<http://rdf.rhea-db.org/> PREFIX ec:<http://purl.uniprot.org/enzyme/> PREFIX up:<http://purl.uniprot.org/core/> PREFIX taxon:<http://purl.uniprot.org/taxonomy/> PREFIX keywords:<http://purl.uniprot.org/keywords/> SELECT ?chebi ?ecNumber (count(?protein) as ?proteinCount) ?reaction ?equation WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . ?reaction rh:equation ?equation . ?reaction rh:ec ?ecNumber . ?reaction rh:side ?reactionSide . ?reactionSide rh:contains ?participant . ?participant rh:compound ?compound . ?compound rh:chebi ?chebi . CHEBI:83137 rdfs:subClassOf+ ?chebi. SERVICE <https://sparql.uniprot.org/sparql> { ?protein a up:Protein . ?protein up:reviewed true . {?protein up:enzyme ?ecNumber} UNION {?protein up:domain/up:enzyme ?ecNumber} UNION {?protein up:component/up:enzyme ?ecNumber} . } } GROUP BY ?chebi ?ecNumber ?reaction ?equationUse118_Number_of_approved_reactions_missing_citations: Number of approved reactions missing citations
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh: <http://rdf.rhea-db.org/> SELECT (count(?reaction) as ?eactionMissingCitationCount) WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . OPTIONAL {?reaction rh:citation ?citation .} FILTER (NOT EXISTS {?reaction rh:citation ?citation .}) }Use119_Give_me_the_set_of_approved_reactions_missing_citations: Give me the set of approved reactions missing citations
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh: <http://rdf.rhea-db.org/> SELECT ?reaction WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . OPTIONAL {?reaction rh:citation ?citation .} FILTER (NOT EXISTS {?reaction rh:citation ?citation .} ) } ORDER BY ?reactionUse126_list_protein_components_ec: list = protein - components -ec
PREFIX up:<http://purl.uniprot.org/core/> PREFIX ec:<http://purl.uniprot.org/enzyme/> PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> SELECT distinct ?enzyme WHERE { ?protein up:reviewed true . ?protein up:mnemonic ?mnemonic . ?protein up:domain ?domain . ?domain up:enzyme ?enzyme . }Use128_list_EC_numbers_not_linked_to_UniProt_entries: list = EC numbers not linked to UniProt entries
PREFIX up:<http://purl.uniprot.org/core/> PREFIX ec:<http://purl.uniprot.org/enzyme/> PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> SELECT (count(distinct ?ecNumber) as ?ecCount) WHERE { ?ecNumber rdfs:subClassOf up:Enzyme . FILTER (NOT EXISTS {?ecNumber up:obsolete true .} ) FILTER (!regex(?ecNumber,'-')) . FILTER (NOT EXISTS { ?protein up:enzyme ?ecNumber . ?protein up:reviewed true . }) FILTER (NOT EXISTS { ?protein up:domain/up:enzyme ?ecNumber . ?protein up:reviewed true . }) FILTER (NOT EXISTS { ?protein up:reviewed true . ?protein up:component/up:enzyme ?ecNumber . }) }Use130_Where_are_the_human_genes_encoding_enzymes_metabolizing_cholesterol_expressed: Where are the human genes encoding enzymes metabolizing cholesterol expressed?
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX up: <http://purl.uniprot.org/core/> PREFIX : <http://purl.orthodb.org/> PREFIX rh:<http://rdf.rhea-db.org/> PREFIX odbgroup:<http://purl.orthodb.org/odbgroup/> SELECT * WHERE { SERVICE <https://sparql.orthodb.org/sparql/> { ?gene a :Gene; :memberOf odbgroup:2906at28890. ?gene :xref [a :Xref; :xrefResource ?xref]. ?xref a :Uniprot. } SERVICE <https://sparql.uniprot.org/sparql> { ?xref a up:Protein; up:recommendedName [up:fullName ?name] ; up:annotation/up:catalyticActivity/up:catalyzedReaction ?reaction . } ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:directionalReaction ?directionalReaction . OPTIONAL { ?directionalReaction rdfs:seeAlso ?xref2 . } ?reaction rh:bidirectionalReaction ?bidirectionalReaction . OPTIONAL { ?bidirectionalReaction rdfs:seeAlso ?xref2 . } }Use131_Where_are_the_human_genes_encoding_enzymes_metabolizing_cholesterol_expressed: Where are the human genes encoding enzymes metabolizing cholesterol expressed?
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> PREFIX rh:<http://rdf.rhea-db.org/> PREFIX CHEBI:<http://purl.obolibrary.org/obo/CHEBI_> PREFIX up:<http://purl.uniprot.org/core/> PREFIX taxon:<http://purl.uniprot.org/taxonomy/> PREFIX genex: <http://purl.org/genex#> PREFIX lscr: <http://purl.org/lscr#> SELECT distinct ?protein ?ensemblGene ?reaction ?anatomicEntityLabel ?anatomicEntity WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . ?reaction rh:equation ?reactionEquation . ?reaction rh:side ?reactionSide . ?reactionSide rh:contains ?participant . ?participant rh:compound ?compound . # compound constraint (CHEBI:16113 == cholesterol) ?compound rh:chebi CHEBI:16113 . SERVICE <https://sparql.uniprot.org/sparql> { # taxonomy constraint (taxon:9606 == Homo sapiens) ?protein up:organism taxon:9606 . ?protein up:annotation ?a . ?a a up:Catalytic_Activity_Annotation . ?a up:catalyticActivity ?ca . ?ca up:catalyzedReaction ?reaction . ?protein rdfs:seeAlso / up:transcribedFrom ?ensemblGene . } # federated query to Bgee (expression data) SERVICE <https://www.bgee.org/sparql/> { ?gene genex:isExpressedIn ?anatomicEntity . ?gene lscr:xrefEnsemblGene ?ensemblGene . ?anatomicEntity rdfs:label ?anatomicEntityLabel . } }Use