Skip to content

Commit

Permalink
Merge pull request #156 from mdrishti/working
Browse files Browse the repository at this point in the history
Add queries for the globi-trydb graph
  • Loading branch information
tarcisiotmf authored Jan 21, 2025
2 parents 628429d + 153ebf5 commit 615f9e9
Show file tree
Hide file tree
Showing 10 changed files with 559 additions and 0 deletions.
47 changes: 47 additions & 0 deletions examples/dbgi/011a.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@prefix ex: <https://purl.org/emi#examples> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix spex:<https://purl.expasy.org/sparql-examples/ontology#> .

ex:011a a sh:SPARQLExecutable,
sh:SPARQLSelectExecutable ;
rdfs:comment "List interactions of all species which have an IUCN status (wdt:P141) of near threatened (wd:Q719675)."@en ;
sh:prefixes _:sparql_examples_prefixes ;
sh:select """PREFIX emi: <https://purl.org/emi#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX sosa: <http://www.w3.org/ns/sosa/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?wdx_Source ?sourceNameURI ?intxnLabel ?intxnType ?wdx_Target ?targetNameURI WHERE {
{ SELECT DISTINCT ?wdx_Target ?targetName ?sourceName ?wdx_Source ?intxnType WHERE { #first select the source-target interaction-pairs
?intxn emi:hasSource ?source ;
emi:hasTarget ?target ;
emi:isClassifiedWith ?intxnType . #unidirectional interaction, e.g.: source-X hosts target target-Y
?intxnType rdfs:label ?intxnLabel .
?source emi:inTaxon ?wdx_Source ; #retrieve wikidata-id for source
sosa:isSampleOf ?sourceName . #scientific name of source as given in GloBI
?target emi:inTaxon ?wdx_Target ; #retrieve wikidata-id for target
sosa:isSampleOf ?targetName . #scientific name of target as given in GloBI
}}
SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
{
?wdx_Source wdt:P141 wd:Q719675 ; #filter source wikidata ids, which have IUCN status (wdt:P141) as near threatened (wd:Q719675) and which is a plant
wdt:P171* wd:Q879246 .
} UNION
{
?wdx_Target wdt:P141 wd:Q719675 ; #filter target wikidata ids, which have IUCN status (wdt:P141) as near threatened (wd:Q719675) and which is a plant
wdt:P171* wd:Q879246 .
}
}
BIND(REPLACE(STR(?sourceName), "%20", " ") AS ?sourceNameX) #remove percent-encoding for scientific names of source-X
BIND(IRI(?sourceNameX) AS ?sourceNameURI)
BIND(REPLACE(STR(?targetName), "%20", " ") AS ?targetNameX) #remove percent-encoding for scientific names of target-Y
BIND(IRI(?targetNameX) AS ?targetNameURI)
}
""" ;
schema:target <https://biosoda.unil.ch/emi/sparql/> ;
spex:federatesWith <https://qlever.cs.uni-freiburg.de/api/wikidata> .
38 changes: 38 additions & 0 deletions examples/dbgi/011b.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@prefix ex: <https://purl.org/emi#examples> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix spex:<https://purl.expasy.org/sparql-examples/ontology#> .

