SPARQL example query
54_List_all_generic_compounds: List all generic compounds
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh: <http://rdf.rhea-db.org/> SELECT ?compound ?compoundName WHERE { ?compound rdfs:subClassOf rh:Polymer . ?compound rh:name ?compoundName . } ORDER BY (?compound)Use55_Number_of_compounds_according_to_their_category: Number of compounds according to their category (Small molecule, Generic compound, Polymer)
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)Use56_Distribution_of_GenericParticipant: Distribution of GenericParticipant
PREFIX rh: <http://rdf.rhea-db.org/> PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> SELECT ?genericSubClass ?labelGenericSubClass (count(?genericParticipant) as ?countGenericParticipant) WHERE { ?genericSubClass rdfs:subClassOf rh:GenericParticipant . ?genericSubClass rdfs:label ?labelGenericSubClass . ?genericParticipant rdfs:subClassOf* ?genericSubClass . } GROUP BY ?genericSubClass ?labelGenericSubClassUse57_Give_me_the_list_of_Rhea_generics: Give me the list of Rhea generics, type polypeptide (rh:GenericPolypeptideParticipant)
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh: <http://rdf.rhea-db.org/> SELECT ?genericSubClass ?labelGenericSubClass (count(?genericParticipant) as ?countGenericParticipant) WHERE { ?genericSubClass rdfs:subClassOf rh:GenericParticipant . ?genericSubClass rdfs:label ?labelGenericSubClass . ?genericParticipant rdfs:subClassOf* ?genericSubClass . } GROUP BY ?genericSubClass ?labelGenericSubClassUse58_Give_me_the_reactions_involving_a_given_Rhea_generic: Give me the reactions involving a given Rhea generic (GENERIC:11964, "reduced [NADPH—hemoprotein reductase]")
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh: <http://rdf.rhea-db.org/> SELECT ?genericSubClass ?labelGenericSubClass (count(?genericParticipant) as ?countGenericParticipant) WHERE { ?genericSubClass rdfs:subClassOf rh:GenericParticipant . ?genericSubClass rdfs:label ?labelGenericSubClass . ?genericParticipant rdfs:subClassOf* ?genericSubClass . } GROUP BY ?genericSubClass ?labelGenericSubClassUse59_Select_reaction_participants_for_a_given_reaction_ID._Display_their_coefficient_and_their_name: Select reaction participants for a given reaction ID. Display their coefficient and their name.
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh: <http://rdf.rhea-db.org/> SELECT ?genericCompound ?genericCompoundName ?reaction ?equation WHERE { ?genericCategory rdfs:subClassOf rh:GenericCompound . ?genericCompound rdfs:subClassOf ?genericCategory . ?genericCompound rh:name ?genericCompoundName . ?genericCompound rh:accession ?ac . FILTER (?ac='GENERIC:11964') . ?participant rh:compound ?genericCompound . ?reactionSide rh:contains ?participant . ?reaction rh:side ?reactionSide . ?reaction rh:equation ?equation . }Use60_Select_the_number_of_approved_reactions_using_CHEBI_29985_as_small_molecule_participant: Select the number of approved reactions using CHEBI:29985 (L-glutamate) as small molecule participant
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh:<http://rdf.rhea-db.org/> SELECT ?reaction ?reactionSide ?coefficient ?participant ?name WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:side ?reactionSide . ?contains rdfs:subPropertyOf rh:contains . ?contains rh:coefficient ?coefficient . ?reactionSide ?contains ?participant . ?participant rh:compound ?compound . ?compound rh:name ?name . FILTER (?reaction=rh:11680) } ORDER BY ?reactionSideUse61_Select_all_approved_reactions_using_CHEBI_29985_as_small_molecule_participant: Select all approved reactions using CHEBI:29985 (L-glutamate) as small molecule participant
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/> SELECT (count(?reaction) as ?reactionCount) WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . ?reaction rh:side ?reactionSide . ?reactionSide rh:contains ?smallMolecule . ?smallMolecule rdfs:subClassOf+ CHEBI:29985 }Use62_Select_the_number_of_approved_reactions_using_L-glutamine_AND_L-glutamate_in_different_reaction_sides: Select the number of approved reactions using L-glutamine (CHEBI:29985) AND L-glutamate (CHEBI:58359) in different reaction sides
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/> SELECT ?reaction ?reactionEquation 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 rh:chebi CHEBI:29985 } # There are several way to indicate that the reaction sides must be different: # - ?reactionSide1 rh:transformableTo ?reactionSide2 # FILTER (?reactionSide1 != ?reactionSide2) #It is better to use rh:transformableTo predicate.Use63_Select_all_approved_reactions_using_L-glutamine_AND_L-glutamate_in_different_reaction_sides: Select all approved reactions using L-glutamine (CHEBI:29985) AND L-glutamate (CHEBI:58359) in different reaction sides
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/> SELECT (count(?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:chebi CHEBI:29985 . ?reaction rh:side ?reactionSide2 . ?reactionSide2 rh:contains ?participant2 . ?participant2 rh:compound ?compound2 . ?compound2 rh:chebi CHEBI:58359 . ?reactionSide1 rh:transformableTo ?reactionSide2 }Use64_Number_of_reaction_participants_per_reaction_side: Distribution: number of reaction participants per reaction Side
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/> SELECT ?reaction ?reactionEquation WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . ?reaction rh:equation ?reactionEquation . ?reaction rh:side ?reactionSide1 . ?reactionSide1 rh:contains ?participant1 . ?participant1 rh:compound ?compound1 . ?compound1 rh:chebi CHEBI:29985 . ?reaction rh:side ?reactionSide2 . ?reactionSide2 rh:contains ?participant2 . ?participant2 rh:compound ?compound2 . ?compound2 rh:chebi CHEBI:58359 . ?reactionSide1 rh:transformableTo ?reactionSide2 . } ORDER BY ?reactionUse65_Number_of_reaction_participants_per_reaction_side: Distribution: number of reaction participants per reaction Side
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh:<http://rdf.rhea-db.org/> SELECT ?reaction ?reactionSide1 (count(distinct ?participant1) as ?side1ParticipantCount) ?reactionSide2 (count(distinct ?participant2) as ?side2ParticipantCount) WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . ?reaction rh:side ?reactionSide1 . ?reactionSide1 rh:contains ?participant1 . ?reaction rh:side ?reactionSide2 . ?reactionSide2 rh:contains ?participant2 . ?reactionSide1 rh:transformableTo ?reactionSide2 } GROUP BY ?reaction ?reactionSide1 ?reactionSide2 ORDER BY ?reactionUse66_Select_all_compounds_and_count_their_occurrence_in_Rhea_reactions: Select all compounds and count their occurrence in Rhea reactions
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh:<http://rdf.rhea-db.org/> SELECT ?reaction ?reactionSide1 (count(distinct ?participant1) as ?side1ParticipantCount) ?reactionSide2 (count(distinct ?participant2) as ?side2ParticipantCount) WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . ?reaction rh:side ?reactionSide1 . ?reactionSide1 rh:contains ?participant1 . ?reactionSide1 rh:curatedOrder ?curatedOrder1 . ?reaction rh:side ?reactionSide2 . ?reactionSide2 rh:contains ?participant2 . ?reactionSide2 rh:curatedOrder ?curatedOrder2 . ?reactionSide1 rh:transformableTo ?reactionSide2 . FILTER (?curatedOrder1 < ?curatedOrder2) . } GROUP BY ?reaction ?reactionSide1 ?reactionSide2 ORDER BY DESC(?side1ParticipantCount) DESC(?side2ParticipantCount) ?reactionUse67_Select_all_compounds_and_count_their_occurrence_in_Rhea_reactions: Select all compounds and count their occurrence in Rhea reactions
PREFIX rh: <http://rdf.rhea-db.org/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?reactionParticipantAc ?chebi (count(distinct ?reaction) as ?reactionCount) ?reactionParticipantName WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . ?reaction rh:side ?reactionSide . ?reactionSide rh:contains ?participant . ?participant rh:compound ?compound . OPTIONAL { ?compound rh:chebi ?chebi . } ?compound rh:name ?reactionParticipantName . ?compound rh:accession ?reactionParticipantAc . } GROUP BY ?reactionParticipantAc ?chebi ?reactionParticipantName ORDER BY DESC(?reactionCount)Use68_Select_reaction_participants_that_appear_in_only_one_reaction: Select reaction participants that appear in only one reaction
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh:<http://rdf.rhea-db.org/> SELECT ?compound ?compoundAc ?compoundName 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:name ?compoundName . ?compound rh:accession ?compoundAc . } GROUP BY ?compound ?compoundName ?compoundAc HAVING (count(distinct ?reaction) = 1) ORDER BY ?compoundAcUse69_Select_all_the_direct_children_of_carbohydrate_in_the_ChEBI_ontology_used_in_Rhea_reaction_or_not: Select all the (direct) children of *carbohydrate* (CHEBI:16646) in the ChEBI ontology , used in Rhea reaction or not
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/> SELECT ?chebiChildCarbohydrate ?chebiLabel WHERE { ?chebiChildCarbohydrate rdfs:subClassOf CHEBI:16646 . ?chebiChildCarbohydrate rdfs:label ?chebiLabel . } ORDER BY ?chebiChildCarbohydrateUse70_Select_all_the_descendants_of__carbohydrate__in_the_ChEBI_ontology_used_in_Rhea_reaction_or_not: Select all the descendants of *carbohydrate* (CHEBI:16646) in the ChEBI ontology, used in Rhea reaction or not
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/> SELECT ?chebiDescendantCarbohydrate (str(?label) as ?chebiLabel) WHERE { ?chebiDescendantCarbohydrate rdfs:subClassOf+ CHEBI:16646 . ?chebiDescendantCarbohydrate rdfs:label ?label . } ORDER BY ?chebiDescendantCarbohydrateUse71_Select_count_of_descendants_of_carbohydrate_in_the_ChEBI_ontology_used_in_Rhea_reaction_or_not: Select count of descendants of *carbohydrate* (CHEBI:16646) in the ChEBI ontology, used in Rhea reaction or not
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/> SELECT (count(?chebiDescendantCarbohydrate) AS ?chebiDescendantCarbohydrateCount) WHERE { ?chebiDescendantCarbohydrate rdfs:subClassOf+ CHEBI:16646 . ?chebiDescendantCarbohydrate rdfs:label ?label . }Use72_Select_children_of_CHEBI_35179_in_the_ChEBI_hierarchy_used_in_Rhea_reactions_or_not: Select children of CHEBI:35179 (a 2-oxo carboxylate) in the ChEBI hierarchy (using rdfs:subClassOf), used in Rhea reactions or not
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/> SELECT ?chebiChild (str(?label) as ?chebiChildName) WHERE { ?chebiChild rdfs:subClassOf CHEBI:35179 . ?chebiChild rdfs:label ?label . } ORDER BY ?chebiChildUse73_Select_all_the_descendants_of_CHEBI_35179_in_the_ChEBI_hierarchy_used_in_Rhea_reaction_or_not: Select all the descendants of CHEBI:35179 (a 2-oxo carboxylate) in the ChEBI hierarchy (using rdfs:subClassOf+), used in Rhea reaction or not
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/> SELECT ?chebiDescendant (str(?label) as ?chebiDescendantName) WHERE { ?chebiDescendant rdfs:subClassOf+ CHEBI:35179 . ?chebiDescendant rdfs:label ?label . } ORDER BY ?chebiDescendantUse74_Select_children_of_CHEBI_35179_in_the_ChEBI_hierarchy_used_in_Rhea_reactions_and_show_the_reactions: Select children of CHEBI:35179 (a 2-oxo carboxylate) in the ChEBI hierarchy (using rdfs:subClassOf) used in Rhea reaction(s), and show the reaction(s)
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/> SELECT ?chebi ?compoundName ?reaction ?reactionEquation 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 rh:name ?compoundName . ?compound rh:chebi ?chebi . ?chebi rdfs:subClassOf CHEBI:35179 . } ORDER BY ?chebiUse75_Select_all_the_descendants_of_CHEBI_35179_in_the_ChEBI_hierarchy_used_in_Rhea_reactions_and_show_the_reactions: Select all the descendants of CHEBI:35179 (a 2-oxo carboxylate) in the ChEBI hierarchy (using rdfs:subClassOf+) used in Rhea reaction(s), and show the reaction(s)
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/> SELECT ?chebi ?compoundName ?reaction ?reactionEquation 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 rh:name ?compoundName . ?compound rh:chebi ?chebi . ?chebi rdfs:subClassOf+ CHEBI:35179 . } ORDER BY ?chebiUse76_Select_the_number_of_approved_reactions_involving_a_monosaccharide_derivative: Select the number of approved reactions involving a *_monosaccharide derivative_* (subclass of *CHEBI:63367*) based on the ChEBI ontology (use of *subClassOf+*)
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/> SELECT (count(distinct ?reaction) as ?reactionCount) 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 rdfs:subClassOf+ CHEBI:63367 . }Use77_Select_all_approved_reactions_involving_a_monosaccharide_derivative: Select all approved reactions involving a *_monosaccharide derivative_* (subclass of *CHEBI:63367*) based on the ChEBI ontology (use of *subClassOf+*)
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/> SELECT distinct ?reaction ?reactionEquation 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 rh:chebi ?chebi . ?chebi rdfs:subClassOf+ CHEBI:63367 . } ORDER BY ?reactionUse78_Select_the_number_of_approved_reactions_involving_a_monosaccharide: Select the number of approved reactions involving a *_monosaccharide_* (subclass of *CHEBI:35381*) based on the ChEBI ontology (use of *subClassOf+*)
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/> SELECT (count(distinct ?reaction) as ?reactionCount) 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 rdfs:subClassOf+ CHEBI:35381 . }Use79_Select_all_approved_reactions_involving_a_monosaccharide: Select all approved reactions involving a *_monosaccharide_* (subclass of *CHEBI:35381*) based on the ChEBI ontology (use of *subClassOf+*)
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_> SELECT distinct ?reaction ?reactionEquation 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 rh:chebi ?chebi . ?chebi rdfs:subClassOf+ CHEBI:35381 . }Use