A set of SPARQL examples that are used in LOTUS
Species containing at least n of the following compounds.
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: Species containing at least n of the following compounds.
SELECT DISTINCT ?taxon ?taxon_name WHERE {
VALUES ?n {4}
{
SELECT ?taxon ?taxon_name (COUNT(DISTINCT ?compound) AS ?compoundCount) WHERE {
{
SELECT DISTINCT ?taxon ?taxon_name ?compound WHERE {
{
SELECT DISTINCT ?compound ?smiles WHERE {
SERVICE idsm:wikidata {
VALUES ?smiles {
"C=C[C@H]1[C@@H](OC=C2C1=CCOC2=O)O[C@H]3[C@@H]([C@H]([C@@H]([C@H](O3)CO)O)O)O"
"C=C[C@H]1[C@@H](OC=C2[C@]1(CCOC2=O)O)O[C@H]3[C@@H]([C@H]([C@@H]([C@H](O3)CO)O)O)O"
"C=C[C@@H]1[C@@H]2CCOC(=O)C2=CO[C@H]1O[C@H]3[C@@H]([C@H]([C@@H]([C@H](O3)CO)O)O)OC(=O)C4=C(C=C(C=C4O)O)O"
"COC1=CC(=C2C(=C1)OC3=C(C=CC(=C3C2=O)O[C@H]4[C@@H]([C@H]([C@@H]([C@H](O4)CO)O)O)O)O)O"
}
?compound sachem:similarCompoundSearch [
sachem:query ?smiles;
sachem:cutoff "1.0"^^xsd:double
].
}
}
} hint:Prior hint:runFirst "true".
?compound wdt:P703 ?child.
?child (wdt:P171*) ?taxon.
?taxon wdt:P225 ?taxon_name;
wdt:P105 ?taxon_rank.
FILTER(?taxon_rank = wd:Q7432)
}
}
}
GROUP BY ?taxon ?taxon_name
}
FILTER((xsd:integer(?compoundCount)) >= ?n)
}
LIMIT 10000
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?child")
v5("?compound")
v9("?compoundCount")
v3("?n")
v4("?smiles")
v7("?taxon"):::projected
v8("?taxon_name"):::projected
v3("?taxon_rank")
a1((" "))
c7([http://www.bigdata.com/queryHints#Prior]):::iri
c5(["1.0^^xsd:double"]):::literal
c9(["true"]):::literal
f0[["http://www.w3.org/2001/XMLSchema#integer(?compoundCount) >= ?n"]]
f0 --> v9
f0 --> v3
bind1[/VALUES ?n/]
bind1-->v3
bind10(["4^^xsd:integer"])
bind10 --> bind1
f2[["?taxon_rank = 'wd:Q7432'"]]
f2 --> v3
subgraph s1["https://idsm.elixir-czech.cz/sparql/endpoint/wikidata"]
style s1 stroke-width:4px;
bind3[/VALUES ?smiles/]
bind3-->v4
bind30(["C=C#91;C@H#93;1#91;C@@H#93;(OC=C2C1=CCOC2=O)O#91;C@H#93;3#91;C@@H#93;(#91;C@H#93;(#91;C@@H#93;(#91;C@H#93;(O3)CO)O)O)O"])
bind30 --> bind3
bind31(["C=C#91;C@H#93;1#91;C@@H#93;(OC=C2#91;C@#93;1(CCOC2=O)O)O#91;C@H#93;3#91;C@@H#93;(#91;C@H#93;(#91;C@@H#93;(#91;C@H#93;(O3)CO)O)O)O"])
bind31 --> bind3
bind32(["C=C#91;C@@H#93;1#91;C@@H#93;2CCOC(=O)C2=CO#91;C@H#93;1O#91;C@H#93;3#91;C@@H#93;(#91;C@H#93;(#91;C@@H#93;(#91;C@H#93;(O3)CO)O)O)OC(=O)C4=C(C=C(C=C4O)O)O"])
bind32 --> bind3
bind33(["COC1=CC(=C2C(=C1)OC3=C(C=CC(=C3C2=O)O#91;C@H#93;4#91;C@@H#93;(#91;C@H#93;(#91;C@@H#93;(#91;C@H#93;(O4)CO)O)O)O)O)O"])
bind33 --> bind3
a1 --"sachem:query"--> v4
a1 --"sachem:cutoff"--> c5
v5 --"sachem:similarCompoundSearch"--> a1
end
c7 --http://www.bigdata.com/queryHints#runFirst--> c9
v5 --"wdt:P703"--> v6
v6 --"wdt:P171"--> v7
v7 --"wdt:P225"--> v8
v7 --"wdt:P105"--> v3
bind5[/"count(?compound)"/]
v5 --o bind5
bind5 --as--o v9