A set of SPARQL examples that are used in different SIB resources
Which samples have features annotated as Aspidosperma_type alkaloids by CANOPUS with a probability score above 0.5, ordered by the decreasing count of features?
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX emi: <https://purl.org/emi#>
PREFIX sosa: <http://www.w3.org/ns/sosa/>
SELECT ?extract ?organe ?species_name ?genus_name ?family_name ?count_of_selected_class
WHERE {
?material sosa:hasSample ?extract ;
sosa:isSampleOf ?organe .
?organe emi:inTaxon ?wd_sp .
#OPTIONAL {
SERVICE <https://query.wikidata.org/sparql> {
?wd_sp wdt:P225 ?species_name .
?family wdt:P31 wd:Q16521 ;
wdt:P105 wd:Q35409 ;
wdt:P225 ?family_name ;
^wdt:P171* ?wd_sp .
?genus wdt:P31 wd:Q16521 ;
wdt:P105 wd:Q34740 ;
wdt:P225 ?genus_name ;
^wdt:P171* ?wd_sp .
}
#}
{
SELECT ?extract (COUNT(DISTINCT ?feature) AS ?count_of_selected_class)
WHERE {
?extract a emi:ExtractSample ;
sosa:isFeatureOfInterestOf ?lcms .
?lcms a emi:LCMSAnalysis ;
emi:hasLCMSFeatureSet ?feature_list .
?feature_list emi:hasLCMSFeature ?feature .
?feature emi:hasAnnotation ?canopus .
?canopus a emi:ChemicalTaxonAnnotation ;
emi:hasClass ?np_class ;
emi:hasClassProbability ?class_prob .
?np_class rdfs:label "Aspidosperma type" .
FILTER((?class_prob > 0.5)) .
} GROUP BY ?extract ORDER BY DESC(?count_of_selected_class)
}
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v15("?canopus")
v11("?class_prob")
v17("?count_of_selected_class"):::projected
v2("?extract"):::projected
v6("?family")
v7("?family_name"):::projected
v14("?feature")
v13("?feature_list")
v8("?genus")
v9("?genus_name"):::projected
v12("?lcms")
v1("?material")
v16("?np_class")
v3("?organe"):::projected
v5("?species_name"):::projected
v4("?wd_sp")
c20(["emi:ChemicalTaxonAnnotation"]):::iri
c9(["wd:Q35409"]):::iri
c14(["emi:ExtractSample"]):::iri
c16(["emi:LCMSAnalysis"]):::iri
c11(["wd:Q34740"]):::iri
c24(["Aspidosperma type"]):::literal
c7(["wd:Q16521"]):::iri
v1 --"sosa:hasSample"--> v2
v1 --"sosa:isSampleOf"--> v3
v3 --"emi:inTaxon"--> v4
subgraph s1["https://query.wikidata.org/sparql"]
style s1 stroke-width:4px;
v4 --"wdt:P225"--> v5
v6 --"wdt:P31"--> c7
v6 --"wdt:P105"--> c9
v6 --"wdt:P225"--> v7
v4 --"wdt:P171"--> v6
v8 --"wdt:P31"--> c7
v8 --"wdt:P105"--> c11
v8 --"wdt:P225"--> v9
v4 --"wdt:P171"--> v8
end
f0[["?class_prob > '0.5^^xsd:decimal'"]]
f0 --> v11
v2 --"a"--> c14
v2 --"sosa:isFeatureOfInterestOf"--> v12
v12 --"a"--> c16
v12 --"emi:hasLCMSFeatureSet"--> v13
v13 --"emi:hasLCMSFeature"--> v14
v14 --"emi:hasAnnotation"--> v15
v15 --"a"--> c20
v15 --"emi:hasClass"--> v16
v15 --"emi:hasClassProbability"--> v11
v16 --"rdfs:label"--> c24
bind2[/"count(?feature)"/]
v14 --o bind2
bind2 --as--o v17