From e61474c10be3f31c20ff53b83c687f3899325ed0 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 16 Mar 2011 13:52:23 +0000 Subject: Issues from Vedrins tests resolved, compound rendering issues moved to opentox/compound --- application.rb | 2 +- model.rb | 154 ------------------------------------- public/progressbar/progressbar.css | 20 ++++- views/create.haml | 23 +++--- views/help.haml | 8 +- views/layout.haml | 8 +- views/lazar_description.haml | 43 +++++------ views/model.haml | 3 +- views/models.haml | 4 +- views/predict.haml | 6 +- views/validation.haml | 8 +- 11 files changed, 69 insertions(+), 210 deletions(-) diff --git a/application.rb b/application.rb index f6e03cc..fc21414 100644 --- a/application.rb +++ b/application.rb @@ -192,7 +192,7 @@ post '/models' do # create a new model task = OpenTox::Task.create("Uploading dataset and creating lazar model",url_for("/models",:full)) do |task| task.progress(5) - @model.update :status => "Uploading and saving dataset" + @model.update :status => "Uploading and saving dataset", :task_uri => task.uri begin @dataset = OpenTox::Dataset.create(nil, subjectid) # check format by extension - not all browsers provide correct content-type]) diff --git a/model.rb b/model.rb index 7b91bab..5332629 100644 --- a/model.rb +++ b/model.rb @@ -1,12 +1,7 @@ require 'ohm' -#require 'redis/objects' -#@@redis = Redis.new(:thread_safe=>true)#(:host => '127.0.0.1', :port => 6379) class ToxCreateModel < Ohm::Model - #include Redis::Objects - #include DataMapper::Resource - #attribute :id attribute :name attribute :warnings attribute :error_messages @@ -49,45 +44,6 @@ class ToxCreateModel < Ohm::Model #after :save, :check_policy -=begin - attr_accessor :id, :name, :warnings, :error_messages, :type, :status, :created_at, :task_uri, :uri, :training_dataset, :feature_dataset, :validation_task_uri, :validation_uri, :validation_report_task_uri, :validation_report_uri, :validation_qmrf_task_uri, :validation_qmrf_uri, :nr_compounds, :nr_predictions, :true_positives, :false_positives, :true_negatives, :false_negatives, :correct_predictions, :weighted_area_under_roc, :sensitivity, :specificity, :r_square, :root_mean_squared_error, :mean_absolute_error, :web_uri - - def self.all - end - - def self.get(id) - end - - def self.create(params) - @id = @@redis.incr "toxcreate" - params.each { |k,v| @@redis.hset "toxcreate:#{@id}", k, v } - self.get(@id) - end - - def update(params) - end - - def method_missing - begin - rescue - raise "Unknown method" - end - end - - attr_accessor :subjectid - @subjectid = nil - - after :save, :check_policy - -def status - #begin - RestClient.get(File.join(@task_uri, 'hasStatus')).body - #rescue - # "Service offline" - #end - end -=end - def validation_status begin RestClient.get(File.join(@validation_task_uri, 'hasStatus')).body @@ -112,115 +68,6 @@ def status end end - def algorithm - begin - RestClient.get(File.join(@uri, 'algorithm')).body - rescue - "" - end - end - - def training_dataset - begin - RestClient.get(File.join(@uri, 'trainingDataset')).body - rescue - "" - end - end - - def feature_dataset - begin - RestClient.get(File.join(@uri, 'feature_dataset')).body - rescue - "" - end - end - -=begin - def process - - LOGGER.debug self.to_yaml - - if @uri.nil? and status == "Completed" - #update :uri => RestClient.get(File.join(@task_uri, 'resultURI')).body - #lazar = YAML.load(RestClient.get(@uri, :accept => "application/x-yaml").body) - - elsif @validation_uri.nil? and validation_status == "Completed" - begin - - #update :validation_uri => RestClient.get(File.join(@validation_task_uri, 'resultURI')).body - #LOGGER.debug "Validation URI: #{@validation_uri}" - - #update :validation_report_task_uri => RestClient.post(File.join(CONFIG[:services]["opentox-validation"],"/report/crossvalidation"), :validation_uris => @validation_uri).body - #LOGGER.debug "Validation Report Task URI: #{@validation_report_task_uri}" - - #update :validation_qmrf_task_uri => RestClient.post(File.join(CONFIG[:services]["opentox-validation"],"/reach_report/qmrf"), :model_uri => @uri).body - #LOGGER.debug "QMRF Report Task URI: #{@validation_qmrf_task_uri}" - - uri = File.join(@validation_uri, 'statistics') - yaml = RestClient.get(uri).body - v = YAML.load(yaml) - - case type - when "classification" - tp=0; tn=0; fp=0; fn=0; n=0 - v[:classification_statistics][:confusion_matrix][:confusion_matrix_cell].each do |cell| - if cell[:confusion_matrix_predicted] == "true" and cell[:confusion_matrix_actual] == "true" - tp = cell[:confusion_matrix_value] - n += tp - elsif cell[:confusion_matrix_predicted] == "false" and cell[:confusion_matrix_actual] == "false" - tn = cell[:confusion_matrix_value] - n += tn - elsif cell[:confusion_matrix_predicted] == "false" and cell[:confusion_matrix_actual] == "true" - fn = cell[:confusion_matrix_value] - n += fn - elsif cell[:confusion_matrix_predicted] == "true" and cell[:confusion_matrix_actual] == "false" - fp = cell[:confusion_matrix_value] - n += fp - end - end - update :nr_predictions => n - update :true_positives => tp - update :false_positives => fp - update :true_negatives => tn - update :false_negatives => fn - update :correct_predictions => 100*(tp+tn).to_f/n - update :weighted_area_under_roc => v[:classification_statistics][:weighted_area_under_roc].to_f - update :sensitivity => tp.to_f/(tp+fn) - update :specificity => tn.to_f/(tn+fp) - when "regression" - update :nr_predictions => v[:num_instances] - v[:num_unpredicted] - update :r_square => v[:regression_statistics][:r_square] - update :root_mean_squared_error => v[:regression_statistics][:root_mean_squared_error] - update :mean_absolute_error => v[:regression_statistics][:mean_absolute_error] - end - rescue - LOGGER.warn "Cannot create Validation Report Task #{@validation_report_task_uri} for Validation URI #{@validation_uri} from Task #{@validation_task_uri}" - end - - else - - if @validation_report_uri.nil? and validation_report_status == "Completed" - begin - update :validation_report_uri => RestClient.get(File.join(@validation_report_task_uri, 'resultURI')).body - rescue - LOGGER.warn "Cannot create Validation Report for Task URI #{@validation_report_task_uri} " - end - end - - if @validation_qmrf_uri.nil? and validation_qmrf_status == "Completed" - begin - update :validation_qmrf_uri => RestClient.get(File.join(@validation_qmrf_task_uri, 'resultURI')).body - rescue - LOGGER.warn "Cannot create QMRF Report for Task URI #{@validation_qmrf_task_uri} " - end - end - - end - - end -=end - private def check_policy OpenTox::Authorization.check_policy(web_uri, subjectid) @@ -228,4 +75,3 @@ def status end -#DataMapper.auto_upgrade! diff --git a/public/progressbar/progressbar.css b/public/progressbar/progressbar.css index 92e3f82..f3b4131 100644 --- a/public/progressbar/progressbar.css +++ b/public/progressbar/progressbar.css @@ -11,7 +11,9 @@ /* Layout helpers ----------------------------------*/ .ui-helper-hidden { display: none; } +/* .ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); } +*/ .ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } .ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } .ui-helper-clearfix { display: inline-block; } @@ -19,8 +21,9 @@ * html .ui-helper-clearfix { height:1%; } .ui-helper-clearfix { display:block; } /* end clearfix */ +/* .ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } - +*/ /* Interaction Cues ----------------------------------*/ @@ -40,7 +43,6 @@ /* Overlays */ .ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } - /* * jQuery UI CSS Framework 1.8.9 * @@ -82,8 +84,10 @@ .ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #cd0a0a; } .ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #cd0a0a; } .ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } +/* .ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } .ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } +*/ /* Icons ----------------------------------*/ @@ -280,6 +284,7 @@ ----------------------------------*/ /* Corner radius */ +/* .ui-corner-tl { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; } .ui-corner-tr { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; } .ui-corner-bl { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; } @@ -289,10 +294,17 @@ .ui-corner-right { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } .ui-corner-left { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; } .ui-corner-all { -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } +*/ /* Overlays */ +/* .ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); } -.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/* +.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; } +*/ +.ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; } +.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; } + +/* * jQuery UI Progressbar 1.8.9 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) @@ -302,4 +314,4 @@ * http://docs.jquery.com/UI/Progressbar#theming */ .ui-progressbar { height:20px; text-align: left; } -.ui-progressbar .ui-progressbar-value {margin: -1px; height:20px; } \ No newline at end of file +.ui-progressbar .ui-progressbar-value {margin: -1px; height:20px; } diff --git a/views/create.haml b/views/create.haml index c04f841..82f48d0 100644 --- a/views/create.haml +++ b/views/create.haml @@ -1,17 +1,16 @@ .input - %p - This service creates - %ul - %li - = toggle_link("#lazar_description","lazar") - %em= toggle_link("#classification","classification") - models and - %li - = toggle_link("#lazar_description","lazar") - %em= toggle_link("#regression","regression") - models - from your uploaded datasets. Further modelling algorithms will be added in future versions. + This service creates + %ul + %li + = toggle_link("#lazar_description","lazar") + %em= toggle_link("#classification","classification") + models and + %li + = toggle_link("#lazar_description","lazar") + %em= toggle_link("#regression","regression") + models + from your uploaded datasets. Further modelling algorithms will be added in future versions. %p Please read the diff --git a/views/help.haml b/views/help.haml index a8bbf4b..da6495e 100644 --- a/views/help.haml +++ b/views/help.haml @@ -2,7 +2,7 @@ %p Input files have two columns. Enter in the first column the chemical structure in %a{:href => "http://en.wikipedia.org/wiki/Simplified_molecular_input_line_entry_specification"} SMILES - format, in the second column the toxic activity. + format, in the second column the toxic activity. The first line contains a description of the columns and is ignored. %dl %dt Classification datasets %dd Please use 1/0, active/inactive or true/false to indicate active/inactive compounds. @@ -33,6 +33,11 @@ %td %th A %th B + %tr + - n += 1 + %th= n + %td SMILES + %td Hamster Carcinogenicity %tr - n += 1 %th= n @@ -87,6 +92,7 @@ .code %code + %br SMILES, Hamster Carcinogenicity %br CC(=O)Nc1ccc(O)cc1, 1 %br O=c1[nH]cnc2[nH]ncc12, 1 %br CCCCNc1cc(cc(c1Oc2ccccc2)S(=O)(=O)N)C(=O)O, 1 diff --git a/views/layout.haml b/views/layout.haml index d54b413..d9d7783 100644 --- a/views/layout.haml +++ b/views/layout.haml @@ -1,8 +1,8 @@ -!!! +!!! %html{:xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", :lang => "en"} %head - %meta{'http-equiv' => 'Content-Type', :content => 'text/html'} + %meta{'http-equiv' => 'Content-Type', :content => 'text/html; charset=UTF-8'} %title ToxCreate %script{:type => "text/javascript", :src => "javascripts/jquery.js"} %script{:type => "text/javascript", :src => "javascripts/toxcreate.js"} @@ -12,7 +12,7 @@ %body .logo - = image_tag "/ToxCreate_rgb_72.png", :alt => 'ToxCreate', :align => 'right' + %img{:src => "ToxCreate_rgb_72.png", :alt => 'ToxCreate', :align => 'right'}/ %br Create and evaluate models to predict toxicity .index @@ -37,7 +37,7 @@ - if `hostname`.match(/ot-test/) .notice This service is for testing purposes only - once a week all models will be deleted. Please send bug reports and feature requests to our - %a{:href => 'http://github.com/helma/opentox-toxmodel/issues'} issue tracker. + %a{:href => 'http://github.com/opentox/opentox-toxmodel/issues'} issue tracker. - if flash[:notice] %p diff --git a/views/lazar_description.haml b/views/lazar_description.haml index d870425..d8e995d 100644 --- a/views/lazar_description.haml +++ b/views/lazar_description.haml @@ -5,25 +5,24 @@ = hide_link "#lazar_description" ) %dd - %p - %code lazar - searches the training dataset for - = toggle_link "#similarity", "similar" - compounds - %em (neighbors) - and calculates the prediction from their measured activities. - %code lazar - calculates predictions using - %ul - %li - a majority vote (weighted by compound similarity) for - %em= toggle_link("#classification","classification") - ( - %a{:href => "http://www.in-silico.de/articles/modi020905.pdf"} original publication - ) - %li - a local QSAR model based on neighbors for - %em= toggle_link("#regression","regression") - ( - %a{:href => "http://www.in-silico.de/articles/mh_tf.pdf"} original publication - ) + %code lazar + searches the training dataset for + = toggle_link "#similarity", "similar" + compounds + %em (neighbors) + and calculates the prediction from their measured activities. + %code lazar + calculates predictions using + %ul + %li + a majority vote (weighted by compound similarity) for + %em= toggle_link("#classification","classification") + ( + %a{:href => "http://www.in-silico.de/articles/modi020905.pdf"} original publication + ) + %li + a local QSAR model based on neighbors for + %em= toggle_link("#regression","regression") + ( + %a{:href => "http://www.in-silico.de/articles/mh_tf.pdf"} original publication + ) diff --git a/views/model.haml b/views/model.haml index 5addcb0..91d7016 100644 --- a/views/model.haml +++ b/views/model.haml @@ -83,4 +83,5 @@ %a{:href => File.join(model.validation_qmrf_uri,"editor")} QMRF Editor, %a{:href => "#{model.uri}.yaml#{subjectstring}"} YAML %em (experts, models cannot be represented in Excel) - = haml :validation, :locals=>{:model=>model,:subjectstring => subjectstring}, :layout => false + + = haml :validation, :locals=>{:model=>model,:subjectstring => subjectstring}, :layout => false diff --git a/views/models.haml b/views/models.haml index a99144a..67c061c 100644 --- a/views/models.haml +++ b/views/models.haml @@ -10,12 +10,14 @@ }); -# %p Get an overview about ToxCreate models. This page is refreshed every 15 seconds to update the model status. -%p Get an overview about ToxCreate models. This page is refreshed every 5 seconds to update the model status. +%p Get an overview about ToxCreate models. Parts of this page are refreshed every 5 seconds to update the model status. -# explanations = haml :lazar_description, :layout => false = haml :classification, :layout => false = haml :regression, :layout => false += haml :similarity, :layout => false += haml :significant_fragments, :layout => false - @models.each do |model| = haml :model, :locals=>{:model=>model,:subjectstring=>subjectstring}, :layout => false diff --git a/views/predict.haml b/views/predict.haml index 347592c..d8c34a2 100644 --- a/views/predict.haml +++ b/views/predict.haml @@ -16,7 +16,7 @@ .jme %applet{:code => "JME.class", :name => "JME", :archive => "JME.jar", :width => "500", :height => "360"} %param{ :name => "options", :value => "polarnitro"} - Please enable Java and JavaScript in your browser to use the JME editor. + Please enable Java and JavaScript in your browser to use the JME editor. %label{:for => 'identifier'} or enter a Name, InChI, Smiles, CAS, ... %input{:type => 'text', :name => 'identifier', :id => 'identifier', :size => '60'} @@ -24,10 +24,10 @@ %legend Choose one or more prediction models - @models.each do |model| - %label{:for => model.id} + %label{:for => "model#{model.id}"} = model.name -#%input{:type => 'checkbox', :name => "selection[#{model.id}]", :value => true, :id => model.id, :disabled => !is_authorized(model.uri, "GET")} - %input{:type => 'checkbox', :name => "selection[#{model.id}]", :value => true, :id => model.id, :disabled => false} + %input{:type => 'checkbox', :name => "selection[#{model.id}]", :value => true, :id => "model#{model.id}", :disabled => false} %br %input{:type => 'hidden', :name => 'subjectid', :id => 'subjectid', :value => session[:subjectid]} diff --git a/views/validation.haml b/views/validation.haml index 06a57e7..b8a6eaa 100644 --- a/views/validation.haml +++ b/views/validation.haml @@ -2,22 +2,16 @@ %dl{:id => "model_validation_#{model.id}"} %dt Validation: - -# %input{ :id => "model_validation_report_#{model.id}", :type => "hidden", :value => "#{model.validation_report_status}", :class => "model_validation_report" } %dd %dl - if model.validation_report_uri %dt Detailed report: %dd %a{:href => model.validation_report_uri + subjectstring, :target => "_blank"} show - %dt Number of predictions + %dt Number of predictions: %dd= model.nr_predictions.to_s - case model.type - when "classification" = haml :classification_validation, :locals=>{:model=>model}, :layout => false if model.correct_predictions - when "regression" = haml :regression_validation, :locals=>{:model=>model}, :layout => false --# else - = image_tag("/snake_transparent.gif") if model.validation_status == "Running" - %a{:href => model.validation_task_uri} #{model.validation_status} - - -- cgit v1.2.3