Created
August 25, 2011 08:01
-
-
Save nakao/1170203 to your computer and use it in GitHub Desktop.
Sample Ruby code for the BH11Ujicha SPARQL endpoint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rdf' # gem install rdf | |
require 'rest_client' # gem install rest-client | |
require 'json' # gem install json | |
endpoint = "http://open-biomed.org:8890/sparql" | |
query = "SELECT * WHERE { <http://bio2rdf.org/affymetrix:1007_s_at> ?predicate ?object }" | |
# XML, "application/sparql-results+xml" ; CSV, "text/csv" | |
response = RestClient.post endpoint, :query => query, :format => "application/sparql-results+json" | |
puts "Response: #{response.code}" | |
data = JSON.parse(response.to_str) | |
data['results']['bindings'].each do |ent| | |
p [ent['predicate']['value'], ent['object']['value']] | |
end | |
puts " ==== " | |
p data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment