A set of SPARQL examples that are used in different SIB resources
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:'))
}
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?chebi"):::projected
v7("?chebi2")
v9("?chebiCount")
v8("?chebiRestriction")
v4("?compound")
v5("?dbXref"):::projected
v3("?participant")
v1("?reaction")
v2("?reactionSide")
v10("?xrefCount")
c4(["rh:Approved"]):::iri
c12(["owl:Restriction"]):::iri
c14(["chebihash:has_major_microspecies_at_pH_7_3"]):::iri
c2(["rh:Reaction"]):::iri
v1 --"rdfs:subClassOf"--> c2
v1 --"rh:status"--> c4
v1 --"rh:side"--> v2
v2 --"rh:contains"--> v3
v3 --"rh:compound"--> v4
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
f0[["regex(?dbXref,'^CAS:')"]]
f0 --> v5
v4 --"rh:chebi"--> v6
v7 --"rdfs:subClassOf"--> v8
v8 --"a"--> c12
v8 --"owl:onProperty"--> c14
v8 --"owl:someValuesFrom"--> v6
v7 --"oboInOwl:hasDbXref"--> v5
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
f1[["regex(?dbXref,'^CAS:')"]]
f1 --> v5
v4 --"rh:chebi"--> v6
v6 --"oboInOwl:hasDbXref"--> v5
end
union0r <== or ==> union0l
end
bind4[/"count(?chebi)"/]
v6 --o bind4
bind4 --as--o v9
bind5[/"count(?dbXref)"/]
v5 --o bind5
bind5 --as--o v10