summaryrefslogtreecommitdiff
path: root/application.rb
diff options
context:
space:
mode:
authorgebele <gebele@alfadeo.de>2010-07-20 09:54:17 +0200
committergebele <gebele@alfadeo.de>2010-07-20 09:54:17 +0200
commit949748180cceddded909900f65e9ca75de969779 (patch)
treec8da0d84e2a159b4341d25c6f69745c894f0e625 /application.rb
parentcf793f4d2645b0785b7e3dae00119e7ab2112327 (diff)
merge fix in application.rb
Diffstat (limited to 'application.rb')
-rw-r--r--application.rb137
1 files changed, 0 insertions, 137 deletions
diff --git a/application.rb b/application.rb
index ec9962d..3156fcd 100644
--- a/application.rb
+++ b/application.rb
@@ -21,143 +21,6 @@ get '/stylesheets/style.css' do
sass :style
end
-class ToxCreateModel
- include DataMapper::Resource
- property :id, Serial
- property :name, String, :length => 255
- property :uri, String, :length => 255
- property :task_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 :nr_compounds, Integer
- property :created_at, DateTime
-
- def status
- RestClient.get(File.join(@task_uri, 'hasStatus')).body
- end
-
- def validation_status
- begin
- RestClient.get(File.join(@validation_task_uri, 'hasStatus')).body
- rescue
- "Service offline"
- end
- end
-
- def validation_report_status
- begin
- RestClient.get(File.join(@validation_report_task_uri, 'hasStatus')).body
- rescue
- "Service offline"
- 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
-
- def 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
- {
- :n => n,
- :tp => tp,
- :fp => fp,
- :tn => tn,
- :fn => fn,
- :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
-
-end
-
-DataMapper.auto_upgrade!
-
-helpers do
- def activity(a)
- case a.to_s
- when "true"
- act = "active"
- when "false"
- act = "inactive"
- else
- act = "not available"
- end
- act
- end
-
- def process_model(model)
- if !model.uri and model.status == "Completed"
- model.uri = RestClient.get(File.join(model.task_uri, 'resultURI')).body
- model.save
- end
- #unless @@config[:services]["opentox-model"].match(/localhost/)
- if !model.validation_uri and model.validation_status == "Completed"
- begin
- model.validation_uri = RestClient.get(File.join(model.validation_task_uri, 'resultURI')).body
- LOGGER.debug "Validation URI: #{model.validation_uri}"
- model.validation_report_task_uri = RestClient.post(File.join(@@config[:services]["opentox-validation"],"/report/crossvalidation"), :validation_uris => model.validation_uri).body
- LOGGER.debug "Validation Report Task URI: #{model.validation_report_task_uri}"
- model.save
- rescue
- end
- end
- if model.validation_report_task_uri and !model.validation_report_uri and model.validation_report_status == 'Completed'
- model.validation_report_uri = RestClient.get(File.join(model.validation_report_task_uri, 'resultURI')).body
- end
- #end
- end
-end
-
-=======
->>>>>>> helma/master
get '/?' do
redirect url_for('/create')
end