ex:011b a sh:SPARQLExecutable,
sh:SPARQLSelectExecutable ;
rdfs:comment "List interactions and traits of all species which have an IUCN status (wdt:P141) of near threatened (wd:Q719675)."@en ;
sh:prefixes _:sparql_examples_prefixes ;
sh:select """PREFIX emi: <https://purl.org/emi#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX sosa: <http://www.w3.org/ns/sosa/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX qudt: <https://qudt.org/2.1/schema/qudt#>
SELECT DISTINCT ?source_wd ?sourceNameURI ?tryDataLab ?tryDataVal ?unit ?unitComment WHERE {
?trySpObs sosa:isSampleOf ?source_trySpName ; #retrieve trait/non-trait data from trydb for trySpName (scientific name of plant species as listed in trydb)
sosa:isFeatureOfInterestOf ?tryObId .
?source_trySpName emi:inTaxon ?source_wd . #retrieve wikidata-id for trySpName
?tryObId sosa:hasResult ?tryData .
?tryData rdfs:label ?tryDataLab ;
rdf:type emi:Trait ; #filter data which is labelled as "Trait"
rdf:value ?tryDataVal ; #retrieve values for Trait data
qudt:hasUnit ?unit . #retrieve units for Trait data
OPTIONAL {?tryData rdfs:comment ?unitComment .} #retrieve comments (containing original unprocessed unit information - necessary for understanding some data) for Trait data
SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
?source_wd wdt:P141 wd:Q719675 . #filter wikidata-ids for trySpName, which have IUCN status (wdt:P141) as near threatened (wd:Q719675)
}
BIND(REPLACE(STR(?source_trySpName), "%20", " ") AS ?sourceNameX) #remove percent-encoding for trySpName
BIND(IRI(?sourceNameX) AS ?sourceNameURI)
}""" ;
schema:target <https://biosoda.unil.ch/emi/sparql/> ;
spex:federatesWith <https://qlever.cs.uni-freiburg.de/api/wikidata> .
61 changes: 61 additions & 0 deletions examples/dbgi/012.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
@prefix ex: <https://purl.org/emi#examples> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix spex:<https://purl.expasy.org/sparql-examples/ontology#> .

ex:012 a sh:SPARQLExecutable,
sh:SPARQLSelectExecutable ;
rdfs:comment "List all metabolites produced by species with near threatened (wd:Q719675) IUCN status (wdt:P141) and with values available (or greater than a specific value) for trait 'Seed dry mass'."@en ;
sh:prefixes _:sparql_examples_prefixes ;
sh:select """PREFIX emi: <https://purl.org/emi#>
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 sosa: <http://www.w3.org/ns/sosa/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT DISTINCT ?structure_inchikey ?wd_chem ?source_wdx ?sourceNameURI WHERE {
?trySpObs sosa:isSampleOf ?trySpName ; #retrieve trait/non-trait data for trySpName (scientific name of plant species as listed in trydb)
sosa:isFeatureOfInterestOf ?tryObId .
?tryObId sosa:hasResult ?tryData .
?trySpName emi:inTaxon ?source_wdx . #retrieve wikidata-ids wdx for trySpName
?tryData rdfs:label ?tryDataLab ;
rdf:type emi:Trait ; #retrieve data which is labelled as "Trait"
rdf:value ?tryDataVal . #retrieve values for Trait data
FILTER (?tryDataLab = "Seed dry mass" ) #filter on data label 'Seed dry mass'
FILTER (?tryDataVal >= 626) #filter on data value >= 626
SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
?source_wdx wdt:P141 wd:Q719675 . #filter wikidata-ids for trySpName, which have IUCN status (wdt:P141) as near threatened (wd:Q719675)
}
BIND(REPLACE(STR(?trySpName), "%20", " ") AS ?sourceNameX) #remove percent-encoding for scientific names of trySpName
BIND(IRI(?sourceNameX) AS ?sourceNameURI)
{ SELECT ?source_wdx ?structure_inchikey ?wd_chem WHERE { #retrieve metabolite data
?material sosa:hasSample ?extract ;
sosa:isSampleOf ?organe .
?organe emi:inTaxon ?source_wdx . #filter metabolite data which is found in wikidata-ids wdx
?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 ?structure_inchikey .
?structure_inchikey emi:isInChIKeyOf ?wd_chem . #retrieve wikidata-ids for metabolites
}}
UNION #union with data from lotus (integrated in wikidata)
{ SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
?wd_chem wdt:P235 ?structure_inchikey;
wdt:P703 ?source_wdx .
}}
} LIMIT 1000
""" ;
schema:target <https://biosoda.unil.ch/emi/sparql/> ;
spex:federatesWith <https://qlever.cs.uni-freiburg.de/api/wikidata> .

