summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.de>2009-08-15 18:36:49 +0200
committerChristoph Helma <helma@in-silico.de>2009-08-15 18:36:49 +0200
commitbb2614a3cb7720f906c9d853e0dc1f3713058005 (patch)
treeda9a854d492190ce7ae0f83a1cbb8c51b5fae44a
parent82f7a9b1a639a8693c0b1267b6b280ee121d8f9a (diff)
XML support removed, YAML expected for object serialization.
-rw-r--r--Rakefile1
-rw-r--r--lib/opentox-ruby-api-wrapper.rb19
2 files changed, 10 insertions, 10 deletions
diff --git a/Rakefile b/Rakefile
index de8e703..72eebcf 100644
--- a/Rakefile
+++ b/Rakefile
@@ -11,7 +11,6 @@ begin
gem.homepage = "http://github.com/helma/opentox-ruby-api-wrapper"
gem.authors = ["Christoph Helma"]
gem.add_dependency "rest-client"
- gem.add_dependency "crack"
gem.add_development_dependency "thoughtbot-shoulda"
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
diff --git a/lib/opentox-ruby-api-wrapper.rb b/lib/opentox-ruby-api-wrapper.rb
index 8e4e28e..81a7292 100644
--- a/lib/opentox-ruby-api-wrapper.rb
+++ b/lib/opentox-ruby-api-wrapper.rb
@@ -1,4 +1,6 @@
-[ 'rest_client', 'crack/xml', 'spork', 'helper' ].each do |lib|
+
+#['rubygems', 'rest_client', 'spork', 'helper' ].each do |lib|
+['rubygems', 'rest_client', 'spork' ].each do |lib|
require lib
end
@@ -102,12 +104,7 @@ module OpenTox
# Get all compounds and features from a dataset, returns a hash with compound_uris as keys and arrays of features as values
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
+ YAML.load(RestClient.get(@uri + '/compounds/features'))
end
# Get all features from a dataset
@@ -143,8 +140,12 @@ module OpenTox
class Lazar < OpenTox
# Create a new prediction model from a dataset
- def initialize(training_dataset)
- @uri = RestClient.post ENV['OPENTOX_LAZAR'] + 'models/' , :dataset_uri => training_dataset.uri
+ def initialize(params)
+ if params[:uri]
+ @uri = params[:uri]
+ elsif params[:dataset_ur]
+ @uri = RestClient.post ENV['OPENTOX_LAZAR'] + 'models/' , :dataset_uri => training_dataset.uri
+ end
end
# Predict a compound