query-782eebc84c309b460edda843aea47aa1

rq turtle/ttl

TODO

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?compound ?compoundLabel ?canonical_smiles (GROUP_CONCAT(CONCAT(?sourceLabel, IF(BOUND(?publicationDate), CONCAT(", ", STR(?publicationDate)), "")); separator = ";\n") AS ?sources) WHERE  {
  ?compound p:P233 ?statement.
  ?statement ps:P233 ?canonical_smiles.
  OPTIONAL {
    ?statement prov:wasDerivedFrom/pr:P248 ?source.
    OPTIONAL {
      ?source wdt:P577 ?publicationDate.
    }
  }
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en".
    ?compound rdfs:label ?compoundLabel.
    ?source rdfs:label ?sourceLabel.
  }
}
GROUP BY ?compound ?compoundLabel ?canonical_smiles

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?canonical_smiles"):::projected v1("?compound"):::projected v6("?compoundLabel"):::projected v5("?publicationDate"):::projected v4("?source") v7("?sourceLabel"):::projected v8("?sources") v2("?statement") a1((" ")) c7(["bd:serviceParam"]):::iri c9(["en"]):::literal v1 --"p:P233"--> v2 v2 --"p:statement/P233"--> v3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."prov:wasDerivedFrom".-> a1 a1 --"p:reference/P248"--> v4 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P577".-> v5 end end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 v1 --"rdfs:label"--> v6 v4 --"rdfs:label"--> v7 end bind1[/"concat(?sourceLabel,if(bound(?publicationDate),concat(', ',str(?publicationDate)),''))"/] v7 --o bind1 v5 --o bind1 bind1 --as--o v8