sparql-examples

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

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

007

Show chemical structures in Melochia umbellata extracts with structural annotations where the cosmic score is greater than 0.5 and the zodiac score is less than 0.8. For ISDB annotations, consider taxon scores greater than or equal to 6

Use at

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 DISTINCT ?ik ?wd_id ?taxon ?taxon_name
WHERE { 
    {SELECT  ?ik ?wd_id
        WHERE {
            ?sample a emi:ExtractSample ;
                sosa:isSampleOf* ?organe ;
                sosa:isFeatureOfInterestOf ?lcms .
            ?organe emi:inTaxon ?taxon .
            ?taxon rdfs:label "melochia umbellata" .
            ?lcms a emi:LCMSAnalysisPos ;
                sosa:hasResult ?feature_list .
            ?feature_list emi:hasLCMSFeature ?feature .
            {
                ?feature emi:hasAnnotation ?annotation .
                ?annotation a emi:StructuralAnnotation ;
                    prov:wasGeneratedBy ?activity .
                ?activity prov:wasAssociatedWith <https://bio.informatik.uni-jena.de/software/sirius> .
                ?annotation emi:hasCosmicScore ?cosmic ;
                    emi:hasZodiacScore ?zodiac .
                FILTER((?cosmic > 0.5) && (?zodiac > 0.8))
            } UNION {
                ?feature emi:hasAnnotation ?annotation .
                ?annotation emi:hasTaxoScore ?taxo .
                FILTER(?taxo >= 6)
            }
            ?annotation emi:hasChemicalStructure ?ik2d .
            ?ik2d emi:hasSMILES ?smiles ;
                emi:isInChIKey2DOf ?ik .
            ?ik emi:isInChIKeyOf ?wd_id .
        } LIMIT 50
    }
  SERVICE <https://query.wikidata.org/sparql> {
        ?wd_id wdt:P31 wd:Q113145171 ;
            wdt:P703 ?taxon .
        ?taxon wdt:P225 ?taxon_name .
    }
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v10("?activity")
  v9("?annotation")
  v7("?cosmic")
  v6("?feature")
  v5("?feature_list")
  v14("?ik"):::projected 
  v12("?ik2d")
  v3("?lcms")
  v2("?organe")
  v1("?sample")
  v13("?smiles")
  v11("?taxo")
  v4("?taxon"):::projected 
  v16("?taxon_name"):::projected 
  v15("?wd_id"):::projected 
  v8("?zodiac")
  c7(["melochia umbellata"]):::literal 
  c14(["emi:StructuralAnnotation"]):::iri 
  c8(["emi:LCMSAnalysisPos"]):::iri 
  c28(["wd:Q113145171"]):::iri 
  c17([https://bio.informatik.uni-jena.de/software/sirius]):::iri 
  c2(["emi:ExtractSample"]):::iri 
  v1 --"a"-->  c2
  v1 --"sosa:isSampleOf"-->  v2
  v1 --"sosa:isFeatureOfInterestOf"-->  v3
  v2 --"emi:inTaxon"-->  v4
  v4 --"rdfs:label"-->  c7
  v3 --"a"-->  c8
  v3 --"sosa:hasResult"-->  v5
  v5 --"emi:hasLCMSFeature"-->  v6
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    f0[["?taxo >= '6^^xsd:integer'"]]
    f0 --> v11
    v6 --"emi:hasAnnotation"-->  v9
    v9 --"emi:hasTaxoScore"-->  v11
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    f1[["?cosmic > '0.5^^xsd:decimal'?zodiac > '0.8^^xsd:decimal'"]]
    f1 --> v7
    f1 --> v8
    v6 --"emi:hasAnnotation"-->  v9
    v9 --"a"-->  c14
    v9 --"prov:wasGeneratedBy"-->  v10
    v10 --"prov:wasAssociatedWith"-->  c17
    v9 --"emi:hasCosmicScore"-->  v7
    v9 --"emi:hasZodiacScore"-->  v8
  end
  union0r <== or ==> union0l
  end
  v9 --"emi:hasChemicalStructure"-->  v12
  v12 --"emi:hasSMILES"-->  v13
  v12 --"emi:isInChIKey2DOf"-->  v14
  v14 --"emi:isInChIKeyOf"-->  v15
  subgraph s1["https://query.wikidata.org/sparql"]
    style s1 stroke-width:4px;
    v15 --"wdt:P31"-->  c28
    v15 --"wdt:P703"-->  v4
    v4 --"wdt:P225"-->  v16
  end