Help SPARQLEndpoint
From ToxBankWiki
Help SPARQLEndpoint (Redirected from Help/SPARQLEndpoint)
Contents |
Accessing the SPARQL endpoint
In ToxBank Gold Compound Wiki the SPARQLExtension for Semantic MediaWiki provide a SPARQL endpoint as a web service that answers SPARQL queries. An integrated webform Special:SPARQLEndpoint can also be used as an easy graphical human-readable interface to the SPARQL endpoint. Data analysis or other software can make direct request to the HTTP-based service.
Application Example:
Example R-client
How the Gold Compound wiki can be accessed from within R see [gcwiki-r-client on github] .
With the common command line tool curl
To receive a XML-result list of all goldcompounds send an HTTP post request with the SPARQL-string and the wanted format to the wiki's SPARQL endpoint:
SPARQL_STRING=" PREFIX cat: <http://wiki.toxbank.net/w/index.php/Special:URIResolver/Category-3A> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT DISTINCT ?substance ?name WHERE { ?substance a cat:GoldCompounds ; rdfs:label ?name . } ORDER BY ?name " curl -X POST -d "output=xml" -d "query=$SPARQL_STRING" http://wiki.toxbank.net/wiki/Special:SPARQLEndpoint
SPARQL Examples:
- Retrieve a list of URIs and names of all gold compounds of the TGCD.
PREFIX cat: <http://wiki.toxbank.net/w/index.php/Special:URIResolver/Category-3A> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT DISTINCT ?substance ?name WHERE { ?substance a cat:GoldCompounds ; rdfs:label ?name . } ORDER BY ?name
- Obtain all predicates of a specific compound:
PREFIX wiki: <http://wiki.toxbank.net/w/index.php/Special:URIResolver/> SELECT ?predicate ?value WHERE { wiki:Acetaminophen ?predicate ?value } ORDER BY ?predicate
- Retrieve a list of all toxic effects:
PREFIX prop: <http://wiki.toxbank.net/w/index.php/Special:URIResolver/Property-3A> SELECT DISTINCT ?effect WHERE { ?subject prop:Has_toxic_effect ?effect }
- Get a list of compound-URIs that do have apoptosis as a toxic effect:
PREFIX wiki: <http://wiki.toxbank.net/w/index.php/Special:URIResolver/> PREFIX prop: <http://wiki.toxbank.net/w/index.php/Special:URIResolver/Property-3A> SELECT DISTINCT ?subject WHERE { ?subject prop:Has_toxic_effect wiki:Apoptosis }
- Get a list of hepatotoxic compounds (compound name, InChI identifier, compound URI) that do have an InChI identifier ordered by name:
PREFIX cat: <http://wiki.toxbank.net/w/index.php/Special:URIResolver/Category-3A> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX prop: <http://wiki.toxbank.net/w/index.php/Special:URIResolver/Property-3A> SELECT DISTINCT ?name ?inchi ?substance WHERE { ?substance a cat:HepatotoxicCompounds OPTIONAL { ?substance rdfs:label ?name } OPTIONAL { ?substance prop:Has_InChI ?inchi } FILTER ( ?inchi != ) } ORDER BY ?name