sparql-examples

SPARQL examples for the EMI

View the Project on GitHub earth-metabolome-initiative/sparql-examples

3

rq turtle/ttl

Among the structural annotations in Tabernaemontana coffeoides seeds extract, get the ones that contain an Aspidospermidine scaffold scaffold.

Use at

PREFIX enpkg: <https://enpkg.commons-lab.org/kg/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX idsm: <https://idsm.elixir-czech.cz/sparql/endpoint/>
PREFIX sachem: <http://bioinfo.uochb.cas.cz/rdf/v1.0/sachem#>

SELECT DISTINCT ?ik2d ?smiles
WHERE
    { 
    ?extract rdf:type enpkg:LabExtract .
    FILTER(regex(str(?extract), "VGF152_B02")) # Tabernaemontana coffeoides seeds extract
        ?extract enpkg:has_LCMS ?lcms .
            ?lcms enpkg:has_lcms_feature_list ?feature_list .
            ?feature_list enpkg:has_lcms_feature ?feature .
                ?feature enpkg:has_sirius_annotation|enpkg:has_isdb_annotation ?annotation . 
                ?annotation enpkg:has_InChIkey2D ?ik2d .
                    ?ik2d enpkg:has_smiles ?smiles .
                    ?ik2d enpkg:is_InChIkey2D_of ?ik .
                        ?ik enpkg:has_wd_id ?wd_id .
                        SERVICE idsm:wikidata {
                            VALUES ?SUBSTRUCTURE {
                            "CCC12CCCN3C1C4(CC3)C(CC2)NC5=CC=CC=C45" # Aspidospermidine scaffold
                            }
                            ?wd_id sachem:substructureSearch _:b16.
                            _:b16 sachem:query ?SUBSTRUCTURE.
                        }      
    }
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v10("?SUBSTRUCTURE")
  v5("?annotation")
  v1("?extract")
  v4("?feature")
  v3("?feature_list")
  v8("?ik")
  v6("?ik2d"):::projected 
  v2("?lcms")
  v7("?smiles"):::projected 
  v9("?wd_id")
  a1((" "))
  c3(["enpkg:LabExtract"]):::iri 
  f0[["regex(str(?extract),'VGF152_B02')"]]
  f0 --> v1
  v1 --"a"-->  c3
  v1 --"enpkg:has_LCMS"-->  v2
  v2 --"enpkg:has_lcms_feature_list"-->  v3
  v3 --"enpkg:has_lcms_feature"-->  v4
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    v4 --"enpkg:has_isdb_annotation"-->  v5
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    v4 --"enpkg:has_sirius_annotation"-->  v5
  end
  union0r <== or ==> union0l
  end
  v5 --"enpkg:has_InChIkey2D"-->  v6
  v6 --"enpkg:has_smiles"-->  v7
  v6 --"enpkg:is_InChIkey2D_of"-->  v8
  v8 --"enpkg:has_wd_id"-->  v9
  subgraph s1["https://idsm.elixir-czech.cz/sparql/endpoint/wikidata"]
    style s1 stroke-width:4px;
    bind1[/VALUES ?SUBSTRUCTURE/]
    bind1-->v10
    bind10(["CCC12CCCN3C1C4(CC3)C(CC2)NC5=CC=CC=C45"])
    bind10 --> bind1
    v9 --"sachem:substructureSearch"-->  a1
    a1 --"sachem:query"-->  v10
  end