summaryrefslogtreecommitdiff
path: root/views/neighbors.haml
diff options
context:
space:
mode:
Diffstat (limited to 'views/neighbors.haml')
-rw-r--r--views/neighbors.haml42
1 files changed, 8 insertions, 34 deletions
diff --git a/views/neighbors.haml b/views/neighbors.haml
index 32b8389..9c12be9 100644
--- a/views/neighbors.haml
+++ b/views/neighbors.haml
@@ -1,38 +1,19 @@
-/ unpacks multi prediction array ;
-/ prepare it for neighbors ;
-/ align single prediction to endpoint ;
-/ display preordered in table view ;
-
%div.results
%h3 Neighbors:
/ tabs div
#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})"
%div.tab-content
- / unpack to single arrays
- @predictions.each_with_index do |prediction,j|
- / pass model type for significant fragments view
+ - if prediction.dimension > 0
+ - prediction = prediction[0]
#results.tab-pane{:id=>"#{j+1}", :class => ("active" if j == 0)}
- / prepare dataset for neighbors table ;
- / delete first array which contains prediction ;
- / following arrays are the neighbor predictions ;
- / call the tablesorter plugin ;
- / presort by similarity ;
:javascript
$(document).ready(function(){
$("table##{j+1}").tablesorter({
@@ -58,7 +39,7 @@
widthFixed: false
});
});
- - if prediction[:neighbors].size > 0
+ - if prediction[:neighbors]
%div.table-responsive
%table{:id=>"#{j+1}", :style=>"border-style: solid;"}
%thead
@@ -70,9 +51,7 @@
%a.btn.glyphicon.glyphicon-info-sign{:href=>"javascript:void(0)", :title=>"Measured Activity", :tabindex=>"0", data: {trigger:"focus", container:"body", toggle:"popover", placement:"auto", html:"true", content:"Experimental result(s) from the training dataset."}, :style=>"z-index:auto+10;"}
%th.sorter-false{:style =>"vertical-align:middle;"}
Similarity
- %a.btn.glyphicon.glyphicon-info-sign{:href=>"javascript:void(0)", :title=>"Similarity", :tabindex=>"0", data: {trigger:"focus", container:"body", toggle:"popover", placement:"auto", html:"true", content:"<a href=\"https://en.wikipedia.org/wiki/Jaccard_index\">Tanimoto/Jaccard</a> similarity based on <a href=\"https://openbabel.org/docs/dev/FileFormats/MolPrint2D_format.html\">Molprint2D</a> fingerprints."}, :style=>"z-index:auto+10;"}
- / %th{:style =>"vertical-align:middle;"}
- / Supporting Information
+ %a.btn.glyphicon.glyphicon-info-sign{:href=>"javascript:void(0)", :title=>"Similarity", :tabindex=>"0", data: {trigger:"focus", container:"body", toggle:"popover", placement:"auto", html:"true", content:"<a alt=\"Link opens in new window.\" title=\"Link opens in new window.\" target=\"_blank\" href=\"https://en.wikipedia.org/wiki/Jaccard_index\">Tanimoto/Jaccard</a> similarity based on <a alt=\"Link opens in new window.\" title=\"Link opens in new window.\" target=\"_blank\" href=\"https://openbabel.org/docs/dev/FileFormats/MolPrint2D_format.html\">Molprint2D</a> fingerprints."}, :style=>"z-index:auto+10;"}
%tbody
- type = @model_types[j]
- unit = @models[j].unit
@@ -81,17 +60,16 @@
/ Compound
- c = Compound.find(neighbor)
%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["_id"])}/details"), :id=>"link#{j+1}#{count}"}}
- %p= c.svg
+ = c.svg
%p= c.smiles
/ Measured Activity
%td{:style =>"vertical-align:middle;padding-left:1em;width:20%;white-space:nowrap;"}
- if neighbor[:measurement].is_a?(Array)
- = (type == "Regression") ? neighbor[:measurement].collect{|value| "#{value.delog10} (#{unit})</br>#{c.mmol_to_mg(value.delog10)} #{unit =~ /mmol\/L/ ? "(mg/L)" : "(mg/kg_bw/day)"}"}.join("</br>") : neighbor[:measurement].join(", ")
+ = (type == "Regression") ? neighbor[:measurement].collect{|value| "#{value.delog10.signif(3)} (#{unit})</br>#{c.mmol_to_mg(value.delog10).signif(3)} #{unit =~ /mmol\/L/ ? "(mg/L)" : "(mg/kg_bw/day)"}"}.join("</br>") : neighbor[:measurement].join(", ")
- else
- = (type == "Regression") ? "#{neighbor[:measurement].delog10} (#{unit})</br>#{c.mmol_to_mg(neighbor[:measurement].delog10)} #{(unit =~ /\b(mol\/L)\b/) ? "(mg/L)" : "(mg/kg_bw/day)"}" : neighbor[:measurement]
-
+ - if !neighbor[:measurement].nil?
+ = (type == "Regression") ? "#{neighbor[:measurement].delog10.signif(3)} (#{unit})</br>#{c.mmol_to_mg(neighbor[:measurement].delog10).signif(3)} #{(unit =~ /\b(mmol\/L)\b/) ? "(mg/L)" : "(mg/kg_bw/day)"}" : neighbor[:measurement]
/ Similarity = tanimoto
%td{:style =>"vertical-align:middle;padding-left:1em;width:20%;"}
= neighbor[:similarity].round(3)
@@ -100,7 +78,3 @@
%span.btn.btn-default.disabled
= "Not enough similar compounds in training dataset"
- %div.modal.fade{:id=>"details#{j+1}", :role=>"dialog"}
- %div.modal-dialog.modal-lg
- %div.modal-content
-