Sha256: 3aac98062640f193ceebd765f9426eb7584cae6405ae731bfec5f6bd7e6cecb2
Contents?: true
Size: 1.74 KB
Versions: 5
Compression:
Stored size: 1.74 KB
Contents
module Biomart # Class representation for a biomart database. # Will contain many Biomart::Dataset objects, and belong to a Biomart::Server. class Database include Biomart attr_reader :name, :display_name, :visible def initialize( url, args ) @url = url or raise ArgumentError, "must pass :url" unless @url =~ /martservice/ @url = @url + "/martservice" end @name = args["name"] || args[:name] @display_name = args["displayName"] || args[:display_name] @visible = ( args["visible"] || args[:visible] ) ? true : false @datasets = {} end # Returns an array of the dataset names (biomart 'name') # for this dataset. def list_datasets if @datasets.empty? fetch_datasets end return @datasets.keys end # Returns a hash (keyed by the biomart 'name' for the dataset) # of all of the Biomart::Dataset objects belonging to this server. def datasets if @datasets.empty? fetch_datasets end return @datasets end private # Utility method to do the webservice call to the biomart server # and collate/build the information about the datasets. def fetch_datasets url = @url + "?type=datasets&mart=#{@name}" document = request( :url => url ) tsv_data = CSV.parse( document, "\t" ) tsv_data.each do |t| if t[1] and ( t[3] === "1" ) dataset_attr = { "name" => t[1], "displayName" => t[2], "visible" => t[3] } @datasets[ dataset_attr["name"] ] = Dataset.new( @url, dataset_attr ) end end end end end
Version data entries
5 entries across 5 versions & 2 rubygems