sparql-examples

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

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

examples020

rq turtle/ttl

Natural producers (and their interactions that might be useful in agriculture) of Onpordopicrin (wd:Q27107580), which might exhibit antimicrobial and cytotoxic activities, especially against human-derived macrophages and against epidermoid carcinoma cells. There is limited scientific evidence to support these claims (https://www.sciencedirect.com/science/article/abs/pii/S138614251500685X).

Use at

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX emi: <https://purl.org/emi#>
PREFIX sosa: <http://www.w3.org/ns/sosa/>
PREFIX wgs: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX prov: <http://www.w3.org/ns/prov#>
SELECT DISTINCT ?sourceWD ?sourceName ?intxnName ?targetWD ?targetName ?loc WHERE {
	# trait data
	?intxn emi:hasSource ?xOrg ; # retrieve interaction-pairs
        	emi:hasTarget ?yOrg ;
		emi:isClassifiedWith ?intxnName ;
		prov:atLocation ?loc ; # retrieve location, latitude and longitude of interactions
		wgs:lat ?lats ;					
		wgs:long ?longs .
	?xOrg emi:inTaxon ?sourceWD ; # retrieve interaction-source and its scientific name as listed in GloBI
		rdfs:label ?sourceName ;
		sosa:isSampleOf ?sourceSample .
	?yOrg emi:inTaxon ?targetWD ; # retrieve interaction-target and its scientific name as listed in GloBI
		rdfs:label ?targetName ;
		sosa:isSampleOf ?targetSample .

	# metabolite data
        { 
		SELECT DISTINCT ?targetWD ?wd_chem WHERE {		
			?material sosa:hasSample ?extract ;
                        	sosa:isSampleOf ?organe .
                	?organe emi:inTaxon ?targetWD .	# filter by target wikidata-id
                	?extract sosa:isFeatureOfInterestOf ?lcms .
                	?lcms sosa:hasResult ?feature_list .
                	?feature_list emi:hasLCMSFeature ?feature .
                	?feature emi:hasAnnotation ?sirius_annotation .
                	?sirius_annotation a emi:StructuralAnnotation ;
	                	emi:hasChemicalStructure ?ik2d .
                	?ik2d emi:hasSMILES ?smiles ;
                      		emi:isInChIKey2DOf ?ik .
                	?ik emi:isInChIKeyOf ?wd_chem .
                	VALUES ?wd_chem { wd:Q27107580 } # filter on the wikidata-id of Onpordopicrin
		}
	} UNION	# union with the lotus metabolite data from wikidata
	{ 
		SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
			?wd_chem wdt:P235 ?ik ;
   				wdt:P703 ?targetWD .
		 	VALUES ?wd_chem { wd:Q27107580 }
		}
	}
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v15("?extract")
  v19("?feature")
  v18("?feature_list")
  v23("?ik")
  v21("?ik2d")
  v1("?intxn")
  v4("?intxnName"):::projected 
  v6("?lats")
  v17("?lcms")
  v5("?loc"):::projected 
  v7("?longs")
  v14("?material")
  v16("?organe")
  v20("?sirius_annotation")
  v22("?smiles")
  v9("?sourceName"):::projected 
  v10("?sourceSample")
  v8("?sourceWD"):::projected 
  v12("?targetName"):::projected 
  v13("?targetSample")
  v11("?targetWD"):::projected 
  v25("?wd_chem")
  v2("?xOrg")
  v3("?yOrg")
  c16(["emi:StructuralAnnotation"]):::iri 
  v1 --"emi:hasSource"-->  v2
  v1 --"emi:hasTarget"-->  v3
  v1 --"emi:isClassifiedWith"-->  v4
  v1 --"prov:atLocation"-->  v5
  v1 --"wgs:lat"-->  v6
  v1 --"wgs:long"-->  v7
  v2 --"emi:inTaxon"-->  v8
  v2 --"rdfs:label"-->  v9
  v2 --"sosa:isSampleOf"-->  v10
  v3 --"emi:inTaxon"-->  v11
  v3 --"rdfs:label"-->  v12
  v3 --"sosa:isSampleOf"-->  v13
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    subgraph s1["https://qlever.cs.uni-freiburg.de/api/wikidata"]
      style s1 stroke-width:4px;
      v25 --"wdt:P235"-->  v23
      v25 --"wdt:P703"-->  v11
      bind0[/VALUES ?wd_chem/]
      bind0-->v25
      bind00(["wd:Q27107580"])
      bind00 --> bind0
    end
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    v14 --"sosa:hasSample"-->  v15
    v14 --"sosa:isSampleOf"-->  v16
    v16 --"emi:inTaxon"-->  v11
    v15 --"sosa:isFeatureOfInterestOf"-->  v17
    v17 --"sosa:hasResult"-->  v18
    v18 --"emi:hasLCMSFeature"-->  v19
    v19 --"emi:hasAnnotation"-->  v20
    v20 --"a"-->  c16
    v20 --"emi:hasChemicalStructure"-->  v21
    v21 --"emi:hasSMILES"-->  v22
    v21 --"emi:isInChIKey2DOf"-->  v23
    v23 --"emi:isInChIKeyOf"-->  v25
    bind1[/VALUES ?wd_chem/]
    bind1-->v25
    bind10(["wd:Q27107580"])
    bind10 --> bind1
  end
  union0r <== or ==> union0l
  end