Skip to content

Instantly share code, notes, and snippets.

@glow-mdsol
Created October 1, 2013 09:28
Show Gist options
  • Save glow-mdsol/6775977 to your computer and use it in GitHub Desktop.
Save glow-mdsol/6775977 to your computer and use it in GitHub Desktop.
import requests
result = requests.get('http://10.192.0.224:8890/sparql?query=PREFIX+xml%3A+%3Chttp%3A%2F%2Fwww.w3.org%2FXML%2F1998%2Fnamespace%3E%0APREFIX+rdfs%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0APREFIX+linkedct%3A+%3Chttp%3A%2F%2Fdata.linkedct.org%2Fvocab%2Fresource%2F%3E%0APREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%0APREFIX+xsd%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23%3E%0A%0A++++++++SELECT+DISTINCT+%3Fstudy_name+%3Fsponsor+%3Ftrial+%3Ftrial_id+%3Fstatus+%3Fphase+%3Forg_id+%3Fsec_id%0A++++++++WHERE+%7B%0AVALUES+%28+%3Fstudy_name+%3Fsponsor+%29%0A%7B+%28+%22C%00A%002%000%000%005%000%001%008%002%00%22+%3Chttp%3A%2F%2Fdata.linkedct.org%2Fresource%2Fsponsor%2F0bdfb8ebc97ca1307b549840e3c83c99%3E+%29+%7D+.%0A%0A++++++++++++%3Ftrial+a+linkedct%3Atrial+%3B%0A+++++++++++++++++++++linkedct%3Atrialid+%3Ftrial_id+%3B%0A+++++++++++++++++++++linkedct%3Aphase+%3Fphase+%3B%0A+++++++++++++++++++++linkedct%3Aoverall_status+%3Fstatus+%3B%0A+++++++++++++++++++++linkedct%3Asponsor_group+%3Fsponsor_group+%3B%0A+++++++++++++++++++++linkedct%3Aid_info_org_study_id+%3Forg_id+.%0A++++++++++++%3Fsponsor_group+linkedct%3Asponsor_group_lead_sponsor+%3Fsponsor+.%0A++++++++++++OPTIONAL+%7B%3Ftrial+linkedct%3Aid_info_secondary_id+%3Fsec_id%7D++%0A++++++++++++FILTER%28REGEX%28%3Forg_id%2C+%3Fstudy_name%2C+%22i%22%29%29%0A++++++++%7D')
print result.text
Virtuoso 37000 Error SQ074: Line 10: Unterminated SPARQL short double-quoted string at ''
SPARQL query:
define sql:big-data-const 0 PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX linkedct: <http://data.linkedct.org/vocab/resource/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT DISTINCT ?study_name ?sponsor ?trial ?trial_id ?status ?phase ?org_id ?sec_id
WHERE {
VALUES ( ?study_name ?sponsor )
{ ( "CA20050182" <http://data.linkedct.org/resource/sponsor/0bdfb8ebc97ca1307b549840e3c83c99> ) } .
?trial a linkedct:trial ;
linkedct:trialid ?trial_id ;
linkedct:phase ?phase ;
linkedct:overall_status ?status ;
linkedct:sponsor_group ?sponsor_group ;
linkedct:id_info_org_study_id ?org_id .
?sponsor_group linkedct:sponsor_group_lead_sponsor ?sponsor .
OPTIONAL {?trial linkedct:id_info_secondary_id ?sec_id}
FILTER(REGEX(?org_id, ?study_name, "i"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment