Skip to content

Instantly share code, notes, and snippets.

@egonw
Last active September 11, 2022 10:11
Show Gist options
  • Select an option

  • Save egonw/192f0f0281859897febb7286345af235 to your computer and use it in GitHub Desktop.

Select an option

Save egonw/192f0f0281859897febb7286345af235 to your computer and use it in GitHub Desktop.
SELECT ?smiles
WHERE {
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:endpoint "www.wikidata.org";
wikibase:api "Search";
mwapi:srsearch "haswbstatement:P235 -haswbstatement:P274";
mwapi:srlimit "max".
?cmp wikibase:apiOutputItem mwapi:title.
}
OPTIONAL { ?cmp wdt:P2017 ?isoSmi }
OPTIONAL { ?cmp wdt:P233 ?canSmi }
BIND (COALESCE(?isoSmi, ?canSmi) AS ?smiles)
FILTER (BOUND(?smiles))
MINUS { ?cmp wdt:P31/wdt:P279* wd:Q25276 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment