Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagesql
# UC1-CQ 1: What substances have a common active moiety <M>?
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#>

SELECT DISTINCT ?Substance (SAMPLE(?SubstanceLabel) AS ?SubstanceName)
WHERE {
	# Bind Variable ActiveMoiety <M>
    # Example: <https://gsrs.ncats.nih.gov/api/v1/substances/1J444QC288> for GSRS Amlodipine
	BIND(uc1_cq1_parameter_1 AS ?M$M )
  	
    # Get the Entities that have the defined active moiety
    ?Substance ^idmp-sub:isActiveMoietyOf|idmp-sub:hasActiveMoiety ?M$M .
    
    # Make sure that we only return actual substances 
  	?Substance a/rdfs:subClassOf* idmp-sub:Substance .
	
    # Optionally, get the name of the substance
	OPTIONAL{?Substance  rdfs:label  ?SubstanceLabel }

} GROUP BY ?Substance

...