diff options
Diffstat (limited to 'views/neighbors.haml')
-rw-r--r-- | views/neighbors.haml | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/views/neighbors.haml b/views/neighbors.haml index 6001605..d9f2796 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})" @@ -28,8 +38,8 @@ $("table##{j+1}").tablesorter({ debug: false, theme: "bootstrap", - headerTemplate: '{content} {icon}', - widgets: ['zebra', 'columns', 'uitheme', 'stickyHeaders'], + headerTemplate: '', + widgets: ['columns', 'uitheme', 'stickyHeaders'], widgetOptions: { stickyHeaders_attachTo : '.tab-content', stickyHeaders : '', @@ -43,50 +53,45 @@ stickyHeaders_yScroll : null, stickyHeaders_filteredToTop: true }, - headers: {0: {sorter: false}, 3: {sorter: false}}, sortList: [[2,1]], + headers: {sorter: false}, widthFixed: false }); }); - if prediction[:neighbors].size > 0 %div.table-responsive - %table.tablesorter{:id=>"#{j+1}", :style=>"border-style: solid;"} + %table{:id=>"#{j+1}", :style=>"border-style: solid;"} %thead %tr - %th{:style =>"vertical-align:middle;"} + %th.sorter-false{:style =>"vertical-align:middle;"} Compound - %th{:style =>"vertical-align:middle;"} + %th.sorter-false{:style =>"vertical-align:middle;"} Measured Activity - %th{:style =>"vertical-align:middle;"} + %a.btn.glyphicon.glyphicon-info-sign{:href=>"#neighbors", :title=>"Measured Activity", :tabindex=>"0", data: {trigger:"focus", container:"body", toggle:"popover", placement:"left", 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=>"#neighbors", :title=>"Similarity", :tabindex=>"0", data: {trigger:"focus", container:"body", toggle:"popover", placement:"left", 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 - %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] + - unit = @models[j].unit - prediction[:neighbors].uniq.each_with_index do |neighbor,count| %tr / 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[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 + /%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 / Measured Activity %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 + = (type == "Regression" ? "#{neighbor[:measurement].delog10}" + " (#{unit})" : neighbor[:measurement]) + %br + = "#{c.mmol_to_mg(neighbor[:measurement].delog10)}" + " (#{(unit =~ /\b(mol\/L)\b/) ? "mg/L" : "mg/kg_bw/day"})" if type == "Regression" + / 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[:similarity].round(3) - else %span.btn.btn-default.disabled |