sparql-examples

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

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

examples021

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 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 emi: <https://purl.org/emi#>
PREFIX sosa: <http://www.w3.org/ns/sosa/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX wgs: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX prov: <http://www.w3.org/ns/prov#>

SELECT DISTINCT ?sourceWD ?sourceNameURI ?intxnName ?targetWD ?targetNameURI ?loc WHERE {
	?intxn emi:hasSource ?xOrg ;				 #retrieve interaction-pairs
               emi:hasTarget ?yOrg ;
	       emi:isClassifiedWith ?intxnName ;
	       prov:atLocation ?loc .				 #retrieve location of interactions
	?xOrg emi:inTaxon ?sourceWD ;				 #retrieve interaction-source and its scientific name as listed in GloBI
	      sosa:isSampleOf ?sourceName .
	?yOrg emi:inTaxon ?targetWD ;				 #retrieve interaction-target and its scientific name as listed in GloBI
	      sosa:isSampleOf ?targetName .

        { SELECT DISTINCT ?targetWD ?wd_chem WHERE {		#retrieve metabolites
	        ?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 }
	}}
	BIND(REPLACE(STR(?sourceName), "%20", " ") AS ?sourceNameX)	#remove percent encodings of source and target scientific names
	BIND(IRI(?sourceNameX) AS ?sourceNameURI)
	BIND(REPLACE(STR(?targetName), "%20", " ") AS ?targetNameX)
	BIND(IRI(?targetNameX) AS ?targetNameURI)
} 

graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v11("?extract")
  v15("?feature")
  v14("?feature_list")
  v19("?ik")
  v17("?ik2d")
  v1("?intxn")
  v4("?intxnName"):::projected 
  v13("?lcms")
  v5("?loc"):::projected 
  v10("?material")
  v12("?organe")
  v16("?sirius_annotation")
  v18("?smiles")
  v7("?sourceName")
  v22("?sourceNameURI"):::projected 
  v21("?sourceNameX")
  v6("?sourceWD"):::projected 
  v9("?targetName")
  v24("?targetNameURI"):::projected 
  v23("?targetNameX")
  v8("?targetWD"):::projected 
  v21("?wd_chem")
  v2("?xOrg")
  v3("?yOrg")
  c13(["emi:StructuralAnnotation"]):::iri 
  v1 --"emi:hasSource"-->  v2
  v1 --"emi:hasTarget"-->  v3
  v1 --"emi:isClassifiedWith"-->  v4
  v1 --"prov:atLocation"-->  v5
  v2 --"emi:inTaxon"-->  v6
  v2 --"sosa:isSampleOf"-->  v7
  v3 --"emi:inTaxon"-->  v8
  v3 --"sosa:isSampleOf"-->  v9
  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;
      v21 --"wdt:P235"-->  v19
      v21 --"wdt:P703"-->  v8
      bind0[/VALUES ?wd_chem/]
      bind0-->v21
      bind00(["wd:Q27107580"])
      bind00 --> bind0
    end
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    v10 --"sosa:hasSample"-->  v11
    v10 --"sosa:isSampleOf"-->  v12
    v12 --"emi:inTaxon"-->  v8
    v11 --"sosa:isFeatureOfInterestOf"-->  v13
    v13 --"sosa:hasResult"-->  v14
    v14 --"emi:hasLCMSFeature"-->  v15
    v15 --"emi:hasAnnotation"-->  v16
    v16 --"a"-->  c13
    v16 --"emi:hasChemicalStructure"-->  v17
    v17 --"emi:hasSMILES"-->  v18
    v17 --"emi:isInChIKey2DOf"-->  v19
    v19 --"emi:isInChIKeyOf"-->  v21
    bind1[/VALUES ?wd_chem/]
    bind1-->v21
    bind10(["wd:Q27107580"])
    bind10 --> bind1
  end
  union0r <== or ==> union0l
  end
  bind2[/"replace(str(?sourceName),'%20',' ')"/]
  v7 --o bind2
  bind2 --as--o v21
  bind3[/"?sourceNameX"/]
  v21 --o bind3
  bind3 --as--o v22
  bind4[/"replace(str(?targetName),'%20',' ')"/]
  v9 --o bind4
  bind4 --as--o v23
  bind5[/"?targetNameX"/]
  v23 --o bind5
  bind5 --as--o v24