summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2010-09-13 18:23:45 +0200
committerChristoph Helma <helma@in-silico.ch>2010-09-13 18:23:45 +0200
commitd214692e1828471084b00af4115a06196c6578f7 (patch)
tree516095a852cd322635af2e74b951b3bc6d312cb9
parent5c5d66c2a9487687ba9032da04031ad59ab1de46 (diff)
RDF/XML download disabled, QMRF report generation enabled
-rw-r--r--application.rb7
-rw-r--r--model.rb117
-rw-r--r--views/model.haml14
-rw-r--r--views/style.sass2
4 files changed, 55 insertions, 85 deletions
diff --git a/application.rb b/application.rb
index 9616841..7a18fd5 100644
--- a/application.rb
+++ b/application.rb
@@ -58,13 +58,6 @@ get '/model/:id/:view/?' do
haml :model, :locals=>{:model=>model}, :layout => false
when /validation/
haml :validation, :locals=>{:model=>model}, :layout => false
- #if model.type == "classification"
- #haml :classification_validation, :locals=>{:model=>model}, :layout => false
- #elsif model.type == "regression"
- #haml :regression_validation, :locals=>{:model=>model}, :layout => false
- #else
- #return "Unknown model type '#{model.type}'"
- #end
else
return "unable to render model: id #{params[:id]}, view #{params[:view]}"
end
diff --git a/model.rb b/model.rb
index 99d6ab3..da12f0b 100644
--- a/model.rb
+++ b/model.rb
@@ -1,15 +1,25 @@
class ToxCreateModel
include DataMapper::Resource
+
property :id, Serial
property :name, String, :length => 255
- property :uri, String, :length => 255
+ property :warnings, Text, :length => 2**32-1
+ property :type, String
+ property :created_at, DateTime
+
property :task_uri, String, :length => 255
+ property :uri, String, :length => 255
+
property :validation_task_uri, String, :length => 255
property :validation_uri, String, :length => 255
+
property :validation_report_task_uri, String, :length => 255
property :validation_report_uri, String, :length => 255
- property :warnings, Text, :length => 2**32-1
+
+ property :validation_qmrf_task_uri, String, :length => 255
+ property :validation_qmrf_uri, String, :length => 255
+
property :nr_compounds, Integer
property :nr_predictions, Integer
property :true_positives, Integer
@@ -23,8 +33,6 @@ class ToxCreateModel
property :r_square, Float
property :root_mean_squared_error, Float
property :mean_absolute_error, Float
- property :type, String
- property :created_at, DateTime
def status
#begin
@@ -50,6 +58,14 @@ class ToxCreateModel
end
end
+ def validation_qmrf_status
+ begin
+ RestClient.get(File.join(@validation_qmrf_task_uri, 'hasStatus')).body
+ rescue
+ "Service offline"
+ end
+ end
+
def algorithm
begin
RestClient.get(File.join(@uri, 'algorithm')).body
@@ -74,64 +90,6 @@ class ToxCreateModel
end
end
-=begin
- def classification_validation
- begin
- uri = File.join(@validation_uri, 'statistics')
- yaml = RestClient.get(uri).body
- v = YAML.load(yaml)
- 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
- @nr_predictions = n
- @true_positives = tp
- @false_positives = fp
- @true_negatives = tn
- @false_negatives = fn
- @correct_predictions = 100*(tp+tn).to_f/n
- @weighted_area_under_roc = v[:classification_statistics][:weighted_area_under_roc].to_f
- @sensitivity = tp.to_f/(tp+fn)
- @specificity = tn.to_f/(tn+fp)
- save
- #:correct_predictions => sprintf("%.2f", 100*(tp+tn).to_f/n),
- #:weighted_area_under_roc => sprintf("%.3f", v[:classification_statistics][:weighted_area_under_roc].to_f),
- #:sensitivity => sprintf("%.3f", tp.to_f/(tp+fn)),
- #:specificity => sprintf("%.3f", tn.to_f/(tn+fp))
- #}
- rescue
- "Service offline"
- end
- end
-
- def regression_validation
- begin
- uri = File.join(@validation_uri, 'statistics')
- yaml = RestClient.get(uri).body
- v = YAML.load(yaml)
- @nr_predictions = v[:num_instances] - v[:num_unpredicted]
- @r_square = v[:regression_statistics][:r_square]
- @root_mean_squared_error = v[:regression_statistics][:root_mean_squared_error]
- @mean_absolute_error = v[:regression_statistics][:mean_absolute_error]
- save
- rescue
- "Service offline"
- end
- end
-=end
-
def process
if @uri.nil? and status == "Completed"
@@ -148,13 +106,20 @@ class ToxCreateModel
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
@@ -192,15 +157,25 @@ class ToxCreateModel
LOGGER.warn "Cannot create Validation Report Task #{@validation_report_task_uri} for Validation URI #{@validation_uri} from Task #{@validation_task_uri}"
end
- elsif @validation_report_uri.nil? and validation_report_status == "Completed"
- begin
- LOGGER.debug File.join(@validation_report_task_uri, 'resultURI')
- LOGGER.debug "Report URI: "+RestClient.get(File.join(@validation_report_task_uri, 'resultURI')).body
- 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
+ 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
diff --git a/views/model.haml b/views/model.haml
index 454423a..0c8ea8f 100644
--- a/views/model.haml
+++ b/views/model.haml
@@ -42,20 +42,22 @@
%dd
%a{:href => "#{model.training_dataset}.xls"} Excel sheet
,
- %a{:href => "#{model.training_dataset}.rdf"} RDF/XML
- %em (experts) ,
+ -#%a{:href => "#{model.training_dataset}.rdf"} RDF/XML
+ -#%em (experts) ,
%a{:href => "#{model.training_dataset}.yaml"} YAML
%em (experts)
%dt Feature dataset:
%dd
- %a{:href => "#{model.feature_dataset}.rdf"} RDF/XML
- ,
+ -#%a{:href => "#{model.feature_dataset}.rdf"} RDF/XML
+ -#,
%a{:href => "#{model.feature_dataset}.yaml"} YAML
%em (experts, dataset too large for Excel)
%dt Model:
%dd
- %a{:href => "#{model.uri}.rdf"} RDF/XML
- ,
+ -#%a{:href => "#{model.uri}.rdf"} RDF/XML
+ -#,
+ - unless model.validation_qmrf_uri.nil?
+ %a{:href => File.join(model.validation_qmrf_uri,"editor")} QMRF Editor,
%a{:href => "#{model.uri}.yaml"} YAML
%em (experts, models cannot be represented in Excel)
= haml :validation, :locals=>{:model=>model}, :layout => false
diff --git a/views/style.sass b/views/style.sass
index ea9e65a..5f362a3 100644
--- a/views/style.sass
+++ b/views/style.sass
@@ -85,7 +85,7 @@ body
font-weight: bold
color: $fg_color
label
- width: 25em
+ width: 28em
display: block
float: left
br