summaryrefslogtreecommitdiff
path: root/views/batch.haml
diff options
context:
space:
mode:
Diffstat (limited to 'views/batch.haml')
-rw-r--r--views/batch.haml155
1 files changed, 48 insertions, 107 deletions
diff --git a/views/batch.haml b/views/batch.haml
index 0e7efc7..6bc2354 100644
--- a/views/batch.haml
+++ b/views/batch.haml
@@ -1,109 +1,50 @@
-%div.well
- %a.btn.btn-warning{:href => to('/predict')}
- %span.glyphicon.glyphicon-menu-left{:aria=>{:hidden=>"true"}}
+:javascript
+ // kill task pid if page is reloaded, `false` makes the request synchronous
+ window.addEventListener('unload', ktpid, false);
+ function ktpid() {
+ var client = new XMLHttpRequest();
+ client.open("GET", '//#{$host_with_port}/prediction/task?ktpid=#{@pid}', false);
+ client.setRequestHeader("Content-Type", "application/json");
+ client.send(null);
+ };
+%div.card
+ %a.btn.btn-outline-info{:href => "//#{$host_with_port}/predict?tpid=#{@pid}"}
+ %span.fa.fa-caret-left{:aria=>{:hidden=>"true"}}
New Prediction
- %a.btn.btn-success{:id => "downbutton", :href=>"#{to("/predict/#{@tmppath}/#{@filename}")}", :title=>"download"}
- %span.glyphicon.glyphicon-download-alt
- Download CSV
+%div.card.bg-light
+ %div.card-body
+ %h3.card-title="Batch prediction results for: #{@filename}"
+
+ // prepare variable values for javascript
+ // increase timer interval for large datasets
+ - timer = 10000#((@compounds_size/1000) == 0 ? 1000 : ((@compounds_size/1000)*1000))
+ // process batch predictions
+ - @models.each_with_index do |model,idx|
+ - m = Model::Validation.find model
+ - task = @tasks[idx].id
+ #result.card.bg-light{:id=>idx}
+ %div.card-body
+ %div.row
+ %div.col-6
+ %h5.card-title="#{m.endpoint} (#{m.species})"
+ #pager{:id=>idx}
+ %div.col-6
+ %a.btn.btn-outline-info.btn-sm.disabled{:id => "detailsbutton_#{idx}", :data=>{:toggle=>"collapse"}, :href=>"javascript:void(0)", :onclick=>"pagePredictions('//#{$host_with_port}/prediction/task/?predictions=#{task}','#{model}','#{idx}','#{@compounds_size}')"}
+ %span.fa.fa-caret-right
+ Details
+ %a.btn.btn-outline-info.btn-sm.disabled{:id => "downbutton_#{idx}", :href=>"//#{$host_with_port}/predict/batch/download?tid=#{task}", :title=>"download"}
+ %span.fa.fa-download
+ CSV
+ %p{:id=>"est_#{idx}"}
+ waiting ...
+ %img.h2{:src=>"/images/wait30trans.gif", :id=>"circle_#{idx}", :class=>"circle", :alt=>"wait", :style=>"display:none;"}
+ :javascript
+ $(document).ready(function() {
+ taskProgress('#{idx}','#{timer}','//#{$host_with_port}/prediction/task/?turi=#{task}');
+ });
+ #data-container.card.d-none.table-responsive{:id=>idx}
+ :javascript
+%div.modal.fade{:id=>"details", :tabindex=>"-1", :role=>"dialog"}
+ %div.modal-dialog.modal-lg{:role=>"document"}
+ %div.modal-content
- / show file name
- %topline
- %div.row
- %div.col-md-4
- %h3 Batch Prediction Results:
- %div.col-md-8
- %h3= @filename
-
- / displays all prediction result in one table
- %div.table-responsive
- %table.table.table-bordered{:id=>"batch", :style=>"background-color:white;"}
- %tbody
- - if @warnings
- - @warnings.each do |warning|
- %tr
- %td
- %b Warning
- %td
- = warning.sub(/\b(tmp\/)\b/,"")
- - @view.each do |compound, array|
- %tr
- %td{:style=>"vertical-align:top;"}
- %p= compound.svg
- %p= compound.smiles
- - array.each do |model,prediction|
- %td{:style=>"vertical-align:top;white-space:nowrap;"}
- - model.model.class.to_s.match("Classification") ? type = "Classification" : type = "Regression"
- - unit = model.unit
-
- %b{:class => "title"}
- = "#{model.endpoint.gsub('_', ' ')} (#{model.species})"
-
- / check for prediction
- - if prediction[:value]
- %p
- / show model type (classification|regression)
- %b Type:
- = type
- %p
- / check for database hit
- - if prediction[:info] =~ /\b(identical)\b/i
-
- / show message about dbhit and measurements
- %p
- %b Compound is part of the training dataset
- %p
- %b Measured activity:
- %br
- - if prediction[:measurements].is_a?(Array)
- = (type == "Regression") ? prediction[:measurements].collect{|value| "#{value.delog10.signif(3)} (#{unit})</br>#{compound.mmol_to_mg(value.delog10).signif(3)} #{unit =~ /mmol\/L/ ? "(mg/L)" : "(mg/kg_bw/day)"}"}.join("</br>") : prediction[:measurements].join(", ")
- - else
- = (type == "Regression") ? "#{prediction[:measurements].delog10.signif(3)} (#{unit})</br>#{compound.mmol_to_mg(prediction[:measurements].delog10).signif(3)} #{(unit =~ /\b(mmol\/L)\b/) ? "(mg/L)" : "(mg/kg_bw/day)"}" : prediction[:measurements]
-
-
- / show prediction
- %p
- %b Prediction:
- %br
- = (type == "Regression") ? "#{prediction[:value].delog10.signif(3)} (#{unit})</br>#{compound.mmol_to_mg(prediction[:value].delog10).signif(3)} #{(unit =~ /\b(mmol\/L)\b/) ? "(mg/L)" : "(mg/kg_bw/day)"}" : prediction[:value]
-
- / show prediction interval or probability
- %p
- - if type == "Regression"
- %b 95% Prediction interval:
- - interval = (prediction[:prediction_interval].nil? ? nil : prediction[:prediction_interval])
- %br
- = interval.nil? ? "" : "#{interval[1].delog10.signif(3)} - #{interval[0].delog10.signif(3)} (#{unit})"
- %br
- = "#{compound.mmol_to_mg(interval[1].delog10).signif(3)} - #{compound.mmol_to_mg(interval[0].delog10).signif(3)} #{(unit =~ /\b(mmol\/L)\b/) ? "(mg/L)" : "(mg/kg_bw/day)"}" if !prediction[:prediction_interval].nil?
- - else
- %b Probability:
- - unless prediction[:probabilities].nil?
- - probabilities = ""
- - prediction[:probabilities].each{|k,v| probabilities += "#{k}: #{v.signif(3)}<br>"}
- %br
- = probabilities
- / show warnings
- %p
- - if !prediction[:info].blank?
- %b Info:
- %br
- %p=prediction[:info].sub(/\'.*\'/,"").sub(/,/, ",<br>")
- - if !prediction[:warnings].blank?
- %b Warnings:
- - prediction[:warnings].uniq.each do |warning|
- %br
- %p=warning.sub(/substances/, "substances<br>").sub(/prediction\:/, "prediction\:<br>")
-
- / no prediction
- - else
- %br
- - if !prediction[:info].blank?
- %b Info:
- %br
- %p=prediction[:info].sub(/\'.*\'/,"").sub(/,/, ",<br>")
- - if !prediction[:warnings].blank?
- %b Warnings:
- - prediction[:warnings].uniq.each do |warning|
- %br
- %p=warning.sub(/substances/, "substances<br>").sub(/prediction\:/, "prediction\:<br>")
- %tr