From abc3526e318a2bfa24dfe033d8879e7657c2ae5c Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Tue, 15 Mar 2016 18:46:34 +0100 Subject: single tests pass --- lib/lazar.rb | 2 +- lib/model.rb | 3 ++- lib/physchem.rb | 6 ------ lib/regression.rb | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/lazar.rb b/lib/lazar.rb index 0125d27..b4293e9 100644 --- a/lib/lazar.rb +++ b/lib/lazar.rb @@ -86,4 +86,4 @@ CLASSES = ["Feature","Compound","Dataset","Validation","CrossValidation","LeaveO "leave-one-out-validation.rb", "experiment.rb", ].each{ |f| require_relative f } - +OpenTox::PhysChem.descriptors # load descriptor features diff --git a/lib/model.rb b/lib/model.rb index f21ea54..5da5dc8 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -66,6 +66,7 @@ module OpenTox prediction.merge!({:value => nil,:confidence => nil,:warning => "Could not find similar compounds with experimental data in the training dataset."}) else prediction.merge!(Algorithm.run(prediction_algorithm, compound, {:neighbors => neighbors,:training_dataset_id=> training_dataset_id,:prediction_feature_id => prediction_feature.id})) + prediction[:neighbors] = neighbors end prediction end @@ -95,7 +96,7 @@ module OpenTox case object.class.to_s when "OpenTox::Compound" prediction = predictions.first - prediction[:neighbors] = neighbors.sort{|a,b| b[1] <=> a[1]} # sort according to similarity + prediction[:neighbors].sort!{|a,b| b[1] <=> a[1]} # sort according to similarity return prediction when "Array" return predictions diff --git a/lib/physchem.rb b/lib/physchem.rb index 067cd59..f7b880f 100644 --- a/lib/physchem.rb +++ b/lib/physchem.rb @@ -37,15 +37,9 @@ module OpenTox DESCRIPTORS = OBDESCRIPTORS.merge(CDKDESCRIPTORS.merge(JOELIBDESCRIPTORS)) - DESCRIPTORS.each do |name,description| - lib,desc = name.split('.',2) - self.find_or_create_by(:name => name, :library => lib, :descriptor => desc, :description => description, :measured => false, :calculated => true, :numeric => true, :nominal => false) - end - require_relative "unique_descriptors.rb" def self.descriptors desc=DESCRIPTORS - # TODO create PhysChem features @startup desc.collect do |name,description| lib,desc = name.split('.',2) self.find_or_create_by(:name => name, :library => lib, :descriptor => desc, :description => description, :measured => false, :calculated => true, :numeric => true, :nominal => false) diff --git a/lib/regression.rb b/lib/regression.rb index b8efd30..6b08fd8 100644 --- a/lib/regression.rb +++ b/lib/regression.rb @@ -62,7 +62,7 @@ module OpenTox else compound_features = variables.collect{|f| compound.fingerprint.include?(f) ? "T" : "F"} prediction = r_model_prediction method, data_frame, variables, weights, compound_features - if prediction.nil? + if prediction.nil? or prediction[:value].nil? prediction = local_weighted_average(compound, params) prediction[:warning] = "Could not create local PLS model. Using weighted average of similar compounds." return prediction -- cgit v1.2.3