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 --- lib/algorithm.rb | 3 ++- lib/dataset.rb | 4 +++- lib/environment.rb | 2 +- lib/validation.rb | 10 ++++++++-- 4 files changed, 14 insertions(+), 5 deletions(-) (limited to 'lib') 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) -- cgit v1.2.3