HCLSIG/Use case/Medical SPARQL/queries

From W3C Wiki
< HCLSIG
Revision as of 09:47, 11 October 2011 by Msamwald (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Medical SPARQL Query Library

For now, this page can be used to collect examples of medical SPARQL queries. These queries can serve as a basis for building a more sophisticated library of SPARQL query templates for responding to medical questions.

Given a compound name or drug brand name, show basic pharmacological information from DrugBank

Execute on SPARQL endpoint at http://linkedlifedata.com/sparql

Example query string: "warfarin"

 PREFIX drugbank: <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/>
 SELECT DISTINCT ?drug_uri ?label ?indication ?mechanismOfAction ?biotransformation ?halfLife
 FROM <http://linkedlifedata.com/resource/drugbank>
 WHERE {
   ?drug_uri a drugbank:drugs .
   ?drug_uri rdfs:label ?label .
   OPTIONAL { ?drug_uri drugbank:brandName ?brandName . }
   OPTIONAL { ?drug_uri drugbank:indication ?indication . }
   OPTIONAL { ?drug_uri drugbank:mechanismOfAction ?mechanismOfAction . } 
   OPTIONAL { ?drug_uri drugbank:biotransformation ?biotransformation . }
   OPTIONAL { ?drug_uri drugbank:halfLife ?halfLife . }
   {{FILTER regex(?label, "warfarin", "i")}
     UNION
    {FILTER regex(?brandName, "warfarin", "i")}
   }
 }

This version seems much faster? (SK)

PREFIX drugbank: <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/>
SELECT DISTINCT ?drug_uri ?label ?indication ?mechanismOfAction ?biotransformation ?halfLife
FROM <http://linkedlifedata.com/resource/drugbank>
WHERE {
  ?drug_uri a drugbank:drugs .
  ?drug_uri rdfs:label ?label . FILTER(regex(?label, "warfarin", "i"))
  OPTIONAL { ?drug_uri drugbank:brandName ?brandName . FILTER(regex(?brandName, "warfarin", "i")) }
  OPTIONAL { ?drug_uri drugbank:indication ?indication . }
  OPTIONAL { ?drug_uri drugbank:mechanismOfAction ?mechanismOfAction . } 
  OPTIONAL { ?drug_uri drugbank:biotransformation ?biotransformation . }
  OPTIONAL { ?drug_uri drugbank:halfLife ?halfLife . }
}

Given a compound name or drug brand name, show food interactions from DrugBank

Execute on SPARQL endpoint at http://linkedlifedata.com/sparql

Example query string: "warfarin"

 PREFIX drugbank: <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/>
 SELECT DISTINCT ?drug_uri ?label ?foodInteraction
 FROM <http://linkedlifedata.com/resource/drugbank>
 WHERE {
   ?drug_uri a drugbank:drugs .
   ?drug_uri rdfs:label ?label .
   ?drug_uri drugbank:foodInteraction ?foodInteraction . 
   OPTIONAL { ?drug_uri drugbank:brandName ?brandName . }  
   {{FILTER regex(?label, "warfarin", "i")}
     UNION
    {FILTER regex(?brandName, "warfarin", "i")}
   }
 } 

Given the name of a condition, find clinical trials for that condition that have the status "Recruiting" and display most relevant information

Execute on SPARQL endpoint at http://linkedlifedata.com/sparql

Example query string: "diabetes"

 PREFIX linkedct: <http://data.linkedct.org/resource/linkedct/>
 PREFIX linkedct_trials: <http://data.linkedct.org/resource/trials/>
 SELECT DISTINCT ?trial ?brief_title ?summary ?description ?criteria ?end_date ?facility_name ?facility_address_country ?facility_address_state ?facility_address_city
 FROM <http://linkedlifedata.com/resource/linkedct>
 WHERE {
   ?trial linkedct:overall_status "Recruiting" ;
          linkedct:brief_title ?brief_title ;
          linkedct:summary ?summary ;
          linkedct:description ?description ;
          linkedct:criteria ?criteria .
   OPTIONAL { ?trial linkedct:end_date ?end_date . }
   ?trial linkedct:location ?location .
   ?location linkedct:facility_name ?facility_name ;
             linkedct:facility_address_country ?facility_address_country ;
 			linkedct:facility_address_state ?facility_address_state ;
 			linkedct:facility_address_city ?facility_address_city .	
 
   ?trial linkedct:condition ?condition .
   ?condition linkedct:condition_name ?condition_name .
   FILTER regex(?condition_name, "diabetes", "i")
 }

NOTE: In LinkedLifeData, the locations of trials in LinkedCT are linked with the Geonames. If we can automatically infer the location of the user (e.g. based on their IP address), we could use this to only display clinical trials that are in reasonable proximity.