Skip to content

Instantly share code, notes, and snippets.

@jvsoest
Last active October 15, 2017 16:42
Show Gist options
  • Save jvsoest/eb015abfb0efd5c669fd36915ce2487d to your computer and use it in GitHub Desktop.
Save jvsoest/eb015abfb0efd5c669fd36915ce2487d to your computer and use it in GitHub Desktop.
One query to retrieve patient information, disease and treatment characteristics, trials matching the treatment characteristics, and the link to publications linked to these trials. Hence, we can find publications related to the disease and treatment of specific patients (via the treatment protocols and clinical trials).
prefix roo: <http://www.cancerdata.org/roo/>
prefix ncit: <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix icd: <http://purl.bioontology.org/ontology/ICD10/>
prefix uo: <http://purl.obolibrary.org/obo/UO_>
prefix dcterm: <http://purl.org/dc/terms/>
prefix ctvoc: <http://bio2rdf.org/clinicaltrials_vocabulary:>
prefix ctres: <http://bio2rdf.org/clinicaltrials_resource:>
prefix ct: <http://bio2rdf.org/clinicaltrials:>
SELECT DISTINCT ?patient ?gender ?ageDiagnosis ?ecogStatus ?clinT ?clinN ?pathT ?pathN ?presDoseGy ?protocol ?trial ?trialAcronym ?trialTitle ?countryName ?cityName ?pubmedLink
WHERE {
SERVICE <http://sparql.cancerdata.org/namespace/thunder/sparql> {
?patient rdf:type ncit:C16960.
?patient roo:100008 ?disease.
?disease rdf:type icd:C20.
?patient roo:100403 ?protocol. # the materialized/inferenced line regarding the treatment protocol
?patient roo:100301 ?rtRes.
?rtRes rdf:type ncit:C15313.
?rtRes roo:100402 ?disease.
?patient roo:100018 ?genderRes.
?genderRes rdf:type ?gender.
# Get age at diagnosis
{
?patient roo:100016 ?ageResDiagnosis.
?ageResDiagnosis rdf:type roo:100002.
?ageResDiagnosis roo:100027 ?ageDiagnosisUnitRes.
?ageDiagnosisUnitRes rdf:type uo:0000036.
?ageResDiagnosis roo:100042 ?ageDiagnosis.
}
# Get ECOG performance status
{
?patient roo:100218 ?ecogRes.
?ecogRes rdf:type ?ecogStatus.
}
# Get clinical TNM values
{
?disease roo:100243 ?clinTnmRes.
?clinTnmRes rdf:type ncit:C48881.
?clinTnmRes roo:100244 ?clinTRes.
?clinTRes rdf:type ?clinT.
?clinTnmRes roo:100242 ?clinNRes.
?clinNRes rdf:type ?clinN.
}
# Get pathologic TNM values
{
?disease roo:100287 ?pathTnmRes.
?pathTnmRes rdf:type ncit:C48739.
?pathTnmRes roo:100288 ?pathTRes.
?pathTRes rdf:type ?pathT.
?pathTnmRes roo:100286 ?pathNRes.
?pathNRes rdf:type ?pathN.
}
# Get prescribed radiation dose (in Gray)
{
?rtRes roo:100023 ?prescribedDoseRes.
?prescribedDoseRes rdf:type roo:100013.
?prescribedDoseRes roo:100027 ?presDoseUnitRes.
?presDoseUnitRes rdf:type uo:000134.
?prescribedDoseRes roo:100042 ?presDoseGy.
}
}
SERVICE <http://sparql.cancerdata.org/namespace/clinicaltrials/sparql> {
?trial roo:100265 ?protocol. #magic line which makes the link
?trial ctvoc:official-title ?trialTitle.
OPTIONAL { ?trial ctvoc:acronym ?trialAcronym. }
?trial ctvoc:location ?locationRes.
#OPTIONAL: uncomment to get locations where trials were conducted
#?locationRes dcterm:title ?location.
#?locationRes ctvoc:address ?addressRes.
#?addressRes ctvoc:city ?cityId.
#?addressRes ctvoc:country ?countryId.
#?cityRes dcterm:identifier ?cityId.
#?cityRes dcterm:title ?cityName.
#?countryRes dcterm:identifier ?countryId.
#?countryRes dcterm:title ?countryName.
?trial <http://bio2rdf.org/bio2rdf_vocabulary:identifier> ?trialId.
BIND(CONCAT('<a href="https://www.ncbi.nlm.nih.gov/pubmed/?term=', ?trialId, '+%5Bsi%5D">link</a>') AS ?pubmedLink).
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment