1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/ 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
#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({
debug: false,
theme: "bootstrap",
headerTemplate: '{content} {icon}',
widgets: ['columns', 'uitheme', 'stickyHeaders'],
widgetOptions: {
stickyHeaders_attachTo : '.tab-content',
stickyHeaders : '',
stickyHeaders_offset : 0,
stickyHeaders_cloneId : '-sticky',
stickyHeaders_addResizeEvent : true,
stickyHeaders_includeCaption : true,
stickyHeaders_zIndex : 2,
stickyHeaders_attachTo : null,
stickyHeaders_xScroll : null,
stickyHeaders_yScroll : null,
stickyHeaders_filteredToTop: true
},
headers: {0: {sorter: false}, 3: {sorter: false}},
sortList: [[2,1]],
widthFixed: false
});
});
- if prediction[:neighbors].size > 0
%div.table-responsive
%table.tablesorter{:id=>"#{j+1}", :style=>"border-style: solid;"}
%thead
%tr
%th{:style =>"vertical-align:middle;"}
Compound
%th{:style =>"vertical-align:middle;"}
Measured Activity
%th{:style =>"vertical-align:middle;"}
Similarity
/ %th{:style =>"vertical-align:middle;"}
/ Supporting Information
%span
%tr
%td
%td{:style=>"font-size:x-small;padding:0px;"}
/ %a.btn.glyphicon.glyphicon-info-sign{:href=>"#neighbors", :title=>"Measured Activity", data: {toggle:"popover", placement:"auto", html:"true", content:"Experimental result(s) from the training dataset."}, :style=>"z-index:auto+10;"}
%td{:style=>"font-size:x-small;padding:0px;"}
/ %a.btn.glyphicon.glyphicon-info-sign{:href=>"#neighbors", :title=>"Similarity", data: {toggle:"popover", placement:"auto", html:"true", content:"LAZAR calculates activity specific similarities based on the presence of statistically significant fragments. This procedure will <ul><li>consider only those parts of a chemical structure that are relevant for a particular endpoint</li><li>ignore inert parts of the structure</li><li>lead to different similarities, depending on the toxic endpoint Similarities of 1 may be encountered even for structurally dissimilar compounds, because inert parts are ignored.</li></ul>"}, :style=>"z-index:auto+10;"}
/ %td
%tbody
- type = @model_types[j]
- 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["_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;"}
- 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[:tanimoto] != nil ? neighbor[:tanimoto].to_f.round(3) : "Not enough similar compounds </br>in training dataset."
- else
%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
|