...
Test Data
GSRS
SPARQL Query
https://github.com/edmcouncil/idmp/blob/master/etc/CQ/Example/cq2.sparql
# CQ 2: What is the active moiety of <substance y>?
prefix idmp-sub: < <https://spec.pistoiaalliance.org/idmp/ontology/ISO/ISO11238-Substances/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: < <http://www.w3.org/2000/01/rdf-schema#>prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix cmns-pts: <https://www.omg.org/spec/Commons/PartiesAndSituations/>
prefix cmns-dsg: <https://www.omg.org/spec/Commons/Designators/>
prefix cmns-cstdsg: <https://www.omg.org/spec/Commons/ContextualDesignators/>
prefix gsrs-sub: <https://gsrs.ncats.nih.gov/api/v1/substances/>SELECT DISTINCT ?ActiveMoiety ?ActiveMoityName ?ActiveMoietyRoleContext
FROM <https://spec.pistoiaalliance.org/idmp/ontology>
FROM <https://data.pistoiaalliance.org/idmp/gsrs>
WHERE {
# use the FDA UNII code to refer to the substance
BIND(gsrs-sub:B786J7A343 AS ?Substance )
# ensure the entity is indeed a substance
?Substance a/
select distinct ?activeMoiety ?activeMoietyLabel
where {
# Bind the name we want into a variable
BIND("amlodipine mesylate monohydrate" AS ?substanceLabel )
# Find a substance or subclass of substance
?substanceType rdfs:subClassOf* idmp-sub:Substance .
?substanceUri a ?substanceType . # find the active moieties
?ActiveMoiety cmns-pts:playsRole ?Role .
?Role cmns-pts:isRealizedIn ?Substance ;
a/rdfs:subClassOf* idmp-sub:ActiveMoietyRole ;
.
OPTIONAL {?Role cmns-cstdsg:isApplicableIn ?ActiveMoietyRoleContext }
OPTIONAL {?ActiveMoiety skos:prefLabel ?ActiveMoityName }
# With a label for substance y
?substanceUri rdfs:label ?substanceLabel .
# Link the substance to the active moiety
?substanceUri idmp-sub:hasActiveMoiety ?activeMoiety .
?activeMoiety a ?activeMoietyType .
?activeMoiety rdfs:label ?activeMoietyLabel .
}