wikidata-chemistry-curation

P592SingleValue.rq

Code examples: curl

SPARQL

SELECT DISTINCT ?itemLabel ?itemLabelURL ?count ?sample1 ?sample2 ?exception
WITH {
	SELECT ?formatter WHERE {
		OPTIONAL { wd:P592 wdt:P1630 ?formatter }
	} LIMIT 1
} AS %formatter
WHERE
{
	{
		SELECT ?item (COUNT(?value) AS ?count) (MIN(?value) AS ?sample1) (MAX(?value) AS ?sample2) {
			?item p:P592 [ ps:P592 ?val; wikibase:rank ?rank ] .
			FILTER( ?rank != wikibase:DeprecatedRank ) .
			INCLUDE %formatter .
			BIND( IF( BOUND( ?formatter ), URI( REPLACE( ?formatter, '\\$1', ?val ) ), ?val ) AS ?value ) .
		} GROUP BY ?item HAVING ( ?count > 1 ) LIMIT 100
	} .
	OPTIONAL {
		wd:P592 p:P2302 [ ps:P2302 wd:Q19474404; pq:P2303 ?exc ] .
		FILTER( ?exc = ?item ) .
	} .
	BIND( BOUND( ?exc ) AS ?exception ) .
    BIND (?item AS ?itemLabelURL)
	SERVICE wikibase:label { bd:serviceParam wikibase:language "en,mul" } .
}
ORDER BY DESC(?count)

Execute or Edit

Output

itemLabelURL count sample1 sample2 exception
http://www.wikidata.org/entity/Q425293 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL3039598/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL3306578/ false
http://www.wikidata.org/entity/Q4008670 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL2103975/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL264186/ false
http://www.wikidata.org/entity/Q417227 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1286/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL150361/ false
http://www.wikidata.org/entity/Q420532 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL3039593/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL553025/ false
http://www.wikidata.org/entity/Q7784695 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL10247/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL298827/ false
http://www.wikidata.org/entity/Q422301 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1201488/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL3039582/ false
http://www.wikidata.org/entity/Q417219 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL2079587/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL3182301/ false
http://www.wikidata.org/entity/Q75830 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL18041/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL28992/ false
http://www.wikidata.org/entity/Q27076606 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1627233/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL389014/ false
http://www.wikidata.org/entity/Q418611 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1292/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1369407/ false
http://www.wikidata.org/entity/Q7699849 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1097558/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1908355/ false
http://www.wikidata.org/entity/Q27164669 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL3192290/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL458603/ false
http://www.wikidata.org/entity/Q5266620 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL39263/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL9506/ false
http://www.wikidata.org/entity/Q27088229 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL408678/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL91730/ false
http://www.wikidata.org/entity/Q285687 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL55242/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL553426/ false
http://www.wikidata.org/entity/Q27088252 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL3259533/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL3265370/ false
http://www.wikidata.org/entity/Q410298 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL356431/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL938/ false
http://www.wikidata.org/entity/Q421369 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1201187/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL584744/ false
http://www.wikidata.org/entity/Q419841 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1189679/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1276421/ false
http://www.wikidata.org/entity/Q27076690 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL147763/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL358725/ false
http://www.wikidata.org/entity/Q415220 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1201258/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL225072/ false
http://www.wikidata.org/entity/Q14200353 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1778156/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL2110756/ false
http://www.wikidata.org/entity/Q425027 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1481/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL149223/ false
http://www.wikidata.org/entity/Q418086 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1616433/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1650818/ false
http://www.wikidata.org/entity/Q15634083 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL285913/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL588593/ false
http://www.wikidata.org/entity/Q425295 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1729/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL560739/ false
http://www.wikidata.org/entity/Q27076721 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL565305/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL567470/ false
http://www.wikidata.org/entity/Q5259281 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1569195/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL493682/ false
http://www.wikidata.org/entity/Q27077200 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL298517/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL298826/ false
http://www.wikidata.org/entity/Q4631298 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL3218924/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL422904/ false
http://www.wikidata.org/entity/Q422538 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL78/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL95606/ false
http://www.wikidata.org/entity/Q2482223 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL207538/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL38856/ false
http://www.wikidata.org/entity/Q21098973 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL2364640/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL3545184/ false
http://www.wikidata.org/entity/Q29428 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL496980/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL56564/ false
http://www.wikidata.org/entity/Q32904692 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL336296/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL605653/ false
http://www.wikidata.org/entity/Q390566 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL3775234/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL437472/ false
http://www.wikidata.org/entity/Q7558263 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1232510/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1240704/ false
http://www.wikidata.org/entity/Q4132745 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1197091/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1199540/ false
http://www.wikidata.org/entity/Q426921 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL269671/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL77/ false
http://www.wikidata.org/entity/Q15409437 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL197027/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL268697/ false
http://www.wikidata.org/entity/Q190016 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1909300/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL526514/ false
http://www.wikidata.org/entity/Q906271 2 https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1201534/ https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL1201684/ false

Code examples

curl

curl -o P592SingleValue.rq https://raw.githubusercontent.com/egonw/SARS-CoV-2-Queries/master/sparql/P592SingleValue.rq
curl -H "Accept: text/tab-separated-values" -G https://query.wikidata.org/bigdata/namespace/wdq/sparql --data-urlencode query@P592SingleValue.rq

This SPARQL query is available under CCZero.