sparql-examples

A set of SPARQL examples

View the Project on GitHub Adafede/sparql-examples

wd_maintenance_chemicals_inchikey_statements

rq turtle/ttl

Statements no longer valid because (none of) the InChIKey(s) of the item does not correspond to the InChIKey matched for the reference.

Use at


PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX prov: <http://www.w3.org/ns/prov#>
#title: Statements no longer valid because (none of) the InChIKey(s) of the item does not correspond to the InChIKey matched for the reference.
SELECT ?item ?statement ?inchikey_item ?inchikey_ref WHERE {
    {
        SELECT ?item ?statement (GROUP_CONCAT(?ii; SEPARATOR = " ") AS ?inchikey_item) ?inchikey_ref WHERE {
            ?statement prov:wasDerivedFrom ?prov.
            ?prov pr:P235 ?inchikey_ref.
            ?item ?p ?statement.
            ?item wdt:P235 ?ii.
        }
        GROUP BY ?item ?statement ?inchikey_ref
    }
    FILTER (?inchikey_item != ?inchikey_ref)
    FILTER (!REGEX(?inchikey_item, ?inchikey_ref))
}

graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v7("?ii")
  v8("?inchikey_item"):::projected 
  v2("?inchikey_ref"):::projected 
  v5("?item"):::projected 
  v6("?p")
  v4("?prov")
  v3("?statement"):::projected 
  f0[["not regex(?inchikey_item,?inchikey_ref)"]]
  f0 --> v8
  f0 --> v2
  f1[["?inchikey_item != ?inchikey_ref"]]
  f1 --> v8
  f1 --> v2
  v3 --"prov:wasDerivedFrom"-->  v4
  v4 --"pr:P235"-->  v2
  v5 -->v6--> v3
  v5 --"wdt:P235"-->  v7
  bind3[/"?ii"/]
  v7 --o bind3
  bind3 --as--o v8