from SPARQLWrapper import SPARQLWrapper, JSON
dicomGroup = '0040'
dicomId = '8302'
sparql = SPARQLWrapper("http://rdf-stage.neuinfo.org/ds/query")
sparql.setQuery("""
prefix property: <http://neurolex.org/wiki/Special:URIResolver/Property-3A>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
select ?name ?id where { """ +
'?s property:DICOMID "DICOM:' + dicomGroup + '"^^xsd:string .' +
'?s property:DICOMID "' + dicomId + '"^^xsd:string . ' +
"""
?s property:Label ?name .
?s property:Id ?id
} LIMIT 100
""")
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
for result in results["results"]["bindings"]:
print result["name"]['value']
print result["id"]['value']