A set of SPARQL examples that are used in different TGX resources
License: https://www.gnu.org/licenses/gpl-3.0
Uses method in: https://github.com/WDscholia/scholia/tree/master/scholia/app/templates/chemical_physchem-properties.sparql
Chemical aspect: physicochemical properties of this chemical
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://wikidata.org/entity/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX target: <http://www.wikidata.org/entity/Q2270>
# title: physicochemical properties of this chemical
SELECT DISTINCT ?propEntity ?propEntityLabel ?value ?units ?unitsLabel ?qualifiers ?source ?sourceLabel ?doi
WITH {
SELECT DISTINCT ?propEntity ?value ?units ?source ?doi (GROUP_CONCAT(?qualifierStr; separator=", ") AS ?qualifiers) WHERE {
target: ?propp ?statement .
?statement a wikibase:BestRank ;
?proppsv [
wikibase:quantityAmount ?value ;
wikibase:quantityUnit ?units
] .
OPTIONAL {
?statement prov:wasDerivedFrom/pr:P248 ?source .
OPTIONAL { ?source wdt:P356 ?doi . }
}
?property wikibase:claim ?propp ;
wikibase:statementValue ?proppsv ;
wdt:P1629 ?propEntity ;
wdt:P31 wd:Q21077852 .
OPTIONAL {
{
?qualifierProp wikibase:qualifier ?qualifier ;
rdfs:label ?qProplabel; FILTER (lang(?qProplabel) = "en") .
?qualifier a owl:DatatypeProperty .
?statement ?qualifier ?qualifierVal .
BIND (CONCAT(str(?qProplabel), ": ", str(?qualifierVal)) AS ?qualifierStr)
} UNION {
?qualifierProp wikibase:qualifier ?qualifier ;
rdfs:label ?qProplabel; FILTER (lang(?qProplabel) = "en") .
?qualifier a owl:ObjectProperty .
?statement ?qualifier ?qualifierVal .
?qualifierVal rdfs:label ?qVallabel; FILTER (lang(?qVallabel) = "en") .
BIND (CONCAT(str(?qProplabel), ": ", str(?qVallabel)) AS ?qualifierStr)
}
}
} GROUP BY ?propEntity ?value ?units ?source ?doi
} AS %result
WHERE {
INCLUDE %result
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
}
ORDER BY ASC(?propEntityLabel)
graph TD