A set of SPARQL examples that are used in different SIB resources
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 .
}
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v8("?chebi")
v6("?chebiInRhea")
v9("?chebiRestrictionPH")
v7("?chebiRestrictionRole")
v5("?compound")
v4("?participant")
v1("?reaction"):::projected
v10("?reactionCount")
v2("?reactionEquation")
v3("?reactionSide")
c4(["rh:Approved"]):::iri
c15(["obo:CHEBI_35718"]):::iri
c13(["obo:RO_0000087"]):::iri
c11(["owl:Restriction"]):::iri
c16(["obo:chebi#has_major_microspecies_at_pH_7_3"]):::iri
c2(["rh:Reaction"]):::iri
v1 --"rdfs:subClassOf"--> c2
v1 --"rh:status"--> c4
v1 --"rh:equation"--> v2
v1 --"rh:side"--> v3
v3 --"rh:contains"--> v4
v4 --"rh:compound"--> v5
v5 --"rh:chebi"--> v6
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v8 --"rdfs:subClassOf"--> v7
v7 --"a"--> c11
v7 --"owl:onProperty"--> c13
v7 --"owl:someValuesFrom"--> c15
v8 --"rdfs:subClassOf"--> v9
v9 --"a"--> c11
v9 --"owl:onProperty"--> c16
v9 --"owl:someValuesFrom"--> v6
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v6 --"rdfs:subClassOf"--> v7
v7 --"a"--> c11
v7 --"owl:onProperty"--> c13
v7 --"owl:someValuesFrom"--> c15
end
union0r <== or ==> union0l
end
bind1[/"count(?reaction)"/]
v1 --o bind1
bind1 --as--o v10