summaryrefslogtreecommitdiff
path: root/model.rb
blob: 5332629e840d1b88e3a2cdf414f178df53a174bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
require 'ohm'

class ToxCreateModel < Ohm::Model

	attribute :name
	attribute :warnings
	attribute :error_messages
	attribute :type
  attribute :status
	attribute :created_at

	attribute :task_uri
	attribute :uri

	attribute :training_dataset
	attribute :feature_dataset
	#attributey :validation_task_uri
	attribute :validation_uri

	#attributey :validation_report_task_uri
	attribute :validation_report_uri

	#attributey :validation_qmrf_task_uri
	attribute :validation_qmrf_uri

	attribute :nr_compounds
	attribute :nr_predictions
	attribute :true_positives
	attribute :false_positives
	attribute :true_negatives
	attribute :false_negatives
	attribute :correct_predictions
	attribute :weighted_area_under_roc
	attribute :sensitivity
	attribute :specificity
	attribute :r_square
	attribute :root_mean_squared_error
	attribute :mean_absolute_error

  attribute :web_uri

  attr_accessor :subjectid
  @subjectid = nil

  #after :save, :check_policy

	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 validation_qmrf_status
		begin
			RestClient.get(File.join(@validation_qmrf_task_uri, 'hasStatus')).body
		rescue
			"Service offline"
		end
	end

  private
  def check_policy
    OpenTox::Authorization.check_policy(web_uri, subjectid)
  end

end