From a165822a7bd663916cff9484a76e6bb6bcf9a353 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 25 Jan 2010 09:29:21 +0100 Subject: internal authorization with first user of users.yaml --- lib/algorithm.rb | 112 +++++++++++++++++++++++++++---------------------------- 1 file changed, 56 insertions(+), 56 deletions(-) (limited to 'lib/algorithm.rb') diff --git a/lib/algorithm.rb b/lib/algorithm.rb index 6ae9e72..d5f85c7 100644 --- a/lib/algorithm.rb +++ b/lib/algorithm.rb @@ -1,66 +1,66 @@ module OpenTox - module Algorithm + module Algorithm - class Fminer - include Owl + class Fminer + include Owl - def initialize - super - self.uri = File.join(@@config[:services]["opentox-algorithm"],'fminer') - self.title = "fminer" - self.source = "http://github.com/amaunz/libfminer" - self.parameters = { - "Dataset URI" => { :scope => "mandatory", :value => "dataset_uri" }, - "Feature URI for dependent variable" => { :scope => "mandatory", :value => "feature_uri" } - } - end + def initialize + super + self.uri = File.join(@@config[:services]["opentox-algorithm"],'fminer') + self.title = "fminer" + self.source = "http://github.com/amaunz/libfminer" + self.parameters = { + "Dataset URI" => { :scope => "mandatory", :value => "dataset_uri" }, + "Feature URI for dependent variable" => { :scope => "mandatory", :value => "feature_uri" } + } + end - def self.create_feature_dataset(params) - resource = RestClient::Resource.new(params[:feature_generation_uri], :user => request.username, :password => request.password) - resource.post :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri] - end - end + def self.create_feature_dataset(params) + resource = RestClient::Resource.new(params[:feature_generation_uri], :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + resource.post :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri] + end + end - class Lazar - include Owl + class Lazar + include Owl - def initialize - super - self.uri = File.join(@@config[:services]["opentox-algorithm"],'lazar') - self.title = "lazar" - self.source = "http://github.com/helma/opentox-algorithm" - self.parameters = { - "Dataset URI" => - { :scope => "mandatory", :value => "dataset_uri" }, - "Feature URI for dependent variable" => - { :scope => "mandatory", :value => "feature_uri" }, - "Feature generation URI" => - { :scope => "mandatory", :value => "feature_generation_uri" } - } - end - - def self.create_model(params) - resource = RestClient::Resource.new(File.join(@@config[:services]["opentox-algorithm"], "lazar"), :user => request.username, :password => request.password) - @uri = resource.post :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri], :feature_generation_uri => File.join(@@config[:services]["opentox-algorithm"], "fminer") - end + def initialize + super + self.uri = File.join(@@config[:services]["opentox-algorithm"],'lazar') + self.title = "lazar" + self.source = "http://github.com/helma/opentox-algorithm" + self.parameters = { + "Dataset URI" => + { :scope => "mandatory", :value => "dataset_uri" }, + "Feature URI for dependent variable" => + { :scope => "mandatory", :value => "feature_uri" }, + "Feature generation URI" => + { :scope => "mandatory", :value => "feature_generation_uri" } + } + end + + def self.create_model(params) + resource = RestClient::Resource.new(File.join(@@config[:services]["opentox-algorithm"], "lazar"), :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + @uri = resource.post :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri], :feature_generation_uri => File.join(@@config[:services]["opentox-algorithm"], "fminer") + end - end + end - class Similarity - def self.weighted_tanimoto(fp_a,fp_b,p) - common_features = fp_a & fp_b - all_features = fp_a + fp_b - common_p_sum = 0.0 - if common_features.size > 0 - common_features.each{|f| common_p_sum += p[f]} - all_p_sum = 0.0 - all_features.each{|f| all_p_sum += p[f]} - common_p_sum/all_p_sum - else - 0.0 - end - end - end + class Similarity + def self.weighted_tanimoto(fp_a,fp_b,p) + common_features = fp_a & fp_b + all_features = fp_a + fp_b + common_p_sum = 0.0 + if common_features.size > 0 + common_features.each{|f| common_p_sum += p[f]} + all_p_sum = 0.0 + all_features.each{|f| all_p_sum += p[f]} + common_p_sum/all_p_sum + else + 0.0 + end + end + end - end + end end -- cgit v1.2.3