lotus-sparql-examples

A set of SPARQL examples that are used in LOTUS

View the Project on GitHub lotusnprod/lotus-sparql-examples

wd_nps_simillarity_antibiotics

rq turtle/ttl

Compounds structurally similar to compounds labeled as antibiotics grouped by parent taxon.

Use at


PREFIX hint: <http://www.bigdata.com/queryHints#>
PREFIX idsm: <https://idsm.elixir-czech.cz/sparql/endpoint/>
PREFIX sachem: <http://bioinfo.uochb.cas.cz/rdf/v1.0/sachem#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
#title: Compounds structurally similar to compounds labeled as antibiotics grouped by parent taxon.
SELECT ?parent_taxon ?parent_taxon_name (COUNT(DISTINCT ?compound) AS ?count) WHERE {
    SERVICE idsm:wikidata {
        VALUES ?CUTOFF {
            "0.9"^^xsd:double
        }
        SERVICE <https://query.wikidata.org/bigdata/namespace/wdq/sparql> {
            VALUES ?MESH {
                "D000900"
            }
            ?antibiotic ((wdt:P279*)/wdt:P2868/wdt:P486) ?MESH;
            wdt:P233 ?smiles.
        }
        ?compound sachem:similarCompoundSearch[
        sachem:query ?smiles;
        sachem:cutoff ?CUTOFF
        ].
    } hint:Prior hint:runFirst true.
    ?compound wdt:P703/wdt:P171 ?parent_taxon.
    ?parent_taxon wdt:P225 ?parent_taxon_name.
}
GROUP BY ?parent_taxon ?parent_taxon_name
ORDER BY DESC (?count)

graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v2("?CUTOFF")
  v3("?MESH")
  v4("?antibiotic")
  v6("?compound"):::projected 
  v9("?count")
  v7("?parent_taxon"):::projected 
  v8("?parent_taxon_name"):::projected 
  v5("?smiles")
  a1((" "))
  a2((" "))
  a3((" "))
  a4((" "))
  c10([http://www.bigdata.com/queryHints#Prior]):::iri 
  c12(["true^^xsd:boolean"]):::literal 
  subgraph s1["https://idsm.elixir-czech.cz/sparql/endpoint/wikidata"]
    style s1 stroke-width:4px;
    bind0[/VALUES ?CUTOFF/]
    bind0-->v2
    bind00(["0.9^^xsd:double"])
    bind00 --> bind0
    subgraph s2["https://query.wikidata.org/bigdata/namespace/wdq/sparql"]
      style s2 stroke-width:4px;
      bind1[/VALUES ?MESH/]
      bind1-->v3
      bind10(["D000900"])
      bind10 --> bind1
      v4 --"wdt:P279"-->  a1
      a1 --"wdt:P2868"-->  a2
      a2 --"wdt:P486"-->  v3
      v4 --"wdt:P233"-->  v5
    end
    a3 --"sachem:query"-->  v5
    a3 --"sachem:cutoff"-->  v2
    v6 --"sachem:similarCompoundSearch"-->  a3
  end
  c10 --http://www.bigdata.com/queryHints#runFirst-->  c12
  v6 --"wdt:P703"-->  a4
  a4 --"wdt:P171"-->  v7
  v7 --"wdt:P225"-->  v8
  bind3[/"count(?compound)"/]
  v6 --o bind3
  bind3 --as--o v9