%link{ :href=>"/jsme/jsa.css", :rel=>"stylesheet"} %script{:src=>"/jsme/jsme.nocache.js"} :javascript $(function() { $('a[data-toggle="tab"]').on('click', function (e) { localStorage.setItem('lastTab', $(e.target).attr('href')); }); var lastTab = localStorage.getItem('lastTab'); if (lastTab) { $('a[href="'+lastTab+'"]').click(); } }); function getInput(){ identifier = document.getElementById("identifier").value; fileselect = document.getElementById("fileselect").value; if (fileselect != ""){ return 1; }; if (identifier != ""){ return 2; }; return 0; }; function showcircle() { switch (getInput()){ case 0: alert("Please draw or insert a chemical structure."); return false; break; case 1: if (checkfile() && checkboxes()){ button = document.getElementById("submit"); image = document.getElementById("circle"); button.parentNode.replaceChild(image, button); $("img.circle").show(); return true; }; return false; break; case 2: if (checksmiles() && checkboxes()){ button = document.getElementById("submit"); image = document.getElementById("circle"); button.parentNode.replaceChild(image, button); $("img.circle").show(); return true; }; return false; break; default: false; }; return false; }; function checkfile() { var fileinput = document.getElementById("fileselect"); if(fileinput.value != "") { //TODO check file type is csv return true; }; alert("Please select a file (csv)."); return false; }; function checksmiles () { getsmiles(); if (document.form.identifier.value == "") { alert("Please draw or insert a chemical structure."); document.form.identifier.focus(); $("img.circle").hide(); return false; }; return true; }; function checkboxes () { var checked = false; $('input[type="checkbox"]').each(function() { if ($(this).is(":checked")) { checked = true; }; }); if (checked == false){ alert("Please select an endpoint."); $("img.circle").hide(); return false; }; return true; }; function jsmeOnLoad() { jsmeApplet = new JSApplet.JSME("appletContainer", "380px", "340px", { //optional parameters "options" : "polarnitro" }); document.JME = jsmeApplet; }; function getsmiles() { if (document.JME.smiles() != '') { document.form.identifier.value = document.JME.smiles() ; }; }; // whole site content needs to be in one form. Input and checkboxes are proofed by js functions. %form{:name => "form", :action => to('/predict'), :method => "post", :enctype => "multipart/form-data", :onsubmit => "return !!(showcircle())" } %fieldset#top.well %h2 1. Draw a chemical structure #insert %label   #appletContainer %br %label{:for => 'identifier'} or enter the %a{:href => "http://en.wikipedia.org/wiki/Simplified_molecular_input_line_entry_specification", :rel => "external"} SMILES string: %br %input{:type => 'text', :name => 'identifier', :id => 'identifier', :size => '60'} %p %label{:for=>"fileselect"} or upload a CSV file for batch predictions %br %span.btn.btn-default.btn-file -#%input{:type=>"file", :name=> "fileselect", :id=>"fileselect", :accept=>".csv", :disabled=>"disabled"} %input{:type=>"file", :name=> "fileselect", :id=>"fileselect", :accept=>"text/csv"} %fieldset#middle.well %h2 2. Select one or more endpoints #models - @endpoints.each do |endpoint| %div{:id=>endpoint} %h4.head-back=endpoint - @models.select{|m| m.endpoint == endpoint}.each do |model| %div.row{:id => model.id} %span.col-sm-4 %input{:type => "checkbox", :name => "selection[#{model.id}]", :id => "selection[#{model.species}]", :value => true, :disabled => false} %label{:for => "selection[#{model.species}]"} = model.species %span.col-sm-8 %a.btn.btn-default.btn-xs{:data=>{:toggle=>"collapse"}, :href=>"#details#{model.id}", :id => "link#{model.id}", :style=>"font-size:small;"} Details | Validation %div.panel-collapse.collapse{:id=>"details#{model.id}", :style=>"margin-left:1em;"} %b Model: %br Source: %a{:href=>model.source, :rel=>"external"} = model.source %br = "Algorithm:\tLAZAR" %br - model.classification? ? type = "Classification" : type = "Regression" = "Type:\t" = type %br - training_dataset = OpenTox::Dataset.find model.training_dataset.id = "Training dataset:\t" = training_dataset.source.split("/").last %br = "Training compounds:\t" = training_dataset.compounds.size %p %b Validation (repeated): %div.row{:style=>"background-color:#f5f5f5;"} - model.crossvalidations.each do |crossvalidation| %span.col-xs-4.col-sm-4.col-md-4.col-lg-4 - cv = OpenTox::CrossValidation.find crossvalidation.id = "Num folds:\t" = cv.folds %br = "Num instances:\t" = cv.nr_instances %br = "Num unpredicted" = cv.nr_unpredicted - if model.classification? %br = "Accuracy:\t" = cv.accuracy.round(3) if cv.accuracy %br = "Weighted Accuracy:\t" = cv.weighted_accuracy.round(3) if cv.weighted_accuracy %br = "True positive rate:\t" = cv.true_rate["active"].round(3) if cv.true_rate["active"] %br = "True negative rate:\t" = cv.true_rate["inactive"].round(3) if cv.true_rate["inactive"] %br = "Positive predictive value:\t" = cv.predictivity["active"].round(3) if cv.predictivity["active"] %br = "Negative predictive value:\t" = cv.predictivity["inactive"].round(3) if cv.predictivity["inactive"] %p %b Confusion Matrix: %table.table.table-condensed.table-borderless{:style=>"width:20%;"} %tbody %tr %td %td %td %b actual %td %td %tr %td %td %td active %td inactive -#%td total %tr %td %b predicted %td active %td =cv.confusion_matrix[0][0] %td =cv.confusion_matrix[0][1] -#%td =cv.confusion_matrix[0][0]+cv.confusion_matrix[0][1] %tr %td %td inactive %td =cv.confusion_matrix[1][0] %td =cv.confusion_matrix[1][1] -#%td =cv.confusion_matrix[1][0]+cv.confusion_matrix[1][1] -#%tr %td %td total %td =cv.confusion_matrix[0][0]+cv.confusion_matrix[1][0] %td =cv.confusion_matrix[0][1]+cv.confusion_matrix[1][1] %td -#= "Confusion Matrix:\t" -#= cv.confusion_matrix - if model.regression? %br = "Root mean squared error:\t" = cv.rmse.round(3) if cv.rmse %br = "Weighted root mean squared error:\t" = cv.weighted_rmse.round(3) if cv.weighted_rmse %br = "Mean absolute error:\t" = cv.mae.round(3) if cv.mae %br = "Weighted mean absolute error:\t" = cv.weighted_mae.round(3) if cv.weighted_mae %br = "R square:\t" = cv.r_squared.round(3) if cv.r_squared /%br /= "Correlation plot" /= cv.correlation_plot /%br /= "Confidence plot:" /= cv.confidence_plot %fieldset#bottom.well %div.row %div.col-md-2 %h2 3. Predict %div.col-md-10 %input.btn.btn-warning.h2{ :type => "submit", :id => "submit", :value=>">>", :onclick => "getsmiles()"} %img.h2{:src=>"/images/wait30trans.gif", :id=>"circle", :class=>"circle", :style=>"display:none;"}