63 changes: 63 additions & 0 deletions examples/dbgi/013.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@prefix ex: <https://purl.org/emi#examples> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix spex:<https://purl.expasy.org/sparql-examples/ontology#> .

ex:013 a sh:SPARQLExecutable,
sh:SPARQLSelectExecutable ;
rdfs:comment "## List traits (and their values) of plants producing Diterpenoids"@en ;
sh:prefixes _:sparql_examples_prefixes ;
sh:select """
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 qudt: <https://qudt.org/2.1/schema/qudt#>
PREFIX npc: <https://purl.org/npc#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT DISTINCT ?source_wdx ?sourceNameURI ?tryDataLab ?tryDataVal ?unit ?unitComment WHERE {
{ SELECT DISTINCT ?source_wdx WHERE { #retrieve metabolite data
?material sosa:hasSample ?extract ;
sosa:isSampleOf ?organe .
?organe emi:inTaxon ?source_wdx . #filter metabolite data which is found in wikidata-ids wdx
?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 ;
emi:hasClass ?npcClass .
?npcClass skos:broader ?npcSuperClass .
?ik emi:isInChIKeyOf ?wd_chem . #retrieve wikidata-ids for metabolites
FILTER (REGEX(STR(?npcSuperClass), "DITERPENOIDS"))
}} UNION #union with data from lotus (integrated in wikidata)
{ SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
?wd_chem wdt:P235 ?structure_inchikey ;
((wdt:P31|wdt:P279)/(wdt:P279*)) wd:Q47006367 ; #check if the class/superclass of the chemical is Diterpenoids
wdt:P703 ?source_wdx .
}}
?trySpName emi:inTaxon ?wdx .
?trySpObs sosa:isSampleOf ?trySpName ; #retrieve trait/non-trait data for trySpName (scientific name of plant species as listed in trydb)
sosa:isFeatureOfInterestOf ?tryObId .
?trySpName emi:inTaxon ?source_wdx . #retrieve wikidata-ids wdx for trySpName
?tryObId sosa:hasResult ?tryData .
?tryData rdfs:label ?tryDataLab ;
rdf:type emi:Trait ; #retrieve data which is labelled as "Trait"
rdf:value ?tryDataVal ; #retrieve values for Trait data
qudt:hasUnit ?unit ; #retrieve units for trait data
rdfs:comment ?unitComment . #retrieve original units for Trait data as listed in trydb
BIND(REPLACE(STR(?trySpName), "%20", " ") AS ?sourceNameX) #remove percent-encoding for scientific names of trySpName
BIND(IRI(?sourceNameX) AS ?sourceNameURI)
}
""" ;
schema:target <https://biosoda.unil.ch/emi/sparql/> ;
spex:federatesWith <https://qlever.cs.uni-freiburg.de/api/wikidata> .
63 changes: 63 additions & 0 deletions examples/dbgi/015.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@prefix ex: <https://purl.org/emi#examples> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix spex:<https://purl.expasy.org/sparql-examples/ontology#> .

