sparql-examples

A set of SPARQL examples

View the Project on GitHub Adafede/sparql-examples

wd_chemicals_infection_grampos

rq turtle/ttl

Chemicals treating Gram-positive infections.

Use at


PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
#title: What are the chemicals known to treat gram-positive infections (Q55789782)?
SELECT DISTINCT ?structure ?structure_smiles WHERE {
    VALUES ?disease {
        wd:Q55789782   # Gram-positive
        # wd:Q19597369 # Gram-negative
    }
    ?infection (wdt:P279*) ?disease.
    { ?structure wdt:P2175 ?infection. }
    UNION
    { ?infection wdt:P2176 ?structure. }
    ?structure wdt:P233 ?structure_smiles.
}

graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v1("?disease")
  v2("?infection")
  v3("?structure"):::projected 
  v4("?structure_smiles"):::projected 
  bind0[/VALUES ?disease/]
  bind0-->v1
  bind00(["wd:Q55789782"])
  bind00 --> bind0
  v2 --"wdt:P279"-->  v1
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    v2 --"wdt:P2176"-->  v3
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    v3 --"wdt:P2175"-->  v2
  end
  union0r <== or ==> union0l
  end
  v3 --"wdt:P233"-->  v4