diff options
author | gebele <gebele@in-silico.ch> | 2017-01-18 11:41:44 +0000 |
---|---|---|
committer | gebele <gebele@in-silico.ch> | 2017-01-18 11:41:44 +0000 |
commit | c78e51a79f68020ce7e59072cac6cd0dc46fbe1d (patch) | |
tree | 9f71b466666ade0ae1dd7d6c8afdd1f094d9815f | |
parent | c9621a800143dc841c2a106f76ca4b9db09a1106 (diff) |
refined dbhit
-rw-r--r-- | application.rb | 16 | ||||
-rw-r--r-- | 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 |