From c78e51a79f68020ce7e59072cac6cd0dc46fbe1d Mon Sep 17 00:00:00 2001 From: gebele Date: Wed, 18 Jan 2017 11:41:44 +0000 Subject: refined dbhit --- application.rb | 16 +++++++--------- views/prediction.haml | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/application.rb b/application.rb index c409a42..47f4340 100644 --- a/application.rb +++ b/application.rb @@ -126,7 +126,6 @@ post '/predict/?' do @type = params[:type] example_core = params[:example_core] - #example_coating = params[:example_coating] example_coating = params.collect{|k,v| v if k =~ /example_coating_/}.compact input_core = params[:input_core] @@ -139,18 +138,17 @@ post '/predict/?' do end if @type == "fingerprint" - @fingerprint_relevant_features = [] - nanoparticle = (input_core == example_core && input_coating == example_coating) ? Nanoparticle.find(params[:example_id]) : nil - - if !nanoparticle.nil? + # search for database hit + dbhit = $coating_list.find{|nano| nano.core.name == input_core && (nano.coating.collect{|co| co.name}) == input_coating } + if !dbhit.nil? @match = true - @nanoparticle = nanoparticle - @name = nanoparticle.name + nanoparticle = dbhit + @nanoparticle = dbhit + @name = @nanoparticle.name else - # changed input = create nanoparticle to predict + # no database hit => create nanoparticle nanoparticle = Nanoparticle.new nanoparticle.core_id = Compound.find_by(:name=>input_core).id.to_s - nanoparticle.coating_ids = [] input_coating.each{|ic| nanoparticle.coating_ids << Compound.find_by(:name=>ic).id.to_s} @match = false @nanoparticle = nanoparticle diff --git a/views/prediction.haml b/views/prediction.haml index 55d9b8e..49b7994 100644 --- a/views/prediction.haml +++ b/views/prediction.haml @@ -66,7 +66,7 @@ / similarity %td - if @match - %h5.th5 1 + %h5.th5 1.0 - else %h5.th5 x / composition -- cgit v1.2.3