Skip to content

Instantly share code, notes, and snippets.

@rjpbonnal
Created February 12, 2010 05:11
Show Gist options
  • Save rjpbonnal/302322 to your computer and use it in GitHub Desktop.
Save rjpbonnal/302322 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'active_rdf'
class Bio
class SPARQL
def initialize(params ={})
@adapter=ConnectionPool.add(:type => :sparql, :url => 'http://geneid.bio2rdf.org/sparql', :engine => :virtuoso)
end
def full_text_search(text)
Query.new.select(:s, :p, :o).where(:s,:p,:o).where(:o,RDFS::Resource.new('bif:contains'), text).execute
end
def self.to_tab(results)
results.collect {|row|
row.join("\t")
}
end
end
end
myEndPoint=Bio::SPARQL.new
#look for Gene TP53
myGeneSemWeb=myEndPoint.full_text_search("TP53")
#Format in a tabular format
puts myEndPoint.to_tab(myGeneSemWeb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment