/ 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 ; - @models.each_with_index do |model,i| %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: ['zebra', 'columns', 'uitheme'], 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 "}, :style=>"z-index:auto+10;"} / %td %tbody - type = @model_types[j] - prediction[:neighbors].uniq.each_with_index do |neighbor,count| %tr / Compound %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 %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("
") : neighbor[2].join(", ") / Similarity %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
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