summaryrefslogtreecommitdiff
path: root/views/neighbors.haml
diff options
context:
space:
mode:
Diffstat (limited to 'views/neighbors.haml')
-rw-r--r--views/neighbors.haml31
1 files changed, 21 insertions, 10 deletions
diff --git a/views/neighbors.haml b/views/neighbors.haml
index 6001605..6011a6d 100644
--- a/views/neighbors.haml
+++ b/views/neighbors.haml
@@ -9,7 +9,17 @@
#tabs
%ul.nav.nav-tabs.nav-justified{:id=>"neighborTabs", :role=>"tablist"}
/ each model a tab head ;
+ / hash for predictionFeature
+ - predictionFeature = {}
- @models.each_with_index do |model,i|
+ / get predictionFeature type
+ - m = Model::Lazar.find model.model_id.to_s
+ - predFeature = Feature.find m.prediction_feature_id.to_s
+ / define feature type (numeric : nominal)
+ - predFeatureType = (predFeature.numeric? ? "numeric" : "nominal")
+ / use prediction feature id for neighbor compound features
+ - predFeatureId = m.prediction_feature_id.to_s
+ - predictionFeature[i] = {"id" => predFeatureId, "type" => predFeatureType}
%li{:class => ("active" if i == 0)}
%a{:href => "#results_#{i+1}", :id => "linkTab#{i+1}", data: {toggle:"tab"}}
= "#{model.endpoint} (#{model.species})"
@@ -29,7 +39,7 @@
debug: false,
theme: "bootstrap",
headerTemplate: '{content} {icon}',
- widgets: ['zebra', 'columns', 'uitheme', 'stickyHeaders'],
+ widgets: ['columns', 'uitheme', 'stickyHeaders'],
widgetOptions: {
stickyHeaders_attachTo : '.tab-content',
stickyHeaders : '',
@@ -74,19 +84,20 @@
- prediction[:neighbors].uniq.each_with_index do |neighbor,count|
%tr
/ Compound
+ - c = Compound.find(neighbor["_id"])
%td{:style =>"vertical-align:middle;padding-left:1em;width:50%;"}
- /%a.btn.btn-link{:href => "#details#{j+1}", data: { toggle: "modal", remote: to("/prediction/#{CGI.escape(neighbor[0].to_s)}/details"), :id=>"link#{j+1}#{count}"}}
- %p= Compound.find(neighbor[0]).svg
- %p= Compound.find(neighbor[0]).smiles
- - c = Compound.find(neighbor[0])
- //- mw = c.molecular_weight
- / Measured Activity
+ /%a.btn.btn-link{:href => "#details#{j+1}", data: { toggle: "modal", remote: to("/prediction/#{CGI.escape(neighbor["_id"])}/details"), :id=>"link#{j+1}#{count}"}}
+ %p= c.svg
+ %p= c.smiles
+ - mw = c.molecular_weight
+ / Measured Activity = compound.features
%td{:style =>"vertical-align:middle;padding-left:1em;width:20%;white-space:nowrap;"}
- = (type == "Regression") ? neighbor[2].collect{|n| weight = c.mmol_to_mg(n); '%.2e' % n + " (#{@models[j].unit})"+"|#{'%.2e' % weight} (mg/kg_bw/day)"}.join("</br>") : neighbor[2].join(", ")
- / Similarity
+ - features = c.features.collect{|k,v| v if k == predictionFeature[j]["id"] }.compact.flatten
+ = (predictionFeature[j]["type"] == "numeric") ? features.collect{|v| weight = c.mmol_to_mg(v); '%.2e' % v + " (#{@models[j].unit})"+" | #{'%.2e' % weight} (mg/kg_bw/day)"}.join("</br>") : features.join("</br>")
+ / Similarity = tanimoto
%td{:style =>"vertical-align:middle;padding-left:1em;width:20%;"}
/ TODO differentiate between no neighbors found and compound found in dataset, display neighbors for compounds in dataset?
- = neighbor[1] != nil ? neighbor[1].round(2) : "Not enough similar compounds </br>in training dataset."
+ = neighbor[:tanimoto] != nil ? neighbor[:tanimoto].to_f.round(3) : "Not enough similar compounds </br>in training dataset."
- else
%span.btn.btn-default.disabled