From d262dbc79c9f5d8e2d74647df52a9c44e1af511d Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 6 May 2010 17:42:03 +0200 Subject: martins modifications merged and adjusted --- Rakefile | 2 +- lib/algorithm.rb | 3 ++- lib/dataset.rb | 4 +++- lib/environment.rb | 2 +- lib/validation.rb | 10 ++++++++-- opentox-ruby-api-wrapper.gemspec | 9 ++++----- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Rakefile b/Rakefile index 2dfb2c6..4c9e00a 100644 --- a/Rakefile +++ b/Rakefile @@ -13,7 +13,7 @@ begin ["sinatra", "rest-client", "rack", "rack-contrib", "rack-flash", "emk-sinatra-url-for", "cehoffman-sinatra-respond_to", "dm-more", "dm-core", "sinatra-static-assets"].each do |dep| gem.add_dependency dep end - ['cucumber','jeweler', "thin"].each do |dep| + ['cucumber','jeweler'].each do |dep| gem.add_development_dependency dep end gem.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.gitignore'] diff --git a/lib/algorithm.rb b/lib/algorithm.rb index 8083db2..eaf1f7e 100644 --- a/lib/algorithm.rb +++ b/lib/algorithm.rb @@ -21,8 +21,9 @@ module OpenTox def self.create_model(params) LOGGER.debug params LOGGER.debug File.basename(__FILE__) + ": creating model" + LOGGER.debug File.join(@@config[:services]["opentox-algorithm"], "lazar") resource = RestClient::Resource.new(File.join(@@config[:services]["opentox-algorithm"], "lazar"), :user => @@users[:users].keys[0], :password => @@users[:users].values[0], :content_type => "application/x-yaml") - @uri = resource.post(:dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri], :feature_generation_uri => File.join(@@config[:services]["opentox-algorithm"], "fminer")).chomp + @uri = resource.post(:dataset_uri => params[:dataset_uri], :prediction_feature => params[:prediction_feature], :feature_generation_uri => File.join(@@config[:services]["opentox-algorithm"], "fminer")).body.chomp end def self.uri diff --git a/lib/dataset.rb b/lib/dataset.rb index c513463..3cfe639 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -14,9 +14,10 @@ module OpenTox def self.find(uri) - if uri.match(/webservices.in-silico.ch|localhost|ot.dataset.de|opentox.informatik.uni-freiburg.de/) # try to get YAML first + #if uri.match(/webservices.in-silico.ch|localhost|ot.dataset.de|opentox.informatik.uni-freiburg.de/) # try to get YAML first d = YAML.load RestClientWrapper.get(uri.to_s.strip, :accept => 'application/x-yaml').to_s d.uri = uri unless d.uri +=begin else # get default rdf+xml owl = OpenTox::Owl.from_uri(uri.to_s.strip, "Dataset") @@ -33,6 +34,7 @@ module OpenTox d.compounds.uniq! d.features.uniq! end +=end return d end diff --git a/lib/environment.rb b/lib/environment.rb index b46bf19..29dcbdb 100644 --- a/lib/environment.rb +++ b/lib/environment.rb @@ -46,7 +46,7 @@ before {$sinatra = self unless $sinatra} class Sinatra::Base # overwriting halt to log halts (!= 202) def halt(*response) - LOGGER.error "halt "+response.first.to_s+" "+(response.size>1 ? response[1].to_s : "") if response.first >= 300 + LOGGER.error "halt "+response.first.to_s+" "+(response.size>1 ? response[1].to_s : "") if response and response.first and response.first >= 300 # orig sinatra code: response = response.first if response.length == 1 throw :halt, response diff --git a/lib/validation.rb b/lib/validation.rb index 6fd5704..97aafc4 100644 --- a/lib/validation.rb +++ b/lib/validation.rb @@ -4,8 +4,14 @@ module OpenTox attr_accessor :uri def initialize(params) - resource = RestClient::Resource.new(params[:uri], :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) - @uri = resource.post(params).to_s + #resource = RestClient::Resource.new(params[:uri], :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + #@uri = resource.post(params).to_s + call = "curl -X POST " + params.each do |k,v| + call += " -d "+k.to_s+"=\""+v.to_s+"\"" unless k == :uri + end + call += " "+params[:uri] + LOGGER.debug call end def self.crossvalidation(params) diff --git a/opentox-ruby-api-wrapper.gemspec b/opentox-ruby-api-wrapper.gemspec index 258ee09..e30b56f 100644 --- a/opentox-ruby-api-wrapper.gemspec +++ b/opentox-ruby-api-wrapper.gemspec @@ -9,10 +9,10 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Christoph Helma"] - s.date = %q{2010-03-18} + s.date = %q{2010-05-04} s.description = %q{Ruby wrapper for the OpenTox REST API (http://www.opentox.org)} s.email = %q{helma@in-silico.ch} - s.executables = ["opentox-install-ubuntu.sh", "opentox-install-debian.sh", "yaml2owl.rb"] + s.executables = ["opentox-install-ubuntu.sh", "yaml2owl.rb", "opentox-install-debian.sh"] s.extra_rdoc_files = [ "LICENSE", "README.rdoc" @@ -31,11 +31,13 @@ Gem::Specification.new do |s| "lib/config/config_ru.rb", "lib/dataset.rb", "lib/environment.rb", + "lib/features.rb", "lib/helper.rb", "lib/model.rb", "lib/opentox-ruby-api-wrapper.rb", "lib/opentox.owl", "lib/owl.rb", + "lib/rest_client_wrapper.rb", "lib/spork.rb", "lib/task.rb", "lib/tasks/opentox.rb", @@ -67,7 +69,6 @@ Gem::Specification.new do |s| s.add_runtime_dependency(%q, [">= 0"]) s.add_development_dependency(%q, [">= 0"]) s.add_development_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 0"]) else s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) @@ -81,7 +82,6 @@ Gem::Specification.new do |s| s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) end else s.add_dependency(%q, [">= 0"]) @@ -96,7 +96,6 @@ Gem::Specification.new do |s| s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) end end -- cgit v1.2.3