A set of SPARQL examples that are used in different TGX resources
List all compounds in the HBM4EU priority substances collection with identifier wd:Q56, optionally with their InChIKey and PubChem CID identifiers.
PREFIX wd: <https://compoundcloud.wikibase.cloud/entity/>
PREFIX wdt: <https://compoundcloud.wikibase.cloud/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?compound ?compoundLabel
(CONCAT("#compound/", SUBSTR(STR(?compound), 45)) AS ?compoundUrl)
?inchikey ?pubchem
WHERE {
VALUES ?collection { wd:Q56 }
?compound wdt:P21 ?collection .
OPTIONAL { ?compound wdt:P10 ?inchikey }
OPTIONAL { ?compound wdt:P13 ?pubchem }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?collection")
v2("?compound"):::projected
v5("?compoundUrl")
v3("?inchikey"):::projected
v4("?pubchem"):::projected
c5(["bd:serviceParam"]):::iri
c7(["#91;AUTO_LANGUAGE#93;,en"]):::literal
bind0[/VALUES ?collection/]
bind0-->v1
bind00(["wd:Q56"])
bind00 --> bind0
v2 --"wdt:P21"--> v1
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P10".-> v3
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P13".-> v4
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c5 --"wikibase:language"--> c7
end
bind1[/"concat('#compound/',substring(str(?compound),'45^^xsd:integer'))"/]
v2 --o bind1
bind1 --as--o v5