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-class_found-in-taxon.sparql
Chemical-class aspect: found in taxon
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX target: <http://www.wikidata.org/entity/Q46995757>
SELECT
?chemicals
?example_chemical ?example_chemicalLabel
(CONCAT("/chemical/", SUBSTR(STR(?example_chemical), 32)) AS ?example_chemicalUrl)
?taxon ?taxonLabel
(CONCAT("/taxon/", SUBSTR(STR(?taxon), 32)) AS ?taxonUrl)
?taxonDescription
WITH {
SELECT DISTINCT
(COUNT(DISTINCT(?chemical)) AS ?chemicals)
?taxon
(SAMPLE(?chemical) AS ?example_chemical)
WHERE {
?chemical wdt:P279* target: ;
p:P703 ?taxonStatement .
?taxonStatement ps:P703 ?taxon .
}
GROUP BY ?taxon
ORDER BY DESC(?chemicals)
LIMIT 250
} AS %taxons
WHERE {
INCLUDE %taxons
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
}
ORDER BY DESC(?chemicals)
graph TD