Class | OpenTox::Dataset |
In: |
lib/opentox-ruby-api-wrapper.rb
|
Parent: | OpenTox |
Initialize with :uri => uri or :name => name (creates a new dataset)
# File lib/opentox-ruby-api-wrapper.rb, line 78 def initialize(params) if params[:uri] @uri = params[:uri].to_s elsif params[:name] @uri = RestClient.post ENV['OPENTOX_DATASETS'], :name => params[:name] RestClient.delete @uri + '/associations' end end
Add a compound and a feature to a dataset
# File lib/opentox-ruby-api-wrapper.rb, line 118 def add(compound,feature) RestClient.put @uri, :compound_uri => compound.uri, :feature_uri => feature.uri end
Get all compounds and features from a dataset, returns a hash with compound_uris as keys and arrays of features as values
# File lib/opentox-ruby-api-wrapper.rb, line 98 def all_compounds_and_features compounds = {} Crack::XML.parse(RestClient.get @uri + '/compounds/features')['dataset']['compound'].each do |c| features = c['feature_uri'].collect{ |f| Feature.new :uri => f } compounds[c['uri']] = features end compounds end