From 0afad05f3f23bff1d0197b759127b2da0be14548 Mon Sep 17 00:00:00 2001 From: David Vorgrimmler Date: Tue, 17 Apr 2012 15:53:04 +0200 Subject: Bugfixes: Handling lib and pc_type --- lazar.rb | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lazar.rb b/lazar.rb index 40b4ad0..c1d800d 100644 --- a/lazar.rb +++ b/lazar.rb @@ -128,24 +128,31 @@ post '/lazar/?' do min_sim = 0.7 unless params[:min_sim] min_sim = (min_sim * 2.0 -1.0 ) # transform to cosine range [-1,1] - training_features_tl = training_features.features.collect{|f,info| info[DC.description].gsub(/.*\[/,"").chop.split(", ")} + training_features_tl = training_features.features.collect{|f,info| + if info[DC.description] == nil + [nil, nil] + else + info[DC.description].gsub(/.*\[/,"").chop.split(", ") + end + + } training_features_pc_types = training_features_tl.collect{|info| info[0]}.flatten.uniq training_features_lib = training_features_tl.collect{|info| info[1]}.flatten.uniq - unless (params[:pc_type] or params[:lib]) - - if (!params[:pc_type] && training_features_pc_types.size>0) + unless (params[:pc_type] and params[:lib]) + + if (!params[:pc_type] && training_features_pc_types.compact.uniq.size > 0) pc_type=training_features_pc_types.join(',') LOGGER.info "pc_type '#{pc_type}' auto-detected from feature dataset" end - if (!params[:lib] && training_features_lib.size>0) + if (!params[:lib] && training_features_lib.compact.uniq.size > 0) lib=training_features_lib.join(',') LOGGER.info "lib '#{lib}' auto-detected from feature dataset" end unless (pc_type and lib) - raise OpenTox::NotFoundError.new "No pc_type parameter given, and autodetection from feature dataset failed" - raise OpenTox::NotFoundError.new "No lib parameter given, and autodetection from feature dataset failed" + raise OpenTox::NotFoundError.new "No pc_type parameter given, and autodetection from feature dataset failed" unless pc_type + raise OpenTox::NotFoundError.new "No lib parameter given, and autodetection from feature dataset failed" unless lib end end @@ -230,7 +237,7 @@ post '/lazar/?' do end end - lazar.compounds=training_activities.compounds.collect + lazar.compounds=training_dataset.compounds.collect task.progress 90 -- cgit v1.2.3