Class: OpenTox::Dataset
- Defined in:
- lib/opentox-ruby-api-wrapper.rb
Instance Attribute Summary
Attributes inherited from OpenTox
Instance Method Summary collapse
-
#add(compound, feature) ⇒ Object
Add a compound and a feature to a dataset.
-
#all_compounds_and_features_uris ⇒ Object
Get all compounds and features from a dataset, returns a hash with compound_uris as keys and arrays of feature_uris as values.
-
#all_features ⇒ Object
Get all features from a dataset.
-
#close ⇒ Object
Tell the dataset that it is complete.
-
#compounds ⇒ Object
Get all compounds from a dataset.
-
#features(compound) ⇒ Object
Get all features for a compound.
-
#initialize(params) ⇒ Dataset
constructor
Initialize with
:uri => uri
or:name => name
(creates a new dataset).
Methods inherited from OpenTox
#destroy, #finished?, #name, #uri_escape
Constructor Details
#initialize(params) ⇒ Dataset
Initialize with :uri => uri
or :name => name
(creates a new dataset)
97 98 99 100 101 102 103 104 105 |
# File 'lib/opentox-ruby-api-wrapper.rb', line 97 def initialize(params) if params[:uri] @uri = params[:uri].to_s elsif params[:name] and params[:filename] @uri = `curl -X POST -F file=@#{params[:filename]} -F name="#{params[:name]}" #{ENV['OPENTOX_DATASET']}` elsif params[:name] @uri = RestClient.post ENV['OPENTOX_DATASET'], :name => params[:name] end end |
Instance Method Details
#add(compound, feature) ⇒ Object
Add a compound and a feature to a dataset
128 129 130 |
# File 'lib/opentox-ruby-api-wrapper.rb', line 128 def add(compound,feature) RestClient.put @uri, :compound_uri => compound.uri, :feature_uri => feature.uri end |
#all_compounds_and_features_uris ⇒ Object
Get all compounds and features from a dataset, returns a hash with compound_uris as keys and arrays of feature_uris as values
113 114 115 |
# File 'lib/opentox-ruby-api-wrapper.rb', line 113 def all_compounds_and_features_uris YAML.load(RestClient.get(@uri + '/compounds/features')) end |
#all_features ⇒ Object
Get all features from a dataset
118 119 120 |
# File 'lib/opentox-ruby-api-wrapper.rb', line 118 def all_features RestClient.get(@uri + '/features').split("\n").collect{|f| Feature.new(:uri => f)} end |
#close ⇒ Object
Tell the dataset that it is complete
133 134 135 |
# File 'lib/opentox-ruby-api-wrapper.rb', line 133 def close RestClient.put @uri, :finished => 'true' end |