summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--application.rb16
-rw-r--r--views/prediction.haml2
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