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
78
79
80
81
82
83
|
module OpenTox
module Model
class Lazar
include Owl
# Create a new prediction model from a dataset
def initialize
super
self.source = "http://github.com/helma/opentox-model"
self.algorithm = File.join(@@config[:services]["opentox-algorithm"],"lazar")
self.independentVariables = File.join(@@config[:services]["opentox-algorithm"],"fminer#BBRC_representative") # TODO read this from dataset
end
def self.from_yaml(yaml)
yaml = YAML.load yaml
lazar = Lazar.new
lazar.title = "lazar model for #{yaml[:endpoint]}"
lazar.parameters = {
"Dataset URI" => { :scope => "mandatory", :value => "dataset_uri=#{yaml[:activity_dataset]}" },
"Feature URI for dependent variable" => { :scope => "mandatory", :value => "feature_uri=#{yaml[:endpoint]}" },
"Feature generation URI" => { :scope => "mandatory", :value => "feature_generation_uri=#{File.join(@@config[:services]["opentox-algorithm"],"fminer")}"} #TODO write to yaml
}
lazar.algorithm = File.join(@@config[:services]["opentox-algorithm"],"lazar")
lazar.trainingDataset = yaml[:activity_dataset]
lazar.dependentVariables = yaml[:endpoint]
lazar.predictedVariables = yaml[:endpoint] #+ " lazar prediction"
lazar
end
def self.find_all
RestClient.get(@@config[:services]["opentox-model"]).split("\n")
end
# Predict a compound
def predict(compound)
RestClient.post(@uri, :compound_uri => compound.uri)
end
def self.base_uri
@@config[:services]["opentox-model"]
end
def self.create(data)
RestClient.post(@@config[:services]["opentox-model"], data, :content_type => "application/x-yaml").to_s
end
def endpoint
YAML.load(RestClient.get uri)[:endpoint]
end
def algorithm=(algorithm)
me = @model.subject(RDF['type'],OT[self.owl_class])
@model.add me, OT['algorithm'], Redland::Uri.new(algorithm) # untyped individual comes from this line, why??
@model.add Redland::Uri.new(algorithm), RDF['type'], OT['Algorithm']
end
def trainingDataset=(trainingDataset)
me = @model.subject(RDF['type'],OT[self.owl_class])
@model.add me, OT['trainingDataset'], Redland::Uri.new(trainingDataset) # untyped individual comes from this line, why??
@model.add Redland::Uri.new(trainingDataset), RDF['type'], OT['Dataset']
end
def dependentVariables=(dependentVariables)
me = @model.subject(RDF['type'],OT[self.owl_class])
@model.add me, OT['dependentVariables'], Redland::Uri.new(dependentVariables) # untyped individual comes from this line, why??
@model.add Redland::Uri.new(dependentVariables), RDF['type'], OT['Feature']
end
def independentVariables=(independentVariables)
me = @model.subject(RDF['type'],OT[self.owl_class])
@model.add me, OT['independentVariables'], Redland::Uri.new(independentVariables) # untyped individual comes from this line, why??
@model.add Redland::Uri.new(independentVariables), RDF['type'], OT['Feature']
end
def predictedVariables=(predictedVariables)
me = @model.subject(RDF['type'],OT[self.owl_class])
@model.add me, OT['predictedVariables'], Redland::Uri.new(predictedVariables) # untyped individual comes from this line, why??
@model.add Redland::Uri.new(predictedVariables), RDF['type'], OT['Feature']
end
end
end
end
|