Class OpenTox::Dataset
In: lib/opentox-ruby-api-wrapper.rb
Parent: OpenTox

Methods

Public Class methods

Initialize with :uri => uri or :name => name (creates a new dataset)

[Source]

# 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

Public Instance methods

Add a compound and a feature to a dataset

[Source]

# 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

[Source]

# 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

Get all features from a dataset

[Source]

# File lib/opentox-ruby-api-wrapper.rb, line 108
                def all_features
                        RestClient.get(@uri + '/features').split("\n").collect{|f| Feature.new(:uri => f)}
                end

Get all compounds from a dataset

[Source]

# File lib/opentox-ruby-api-wrapper.rb, line 93
                def compounds
                        RestClient.get(@uri + '/compounds').split("\n").collect{ |c| Compound.new(:uri => c) }
                end

Get all features for a compound

[Source]

# File lib/opentox-ruby-api-wrapper.rb, line 113
                def features(compound)
                        RestClient.get(@uri + '/compound/' + uri_escape(compound.uri) + '/features').split("\n").collect{|f| Feature.new(:uri => f) }
                end

Get the dataset name

[Source]

# File lib/opentox-ruby-api-wrapper.rb, line 88
                def name
                        RestClient.get @uri + '/name'
                end

[Validate]