sparql-examples

A set of SPARQL examples that are used in different SIB resources

View the Project on GitHub sib-swiss/sparql-examples

001

Among the SIRIUS structural annotations from Tabernaemontana coffeoides (Apocynaceae) seeds extract, which ones are reported in the Tabernaemontana genus?

Use at

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX sosa: <http://www.w3.org/ns/sosa/>
PREFIX emi: <https://purl.org/emi#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX pr: <http://www.wikidata.org/prop/reference/>

SELECT DISTINCT ?ik2d ?genus
WHERE
    {
    ?material sosa:hasSample ?extract ;
        sosa:isSampleOf ?organe .
    ?organe emi:inTaxon ?wd_sp .
    ?wd_sp rdfs:label "tabernaemontana coffeoides" .
    ?extract sosa:isFeatureOfInterestOf ?lcms .
    ?lcms sosa:hasResult ?feature_list .
    ?feature_list emi:hasLCMSFeature ?feature .
    ?feature emi:hasAnnotation ?sirius_annotation .
    ?sirius_annotation a emi:StructuralAnnotation ;
        prov:wasGeneratedBy ?activity ;
        emi:hasChemicalStructure ?ik2d .
    ?activity prov:wasAssociatedWith <https://bio.informatik.uni-jena.de/software/sirius> .
    ?ik2d emi:hasSMILES ?smiles ;
        emi:isInChIKey2DOf ?ik .
    ?ik emi:isInChIKeyOf ?wd_id .
	{
        SELECT DISTINCT ?wd_id ?genus WHERE {
            ?material sosa:hasSample ?extract ;
                sosa:isSampleOf ?organe .
            ?organe emi:inTaxon ?wd_sp .
            ?wd_sp rdfs:label "tabernaemontana coffeoides" .
            OPTIONAL {
                SERVICE <https://query.wikidata.org/sparql> {
                    ?wd_sp wdt:P225 ?species_name .
                    ?genus wdt:P31 wd:Q16521 ;
                        wdt:P105 wd:Q34740 ;
                        ^wdt:P171* ?wd_sp .
                    ?childtaxa wdt:P171* ?genus .
                    ?wd_id wdt:P703 ?childtaxa
                }
            }
        }
    }
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v9("?activity")
  v16("?childtaxa")
  v2("?extract")
  v7("?feature")
  v6("?feature_list")
  v15("?genus"):::projected 
  v12("?ik")
  v10("?ik2d"):::projected 
  v5("?lcms")
  v1("?material")
  v3("?organe")
  v8("?sirius_annotation")
  v11("?smiles")
  v14("?species_name")
  v13("?wd_id")
  v4("?wd_sp")
  c24(["wd:Q34740"]):::iri 
  c11(["emi:StructuralAnnotation"]):::iri 
  c5(["tabernaemontana coffeoides"]):::literal 
  c15([https://bio.informatik.uni-jena.de/software/sirius]):::iri 
  c22(["wd:Q16521"]):::iri 
  v1 --"sosa:hasSample"-->  v2
  v1 --"sosa:isSampleOf"-->  v3
  v3 --"emi:inTaxon"-->  v4
  v4 --"rdfs:label"-->  c5
  v2 --"sosa:isFeatureOfInterestOf"-->  v5
  v5 --"sosa:hasResult"-->  v6
  v6 --"emi:hasLCMSFeature"-->  v7
  v7 --"emi:hasAnnotation"-->  v8
  v8 --"a"-->  c11
  v8 --http://www.w3.org/ns/prov#wasGeneratedBy-->  v9
  v8 --"emi:hasChemicalStructure"-->  v10
  v9 --http://www.w3.org/ns/prov#wasAssociatedWith-->  c15
  v10 --"emi:hasSMILES"-->  v11
  v10 --"emi:isInChIKey2DOf"-->  v12
  v12 --"emi:isInChIKeyOf"-->  v13
  v1 --"sosa:hasSample"-->  v2
  v1 --"sosa:isSampleOf"-->  v3
  v3 --"emi:inTaxon"-->  v4
  v4 --"rdfs:label"-->  c5
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    subgraph s1["https://query.wikidata.org/sparql"]
      style s1 stroke-width:4px;
      v4 -."wdt:P225".->  v14
      v15 --"wdt:P31"-->  c22
      v15 --"wdt:P105"-->  c24
      v4 --"wdt:P171"-->  v15
      v16 --"wdt:P171"-->  v15
      v13 --"wdt:P703"-->  v16
    end
  end