SPARQL example query
79_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 . }Use80_Select_the_number_of_approved_reactions_involving_a_carbohydrate_derivative: Select the number of approved reactions involving a *_carbohydrate derivative_* (subclass of *CHEBI:63299*) 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:63299 . }Use81_Select_all_approved_reactions_involving_a_carbohydrate_derivative: Select all approved reactions involving a *_carbohydrate derivative_* (subclass of *CHEBI:63299*) based on the ChEBI ontology
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:63299 . } ORDER BY ?reactionUse82_Select_the_number_of_approved_reactions_involving_a_carbohydrate: Select the number of approved reactions involving a *_carbohydrate_* (subclass of *CHEBI:16646*) 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:16646 . }Use83_Select_all_approved_reactions_involving_a_carbohydrate: Select all approved reactions involving a *_carbohydrate_* (subclass of *CHEBI:16646*) 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:16646 . } ORDER BY ?reactionUse84_Select_the_number_of_approved_reactions_involving_lipids: Select the number of approved reactions involving *lipids* (subclass of *CHEBI:18059*) based on the ChEBI ontology
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:18059 . }Use85_Select_all_approved_reactions_involving_lipids: Select all approved reactions involving *lipids* (subclass of *CHEBI:18059*) based on the ChEBI ontology
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:18059 . } ORDER BY ?reactionUse86_Select_all_approved_reactions_involving_lipids: Select all approved reactions involving *lipids* (subclass of *CHEBI:18059*) that have at least one parent reaction
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 ?reactionParent WHERE { ?reactionParent rdfs:subClassOf rh:Reaction . ?reactionParent rh:status rh:Approved . ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . ?reaction rdfs:subClassOf ?reactionParent . ?reaction rh:side ?reactionSide . ?reactionSide rh:contains ?participant . ?participant rh:compound ?compound . ?compound rh:chebi ?chebi . ?chebi rdfs:subClassOf+ CHEBI:18059 . } ORDER BY ?reactionUse87_Select_all_approved_reactions_involving_lipids_that_are_parent_reactions_and_give_their_number_of_descendants: Select all approved reactions involving *lipids* (subclass of *CHEBI:18059*) that are parent reactions and give their number of descendants
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 (count(distinct ?reactionDescendant) as ?reactionDescendantCount) ?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:18059 . ?reactionDescendant rdfs:subClassOf rh:Reaction . ?reactionDescendant rh:status rh:Approved . ?reactionDescendant rdfs:subClassOf+ ?reaction . } group by ?reaction ?reactionEquation ORDER BY ?reactionUse88_How_many_descendants_of_CHEBI_17815: How many descendants of CHEBI:17815 (a 1,2-diacyl-sn-glycerol) in the ChEBI ontology?
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(?chebiDescendant) as ?countChild) WHERE { ?chebiDescendant rdfs:subClassOf+ CHEBI:17815 . ?chebiDescendant rdfs:label ?label . }Use89_Give_me_all_CHEBI_identifier_and_label_for_the_descendants_of_CHEBI_17815: Give me all CHEBI identifier and label for the descendants of CHEBI:17815 (a 1,2-diacyl-sn-glycerol)
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 ?chebiDescendant (str(?label) as ?chebiLabel) WHERE { ?chebiDescendant rdfs:subClassOf+ CHEBI:17815 . ?chebiDescendant rdfs:label ?label . } ORDER BY ?chebiDescendantCarbohydrateUse90_How_many_reactions_involve_CHEBI_17815: How many reactions involve CHEBI:17815 (a 1,2-diacyl-sn-glycerol)?
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 ?participant . ?participant rh:compound ?compound . ?compound rh:chebi CHEBI:17815 . }Use91_How_many_reactions_involve_CHEBI_17815: How many reactions involve CHEBI:17815 (a 1,2-diacyl-sn-glycerol) or one of its descendant?
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 ?countReaction) WHERE { ?reaction rdfs:subClassOf rh:Reaction ; rh:status rh:Approved ; rh:side ?reactionSide . ?reactionSide rh:contains ?participant . ?participant rh:compound ?compound . ?compound rh:chebi ?chebi . ?chebi rdfs:subClassOf* CHEBI:17815 . }Use92_Select_all_approved_reactions_with_participants_being_CHEBI_17815_or_one_of_its_descendant: Select all approved reactions with participant(s) being CHEBI:17815 (a 1,2-diacyl-sn-glycerol) or one of its descendant
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:17815 . } ORDER BY ?reactionUse93_Select_all_approved_reactions_with_CHEBI_17815_or_one_of_its_descendant_optional_EC: Select all approved reactions with CHEBI:17815 (a 1,2-diacyl-sn-glycerol) or one of its descendant. Display the EC numbers if the rhea-ec link exists.
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 ?ec ?reactionEquation WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . ?reaction rh:equation ?reactionEquation . ?reaction rh:side ?reactionSide . OPTIONAL {?reaction rh:ec ?ec .} . ?reactionSide rh:contains ?participant . ?participant rh:compound ?compound . ?compound rh:chebi ?chebi . ?chebi rdfs:subClassOf* CHEBI:17815 . } ORDER BY ?reactionUse94_Select_all_approved_reactions_with_CHEBI_or_one_of_its_descendant_optional_UniProtKB_reviewed_EC: Select all approved reactions with CHEBI:17815 (a 1,2-diacyl-sn-glycerol) or one of its descendant. Display links to UniProtKB/Swiss-Prot entries via EC numbers if the link rhea-ec exists.
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/> SELECT distinct ?reaction ?enzyme (count(distinct ?protein) as ?proteinCount) WHERE { ?reaction rdfs:subClassOf rh:Reaction . ?reaction rh:status rh:Approved . ?reaction rh:side ?reactionSide . OPTIONAL {?reaction rh:ec ?enzyme . SERVICE <https://sparql.uniprot.org/sparql> { ?protein up:reviewed true . ?protein up:enzyme ?enzyme. } } . ?reactionSide rh:contains ?participant . ?participant rh:compound ?compound . ?compound rh:chebi ?chebi . ?chebi rdfs:subClassOf* CHEBI:17815 . } GROUP BY ?reaction ?enzyme ORDER BY ?reactionUse95_Get_uniprot_name_of_a_given_chebi_compound: Get uniprot name of a given chebi compound
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rh:<http://rdf.rhea-db.org/> PREFIX CHEBI:<http://purl.obolibrary.org/obo/CHEBI_> PREFIX oboInOwl:<http://www.geneontology.org/formats/oboInOwl#> PREFIX owl:<http://www.w3.org/2002/07/owl#> PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> SELECT ?chebi ?chebiName ?chebiUniprotName WHERE { BIND(CHEBI:57416 AS ?chebi) ?chebi rdfs:label ?chebiName . ?chebi oboInOwl:hasRelatedSynonym ?chebiUniprotName . ?axiom a owl:Axiom . ?axiom owl:annotatedSource ?chebi . ?axiom owl:annotatedProperty oboInOwl:hasRelatedSynonym . ?axiom owl:annotatedTarget ?chebiUniprotName . ?axiom oboInOwl:hasDbXref ?dbXref . FILTER (?dbXref="UniProt") }Use96_Get_tautomer_of_a_given_chebi_compound: Get tautomer of a given chebi compound
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh:<http://rdf.rhea-db.org/> PREFIX obo:<http://purl.obolibrary.org/obo/> 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#> select ?chebi ?chebiName ?chebiTautomer ?chebiTautomerName where { BIND(CHEBI:57416 AS ?chebi) ?chebi rdfs:subClassOf ?chebiRestriction . ?chebiRestriction a owl:Restriction . ?chebiRestriction owl:onProperty chebihash:is_tautomer_of . ?chebiRestriction owl:someValuesFrom ?chebiTautomer . ?chebi rdfs:label ?chebiName . ?chebiTautomer rdfs:label ?chebiTautomerName . }Use97_Get_structural_data_of_a_given_ChEBI_compound: Get structural data of a given ChEBI compound (CHEBI:29985 L-glutamate)
# # get structural data of a given ChEBI compound # PREFIX rh:<http://rdf.rhea-db.org/> PREFIX CHEBI:<http://purl.obolibrary.org/obo/CHEBI_> PREFIX chebihash:<http://purl.obolibrary.org/obo/chebi/> SELECT ?chebi ?formula ?charge ?mass ?monoisotopicmass ?inchikey ?smiles ?inchi WHERE { BIND (CHEBI:29985 AS ?chebi) ?chebi chebihash:inchi ?inchi ; chebihash:smiles ?smiles ; chebihash:formula ?formula ; chebihash:mass ?mass ; chebihash:charge ?charge ; chebihash:inchikey ?inchikey ; chebihash:monoisotopicmass ?monoisotopicmass . }Use98_Get_chebi_compound_of_a_given_InChI: Get chebi compound of a given InChI
PREFIX rh:<http://rdf.rhea-db.org/> PREFIX obo:<http://purl.obolibrary.org/obo/> PREFIX chebihash:<http://purl.obolibrary.org/obo/chebi/> SELECT ?chebi ?inchi WHERE { BIND("InChI=1S/C5H9NO4/c6-3(5(9)10)1-2-4(7)8/h3H,1-2,6H2,(H,7,8)(H,9,10)/t3-/m0/s1" AS ?inchi) ?chebi chebihash:inchi ?inchi . }Use99_Get_the_list_of_reactions_involving_a_ChEBI_participant_with__has_role_antifungal_agent: Get the list of reactions involving a ChEBI participant with has role antifungal agent (CHEBI:35718)
PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX obo: <http://purl.obolibrary.org/obo/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh:<http://rdf.rhea-db.org/> PREFIX chebihash:<http://purl.obolibrary.org/obo/chebi#> SELECT (count(distinct ?reaction) as ?reactionCount) 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 ?chebiInRhea . { ?chebiInRhea rdfs:subClassOf ?chebiRestrictionRole . ?chebiRestrictionRole a owl:Restriction . ?chebiRestrictionRole owl:onProperty obo:RO_0000087 . ?chebiRestrictionRole owl:someValuesFrom CHEBI:35718 . } UNION { ?chebi rdfs:subClassOf ?chebiRestrictionRole . ?chebiRestrictionRole a owl:Restriction . ?chebiRestrictionRole owl:onProperty obo:RO_0000087 . ?chebiRestrictionRole owl:someValuesFrom CHEBI:35718 . ?chebi rdfs:subClassOf ?chebiRestrictionPH . ?chebiRestrictionPH a owl:Restriction . ?chebiRestrictionPH owl:onProperty chebihash:has_major_microspecies_at_pH_7_3 . ?chebiRestrictionPH owl:someValuesFrom ?chebiInRhea . } }Use