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_grampos

rq turtle/ttl

Parent taxa containing the most compounds similar to compounds treating gram-positive infections (Q55789782).

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 wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
#title: Parent taxa containing the most compounds similar to compounds treating gram-positive infections (Q55789782).
SELECT DISTINCT ?parent_taxon ?parent_taxon_name (COUNT(DISTINCT ?compound) AS ?count) WHERE {
    SERVICE idsm:wikidata {
        VALUES ?CUTOFF {
            "0.85"^^xsd:double
        }
        SERVICE <https://query.wikidata.org/bigdata/namespace/wdq/sparql> {
            VALUES ?disease {
                wd:Q55789782
            }
            ?infection (wdt:P279*) ?disease.
            { ?compound wdt:P2175 ?infection. }
            UNION
            { ?infection wdt:P2176 ?compound. }
            ?compound wdt:P233 ?compound_smiles;
            wdt:P703 ?taxon.
        }
        ?compound sachem:similarCompoundSearch [
        sachem:query ?compound_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")
  v5("?compound"):::projected 
  v6("?compound_smiles")
  v10("?count")
  v3("?disease")
  v4("?infection")
  v8("?parent_taxon"):::projected 
  v9("?parent_taxon_name"):::projected 
  v7("?taxon")
  a1((" "))
  a2((" "))
  c11([http://www.bigdata.com/queryHints#Prior]):::iri 
  c13(["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.85^^xsd:double"])
    bind00 --> bind0
    subgraph s2["https://query.wikidata.org/bigdata/namespace/wdq/sparql"]
      style s2 stroke-width:4px;
      bind1[/VALUES ?disease/]
      bind1-->v3
      bind10(["wd:Q55789782"])
      bind10 --> bind1
      v4 --"wdt:P279"-->  v3
      subgraph union0[" Union "]
      subgraph union0l[" "]
        style union0l fill:#abf,stroke-dasharray: 3 3;
        v4 --"wdt:P2176"-->  v5
      end
      subgraph union0r[" "]
        style union0r fill:#abf,stroke-dasharray: 3 3;
        v5 --"wdt:P2175"-->  v4
      end
      union0r <== or ==> union0l
      end
      v5 --"wdt:P233"-->  v6
      v5 --"wdt:P703"-->  v7
    end
    a1 --"sachem:query"-->  v6
    a1 --"sachem:cutoff"-->  v2
    v5 --"sachem:similarCompoundSearch"-->  a1
  end
  c11 --http://www.bigdata.com/queryHints#runFirst-->  c13
  v5 --"wdt:P703"-->  a2
  a2 --"wdt:P171"-->  v8
  v8 --"wdt:P225"-->  v9
  bind3[/"count(?compound)"/]
  v5 --o bind3
  bind3 --as--o v10