Skip to content

Instantly share code, notes, and snippets.

@nakao
Created August 25, 2011 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nakao/1170203 to your computer and use it in GitHub Desktop.
Save nakao/1170203 to your computer and use it in GitHub Desktop.
Sample Ruby code for the BH11Ujicha SPARQL endpoint
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