sparql-examples

A set of SPARQL examples

View the Project on GitHub Adafede/sparql-examples

wd_chemicals_inchikeys_mwapi

rq turtle/ttl

Which chemicals contain given short inchikey(s) (first layer of 14 characters)?

Use at


PREFIX mwapi: <https://www.mediawiki.org/ontology#API/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#title: Which chemicals contain given short inchikey(s) (first layer of 14 characters)?
SELECT * WHERE {
    VALUES ?inchikey {
        "BUOYQGLRFDDTLB"
        "IOSXSVZRTUWBHC"
    }
    SERVICE wikibase:mwapi {
        bd:serviceParam wikibase:endpoint "www.wikidata.org";
        wikibase:api "Search";
        mwapi:srsearch ?inchikey.
        ?item wikibase:apiOutput mwapi:title.
    }
}
LIMIT 1000

graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v1("?inchikey"):::projected 
  v2("?item"):::projected 
  c4(["www.wikidata.org"]):::literal 
  c2([http://www.bigdata.com/rdf#serviceParam]):::iri 
  c6(["Search"]):::literal 
  c9([https://www.mediawiki.org/ontology#API/title]):::iri 
  bind0[/VALUES ?inchikey/]
  bind0-->v1
  bind00(["BUOYQGLRFDDTLB"])
  bind00 --> bind0
  bind01(["IOSXSVZRTUWBHC"])
  bind01 --> bind0
  subgraph s1["http://wikiba.se/ontology#mwapi"]
    style s1 stroke-width:4px;
    c2 --"wikibase:endpoint"-->  c4
    c2 --"wikibase:api"-->  c6
    c2 --https://www.mediawiki.org/ontology#API/srsearch-->  v1
    v2 --"wikibase:apiOutput"-->  c9
  end