ex:015 a sh:SPARQLExecutable,
sh:SPARQLSelectExecutable ;
rdfs:comment "## List metabolites of plants that interact with plant parasite moth Orgyia postica (wd:Q7102162) ."@en ;
sh:prefixes _:sparql_examples_prefixes ;
sh:select """
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 ?intxnLabel ?targetWD ?targetNameURI ?ik ?wd_chem
WHERE {
{SELECT DISTINCT ?sourceWD ?sourceName ?intxnName ?intxnLabel ?targetWD ?targetName WHERE {
?intxn emi:hasSource ?source ; #retrieve interaction-pairs
emi:hasTarget ?target ;
emi:isClassifiedWith ?intxnName .
?target emi:inTaxon ?targetWD ; #retrieve wikidata-id for target plant
sosa:isSampleOf ?targetName .
?source emi:inTaxon ?sourceWD ; #retrieve wikidata-id for source parasite
sosa:isSampleOf ?sourceName .
?intxnName rdfs:label ?intxnLabel
VALUES ?sourceWD { wd:Q7102162 } #retain results only if the source-WD matches the wikidata-id of Orgyia postica
}
}
{ SELECT DISTINCT ?targetWD ?ik ?wd_chem WHERE {
?material sosa:hasSample ?extract ;
sosa:isSampleOf ?organe .
?organe emi:inTaxon ?targetWD . #filter metabolite data which is found in wikidata-ids targetWD
?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 . #retrieve wikidata-ids for metabolites
}} UNION #union with data from lotus (integrated in wikidata)
{ SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
?wd_chem wdt:P235 ?ik ;
wdt:P703 ?targetWD .
}}
BIND(REPLACE(STR(?sourceName), "%20", " ") AS ?sourceNameX) #remove percent encodings from the sourceName
BIND(IRI(?sourceNameX) AS ?sourceNameURI)
BIND(REPLACE(STR(?targetName), "%20", " ") AS ?targetNameX) #remove percent encodings from the targetName
BIND(IRI(?targetNameX) AS ?targetNameURI)
}
""" ;
schema:target <https://biosoda.unil.ch/emi/sparql/> ;
spex:federatesWith <https://qlever.cs.uni-freiburg.de/api/wikidata> .
59 changes: 59 additions & 0 deletions examples/dbgi/018.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@prefix ex: <https://purl.org/emi#examples> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix spex:<https://purl.expasy.org/sparql-examples/ontology#> .

ex:018 a sh:SPARQLExecutable,
sh:SPARQLSelectExecutable ;
rdfs:comment "## List possible interactions of plants that can produce asimcin (wd:Q100138042), a cytotoxin."@en ;
sh:prefixes _:sparql_examples_prefixes ;
sh:select """
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 WHERE {
{ SELECT DISTINCT ?wd_chem WHERE { #retrieve metabolite data for sourceWD
?material sosa:hasSample ?extract ;
sosa:isSampleOf ?organe .
?organe emi:inTaxon ?sourceWD .
?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 . #retrieve wikidats-ids for metabolites
VALUES ?wd_chem { wd:Q100138042 } #filter on wikidata-id of asimicin
}} UNION #union with results from lotus (integrated in wikidata)
{ SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
?wd_chem wdt:P235 ?ik ;
wdt:P703 ?sourceWD .
VALUES ?wd_chem { wd:Q100138042 }
}}
?intxn emi:hasSource ?xOrg ; #retrieve interaction-pairs
emi:hasTarget ?yOrg ;
emi:isClassifiedWith ?intxnName .
?xOrg emi:inTaxon ?sourceWD ; #retrieve wikidata-id of the interaction-source
sosa:isSampleOf ?sourceName . #retrieve its scientific name as listed in GloBI
?yOrg emi:inTaxon ?targetWD ; #retrieve wikidata-id of the interaction-target
sosa:isSampleOf ?targetName . #retrieve its scientific names as listed in GloBI
BIND(REPLACE(STR(?sourceName), "%20", " ") AS ?sourceNameX) #remove percent encodings from source and target names
BIND(IRI(?sourceNameX) AS ?sourceNameURI)
BIND(REPLACE(STR(?targetName), "%20", " ") AS ?targetNameX)
BIND(IRI(?targetNameX) AS ?targetNameURI)
} LIMIT 1000
""" ;
schema:target <https://biosoda.unil.ch/emi/sparql/> ;
spex:federatesWith <https://qlever.cs.uni-freiburg.de/api/wikidata> .
Loading

0 comments on commit 615f9e9

Please sign in to comment.