diff options
author | mr <mr@mrautenberg.de> | 2011-03-21 09:46:08 +0100 |
---|---|---|
committer | mr <mr@mrautenberg.de> | 2011-03-21 09:46:08 +0100 |
commit | 0ed50191f815fce11816044864a045a31194d8b4 (patch) | |
tree | 4c18cd10a221bab6afd5c552b71ebfa9f571c802 | |
parent | d8d49429f3d913fea56a631ac0a5b61c80916424 (diff) | |
parent | a799b1021f8da298f76aba6482f4ea35a3a1c67f (diff) |
merge with opentox/development
-rw-r--r-- | helper.rb | 2 | ||||
-rw-r--r-- | model.rb | 152 | ||||
-rw-r--r-- | public/progressbar/progressbar.css | 24 | ||||
-rw-r--r-- | views/create.haml | 23 | ||||
-rw-r--r-- | views/help.haml | 8 | ||||
-rw-r--r-- | views/layout.haml | 8 | ||||
-rw-r--r-- | views/lazar_description.haml | 43 | ||||
-rw-r--r-- | views/model.haml | 3 | ||||
-rw-r--r-- | views/models.haml | 4 | ||||
-rw-r--r-- | views/predict.haml | 6 | ||||
-rw-r--r-- | views/validation.haml | 8 |
11 files changed, 73 insertions, 208 deletions
@@ -32,7 +32,7 @@ helpers do def is_authorized(uri, action) if OpenTox::Authorization.server && session[:subjectid] != nil - return OpenTox::Authorization.authorize(uri, action, session[:subjectid]) + return OpenTox::Authorization.authorized?(uri, action, session[:subjectid]) else return true end @@ -5,9 +5,6 @@ require 'ohm/contrib' class ToxCreateModel < Ohm::Model - #include Redis::Objects - #include DataMapper::Resource - #attribute :id include Ohm::Callbacks include Ohm::Typecast include Ohm::Timestamping @@ -54,45 +51,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 @@ -117,115 +75,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) @@ -233,4 +82,3 @@ def status end -#DataMapper.auto_upgrade! diff --git a/public/progressbar/progressbar.css b/public/progressbar/progressbar.css index 962abbc..d19839d 100644 --- a/public/progressbar/progressbar.css +++ b/public/progressbar/progressbar.css @@ -19,8 +19,8 @@ * 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; } +.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; } /* Interaction Cues ----------------------------------*/ @@ -40,7 +40,6 @@ /* Overlays */ .ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } - /* * jQuery UI CSS Framework 1.8.9 * @@ -279,9 +278,28 @@ /* Misc visuals ----------------------------------*/ + /* Overlays */ .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;}/* +/* 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; } +.ui-corner-br { -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.ui-corner-top { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; } +.ui-corner-bottom { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.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; } + * jQuery UI Progressbar 1.8.9 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) @@ -291,4 +309,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. @@ -36,6 +36,11 @@ %tr - n += 1 %th= n + %td SMILES + %td Hamster Carcinogenicity + %tr + - n += 1 + %th= n %td CC(=O)Nc1ccc(O)cc1 %td 1 %tr @@ -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 5ecc86b..7b63975 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 268cda2..6724807 100644 --- a/views/models.haml +++ b/views/models.haml @@ -9,14 +9,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 :classification, :layout => false = haml :lazar_description, :layout => false = haml :regression, :layout => false -= haml :significant_fragments, :layout => false = haml :similarity, :layout => false += haml :significant_fragments, :layout => false - if @models - @models.each do |model| 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} - - |