opentox-ruby 2.1.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/algorithm.rb +1 -1
- data/lib/authorization.rb +1 -1
- data/lib/dataset.rb +36 -9
- data/lib/environment.rb +9 -2
- data/lib/feature.rb +14 -3
- data/lib/helper.rb +38 -5
- data/lib/model.rb +45 -12
- data/lib/ontology.rb +98 -16
- data/lib/opentox.rb +8 -7
- data/lib/serializer.rb +40 -31
- data/lib/task.rb +2 -2
- data/lib/to-html.rb +9 -8
- metadata +7 -10
- data/bin/opentox-install-debian.sh +0 -105
- data/bin/opentox-install-ubuntu.sh +0 -375
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.0
|
data/lib/algorithm.rb
CHANGED
@@ -927,7 +927,7 @@ module OpenTox
|
|
927
927
|
# @param [Array] Array to test, must indicate non-occurrence with 0.
|
928
928
|
# @return [Boolean] Whether the feature has variance zero.
|
929
929
|
def self.zero_variance?(array)
|
930
|
-
return (array.to_scale.
|
930
|
+
return (array.to_scale.variance_population == 0.0)
|
931
931
|
end
|
932
932
|
|
933
933
|
# Sum of an array for Arrays.
|
data/lib/authorization.rb
CHANGED
data/lib/dataset.rb
CHANGED
@@ -46,6 +46,12 @@ module OpenTox
|
|
46
46
|
dataset.save(subjectid)
|
47
47
|
dataset
|
48
48
|
end
|
49
|
+
|
50
|
+
def self.from_json(json, subjectid=nil)
|
51
|
+
dataset = Dataset.new(nil,subjectid)
|
52
|
+
dataset.copy_hash Yajl::Parser.parse(json)
|
53
|
+
dataset
|
54
|
+
end
|
49
55
|
|
50
56
|
# Find a dataset and load all data. This can be time consuming, use Dataset.new together with one of the load_* methods for a fine grained control over data loading.
|
51
57
|
# @param [String] uri Dataset URI
|
@@ -84,12 +90,16 @@ module OpenTox
|
|
84
90
|
copy YAML.load(yaml)
|
85
91
|
end
|
86
92
|
|
87
|
-
def
|
93
|
+
def load_json(json)
|
94
|
+
copy_hash Yajl::Parser.parse(json)
|
95
|
+
end
|
96
|
+
|
97
|
+
def load_rdfxml(rdfxml, subjectid=nil)
|
88
98
|
raise "rdfxml data is empty" if rdfxml.to_s.size==0
|
89
99
|
file = Tempfile.new("ot-rdfxml")
|
90
100
|
file.puts rdfxml
|
91
101
|
file.close
|
92
|
-
load_rdfxml_file file
|
102
|
+
load_rdfxml_file file, subjectid
|
93
103
|
file.delete
|
94
104
|
end
|
95
105
|
|
@@ -145,8 +155,8 @@ module OpenTox
|
|
145
155
|
|
146
156
|
# Load all data (metadata, data_entries, compounds and features) from URI
|
147
157
|
def load_all(subjectid=nil)
|
148
|
-
if (CONFIG[:
|
149
|
-
|
158
|
+
if (CONFIG[:json_hosts].include?(URI.parse(@uri).host))
|
159
|
+
copy_hash Yajl::Parser.parse(RestClientWrapper.get(@uri, {:accept => "application/json", :subjectid => subjectid}))
|
150
160
|
else
|
151
161
|
parser = Parser::Owl::Dataset.new(@uri, subjectid)
|
152
162
|
copy parser.load_uri(subjectid)
|
@@ -169,8 +179,8 @@ module OpenTox
|
|
169
179
|
# Load and return only features from the dataset service
|
170
180
|
# @return [Hash] Features of the dataset
|
171
181
|
def load_features(subjectid=nil)
|
172
|
-
if (CONFIG[:
|
173
|
-
@features =
|
182
|
+
if (CONFIG[:json_hosts].include?(URI.parse(@uri).host))
|
183
|
+
@features = Yajl::Parser.parse(RestClientWrapper.get(File.join(@uri,"features"), {:accept => "application/json", :subjectid => subjectid}))
|
174
184
|
else
|
175
185
|
parser = Parser::Owl::Dataset.new(@uri, subjectid)
|
176
186
|
@features = parser.load_features(subjectid)
|
@@ -203,6 +213,10 @@ module OpenTox
|
|
203
213
|
=begin
|
204
214
|
=end
|
205
215
|
|
216
|
+
def to_json
|
217
|
+
Yajl::Encoder.encode({:uri => @uri, :metadata => @metadata, :data_entries => @data_entries, :compounds => @compounds, :features => @features})
|
218
|
+
end
|
219
|
+
|
206
220
|
# Get Spreadsheet representation
|
207
221
|
# @return [Spreadsheet::Workbook] Workbook which can be written with the spreadsheet gem (data_entries only, metadata will will be discarded))
|
208
222
|
def to_spreadsheet
|
@@ -358,12 +372,12 @@ module OpenTox
|
|
358
372
|
# TODO: rewrite feature URI's ??
|
359
373
|
@compounds.uniq!
|
360
374
|
if @uri
|
361
|
-
if (CONFIG[:
|
362
|
-
|
375
|
+
if (CONFIG[:json_hosts].include?(URI.parse(@uri).host))
|
376
|
+
#LOGGER.debug self.to_json
|
377
|
+
RestClientWrapper.post(@uri,self.to_json,{:content_type => "application/json", :subjectid => subjectid})
|
363
378
|
else
|
364
379
|
File.open("ot-post-file.rdf","w+") { |f| f.write(self.to_rdfxml); @path = f.path }
|
365
380
|
task_uri = RestClient.post(@uri, {:file => File.new(@path)},{:accept => "text/uri-list" , :subjectid => subjectid}).to_s.chomp
|
366
|
-
#task_uri = `curl -X POST -H "Accept:text/uri-list" -F "file=@#{@path};type=application/rdf+xml" http://apps.ideaconsult.net:8080/ambit2/dataset`
|
367
381
|
Task.find(task_uri).wait_for_completion
|
368
382
|
self.uri = RestClientWrapper.get(task_uri,{:accept => 'text/uri-list', :subjectid => subjectid})
|
369
383
|
end
|
@@ -379,6 +393,19 @@ module OpenTox
|
|
379
393
|
RestClientWrapper.delete(@uri, :subjectid => subjectid)
|
380
394
|
end
|
381
395
|
|
396
|
+
# Copy a hash (eg. from JSON) into a dataset (rewrites URI)
|
397
|
+
def copy_hash(hash)
|
398
|
+
@metadata = hash["metadata"]
|
399
|
+
@data_entries = hash["data_entries"]
|
400
|
+
@compounds = hash["compounds"]
|
401
|
+
@features = hash["features"]
|
402
|
+
if @uri
|
403
|
+
self.uri = @uri
|
404
|
+
else
|
405
|
+
@uri = hash["metadata"][XSD.anyURI]
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
382
409
|
private
|
383
410
|
# Copy a dataset (rewrites URI)
|
384
411
|
def copy(dataset)
|
data/lib/environment.rb
CHANGED
@@ -40,8 +40,8 @@ else
|
|
40
40
|
end
|
41
41
|
|
42
42
|
# Regular expressions for parsing classification data
|
43
|
-
TRUE_REGEXP = /^(true|active|1|1.0|tox|activating)$/i
|
44
|
-
FALSE_REGEXP = /^(false|inactive|0|0.0|low tox|deactivating)$/i
|
43
|
+
TRUE_REGEXP = /^(true|active|1|1.0|tox|activating|carcinogen|mutagenic)$/i
|
44
|
+
FALSE_REGEXP = /^(false|inactive|0|0.0|low tox|deactivating|non-carcinogen|non-mutagenic)$/i
|
45
45
|
|
46
46
|
# Task durations
|
47
47
|
DEFAULT_TASK_MAX_DURATION = 36000
|
@@ -74,6 +74,13 @@ CONFIG[:authorization][:authenticate_request] = [""] unless CONFIG[:authorizatio
|
|
74
74
|
CONFIG[:authorization][:authorize_request] = [""] unless CONFIG[:authorization][:authorize_request]
|
75
75
|
CONFIG[:authorization][:free_request] = [""] unless CONFIG[:authorization][:free_request]
|
76
76
|
|
77
|
+
ONTOLOGY_SERVER = CONFIG[:services]["opentox-ontology"] ? CONFIG[:services]["opentox-ontology"] : "http://apps.ideaconsult.net:8080/ontology"
|
78
|
+
|
79
|
+
cookie_secret = CONFIG[:authorization] ? CONFIG[:authorization][:cookie_secret] : nil
|
80
|
+
cookie_secret = cookie_secret ? cookie_secret : "ui6vaiNi-change_me"
|
81
|
+
use Rack::Session::Cookie, :expire_after => 28800,
|
82
|
+
:secret => cookie_secret
|
83
|
+
|
77
84
|
RDF = OwlNamespace.new 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
|
78
85
|
OWL = OwlNamespace.new 'http://www.w3.org/2002/07/owl#'
|
79
86
|
DC = OwlNamespace.new 'http://purl.org/dc/elements/1.1/'
|
data/lib/feature.rb
CHANGED
@@ -10,7 +10,7 @@ module OpenTox
|
|
10
10
|
def self.find(uri, subjectid=nil)
|
11
11
|
return nil unless uri
|
12
12
|
feature = Feature.new uri
|
13
|
-
if (CONFIG[:
|
13
|
+
if (CONFIG[:json_hosts].include?(URI.parse(uri).host))
|
14
14
|
feature.add_metadata YAML.load(RestClientWrapper.get(uri,{:accept => "application/x-yaml", :subjectid => subjectid}))
|
15
15
|
else
|
16
16
|
feature.add_metadata Parser::Owl::Dataset.new(uri).load_metadata
|
@@ -23,9 +23,9 @@ module OpenTox
|
|
23
23
|
# @return [String] feature type, unknown if OT.isA property is unknown/ not set
|
24
24
|
def feature_type
|
25
25
|
raise OpenTox::BadRequestError.new("rdf type of feature '"+uri.to_s+"' not set") unless metadata[RDF.type]
|
26
|
-
if metadata[RDF.type].flatten.include?(OT.NominalFeature)
|
26
|
+
if metadata[RDF.type].to_a.flatten.include?(OT.NominalFeature)
|
27
27
|
"classification"
|
28
|
-
elsif metadata[RDF.type].flatten.include?(OT.NumericFeature)
|
28
|
+
elsif metadata[RDF.type].to_a.flatten.include?(OT.NumericFeature)
|
29
29
|
"regression"
|
30
30
|
elsif metadata[OWL.sameAs]
|
31
31
|
metadata[OWL.sameAs].each do |f|
|
@@ -42,4 +42,15 @@ module OpenTox
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
|
+
|
46
|
+
# Get OWL-DL representation in RDF/XML format
|
47
|
+
# @return [application/rdf+xml] RDF/XML representation
|
48
|
+
def to_rdfxml
|
49
|
+
s = Serializer::Owl.new
|
50
|
+
s.add_feature(@uri,@metadata)
|
51
|
+
@metadata.values.grep(/model\/\d+$/).each{ |m| s.add_uri(m,OT.Model)}
|
52
|
+
@metadata.values.grep(/feature/).each{ |f| s.add_uri(f,OT.Feature)}
|
53
|
+
#s.add_parameters(@uri,@parameters) if @parameters
|
54
|
+
s.to_rdfxml
|
55
|
+
end
|
45
56
|
end
|
data/lib/helper.rb
CHANGED
@@ -1,4 +1,34 @@
|
|
1
1
|
helpers do
|
2
|
+
|
3
|
+
def login(username, password)
|
4
|
+
logout
|
5
|
+
session[:subjectid] = OpenTox::Authorization.authenticate(username, password)
|
6
|
+
#LOGGER.debug "ToxCreate login user #{username} with subjectid: " + session[:subjectid].to_s
|
7
|
+
if session[:subjectid] != nil
|
8
|
+
session[:username] = username
|
9
|
+
return session[:subjectid]
|
10
|
+
else
|
11
|
+
session[:username] = ""
|
12
|
+
return nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def logout
|
17
|
+
if session[:subjectid] != nil
|
18
|
+
session[:subjectid] = nil
|
19
|
+
session[:username] = ""
|
20
|
+
return true
|
21
|
+
end
|
22
|
+
return false
|
23
|
+
end
|
24
|
+
|
25
|
+
def logged_in()
|
26
|
+
return true if !AA_SERVER
|
27
|
+
if session[:subjectid] != nil
|
28
|
+
return OpenTox::Authorization.is_token_valid(session[:subjectid])
|
29
|
+
end
|
30
|
+
return false
|
31
|
+
end
|
2
32
|
|
3
33
|
# Authentification
|
4
34
|
def protected!(subjectid)
|
@@ -30,9 +60,9 @@ helpers do
|
|
30
60
|
def clean_uri(uri)
|
31
61
|
uri = uri.sub(" ", "%20") #dirty hacks => to fix
|
32
62
|
uri = uri[0,uri.index("InChI=")] if uri.index("InChI=")
|
33
|
-
|
34
63
|
out = URI.parse(uri)
|
35
64
|
out.path = out.path[0, out.path.length - (out.path.reverse.rindex(/\/{1}\d+\/{1}/))] if out.path.index(/\/{1}\d+\/{1}/) #cuts after /id/ for a&a
|
65
|
+
out.path = out.path.split('.').first #cut extension
|
36
66
|
port = (out.scheme=="http" && out.port==80)||(out.scheme=="https" && out.port==443) ? "" : ":#{out.port.to_s}"
|
37
67
|
"#{out.scheme}://#{out.host}#{port}#{out.path.chomp("/")}" #"
|
38
68
|
end
|
@@ -56,15 +86,16 @@ helpers do
|
|
56
86
|
subjectid = session[:subjectid] if session[:subjectid]
|
57
87
|
subjectid = params[:subjectid] if params[:subjectid] and !subjectid
|
58
88
|
subjectid = request.env['HTTP_SUBJECTID'] if request.env['HTTP_SUBJECTID'] and !subjectid
|
59
|
-
subjectid = request.cookies["subjectid"] unless subjectid
|
60
89
|
# see http://rack.rubyforge.org/doc/SPEC.html
|
61
90
|
subjectid = CGI.unescape(subjectid) if subjectid.include?("%23")
|
62
91
|
@subjectid = subjectid
|
63
92
|
rescue
|
64
|
-
subjectid = nil
|
93
|
+
@subjectid = nil
|
65
94
|
end
|
66
95
|
end
|
67
96
|
def get_extension
|
97
|
+
@accept = request.env['HTTP_ACCEPT']
|
98
|
+
@accept = 'application/rdf+xml' if @accept == '*/*' or @accept == '' or @accept.nil?
|
68
99
|
extension = File.extname(request.path_info)
|
69
100
|
unless extension.empty?
|
70
101
|
case extension.gsub(".","")
|
@@ -78,6 +109,8 @@ helpers do
|
|
78
109
|
@accept = 'application/rdf+xml'
|
79
110
|
when "xls"
|
80
111
|
@accept = 'application/ms-excel'
|
112
|
+
when "sdf"
|
113
|
+
@accept = 'chemical/x-mdl-sdfile'
|
81
114
|
when "css"
|
82
115
|
@accept = 'text/css'
|
83
116
|
else
|
@@ -88,8 +121,8 @@ helpers do
|
|
88
121
|
end
|
89
122
|
|
90
123
|
before do
|
91
|
-
|
92
|
-
|
124
|
+
get_subjectid()
|
125
|
+
get_extension()
|
93
126
|
unless !AA_SERVER or login_requests or CONFIG[:authorization][:free_request].include?(env['REQUEST_METHOD'])
|
94
127
|
protected!(@subjectid)
|
95
128
|
end
|
data/lib/model.rb
CHANGED
@@ -10,8 +10,8 @@ module OpenTox
|
|
10
10
|
# @return [text/uri-list] Task or resource URI
|
11
11
|
def run( params, accept_header=nil, waiting_task=nil )
|
12
12
|
unless accept_header
|
13
|
-
if CONFIG[:
|
14
|
-
accept_header = 'application/
|
13
|
+
if CONFIG[:json_hosts].include?(URI.parse(@uri).host)
|
14
|
+
accept_header = 'application/json'
|
15
15
|
else
|
16
16
|
accept_header = 'application/rdf+xml'
|
17
17
|
end
|
@@ -144,7 +144,7 @@ module OpenTox
|
|
144
144
|
# @param [String] uri Model URI
|
145
145
|
# @return [OpenTox::Model::Lazar] lazar model
|
146
146
|
def self.find(uri, subjectid=nil)
|
147
|
-
|
147
|
+
OpenTox::Model::Lazar.from_json RestClientWrapper.get(uri,{:accept => 'application/json', :subjectid => subjectid})
|
148
148
|
end
|
149
149
|
|
150
150
|
# Create a new lazar model
|
@@ -157,10 +157,42 @@ module OpenTox
|
|
157
157
|
OpenTox::Model::Lazar.find(model_uri, subjectid)
|
158
158
|
end
|
159
159
|
|
160
|
+
def self.from_json(json)
|
161
|
+
hash = Yajl::Parser.parse(json)
|
162
|
+
#LOGGER.debug hash.to_yaml
|
163
|
+
lazar = OpenTox::Model::Lazar.new
|
164
|
+
#hash.each { |k,v| eval("lazar.#{k} = #{v}") }
|
165
|
+
lazar.uri = hash["uri"] if hash["uri"]
|
166
|
+
lazar.metadata = hash["metadata"] if hash["metadata"]
|
167
|
+
lazar.compound = hash["compound"] if hash["compound"]
|
168
|
+
lazar.prediction_dataset = hash["prediction_dataset"] if hash["prediction_dataset"]
|
169
|
+
lazar.features = hash["features"] if hash["features"]
|
170
|
+
lazar.effects = hash["effects"] if hash["effects"]
|
171
|
+
lazar.activities = hash["activities"] if hash["activities"]
|
172
|
+
lazar.p_values = hash["p_values"] if hash["p_values"]
|
173
|
+
lazar.fingerprints = hash["fingerprints"] if hash["fingerprints"]
|
174
|
+
lazar.feature_calculation_algorithm = hash["feature_calculation_algorithm"] if hash["feature_calculation_algorithm"]
|
175
|
+
lazar.similarity_algorithm = hash["similarity_algorithm"] if hash["similarity_algorithm"]
|
176
|
+
lazar.prediction_algorithm = hash["prediction_algorithm"] if hash["prediction_algorithm"]
|
177
|
+
lazar.min_sim = hash["min_sim"] if hash["min_sim"]
|
178
|
+
lazar.subjectid = hash["subjectid"] if hash["subjectid"]
|
179
|
+
lazar.prop_kernel = hash["prop_kernel"] if hash["prop_kernel"]
|
180
|
+
lazar.value_map = hash["value_map"] if hash["value_map"]
|
181
|
+
lazar.nr_hits = hash["nr_hits"] if hash["nr_hits"]
|
182
|
+
lazar.transform = hash["transform"] if hash["transform"]
|
183
|
+
lazar.conf_stdev = hash["conf_stdev"] if hash["conf_stdev"]
|
184
|
+
lazar.prediction_min_max = hash["prediction_min_max"] if hash["prediction_min_max"]
|
185
|
+
lazar
|
186
|
+
end
|
187
|
+
|
188
|
+
def to_json
|
189
|
+
Yajl::Encoder.encode({:uri => @uri,:metadata => @metadata, :compound => @compound, :prediction_dataset => @prediction_dataset, :features => @features, :effects => @effects, :activities => @activities, :p_values => @p_values, :fingerprints => @fingerprints, :feature_calculation_algorithm => @feature_calculation_algorithm, :similarity_algorithm => @similarity_algorithm, :prediction_algorithm => @prediction_algorithm, :min_sim => @min_sim, :subjectid => @subjectid, :prop_kernel => @prop_kernel, :value_map => @value_map, :nr_hits => @nr_hits, :transform => @transform, :conf_stdev => @conf_stdev, :prediction_min_max => @prediction_min_max})
|
190
|
+
end
|
191
|
+
|
160
192
|
def run( params, accept_header=nil, waiting_task=nil )
|
161
193
|
unless accept_header
|
162
|
-
if CONFIG[:
|
163
|
-
accept_header = 'application/
|
194
|
+
if CONFIG[:json_hosts].include?(URI.parse(@uri).host)
|
195
|
+
accept_header = 'application/json'
|
164
196
|
else
|
165
197
|
accept_header = 'application/rdf+xml'
|
166
198
|
end
|
@@ -199,7 +231,7 @@ module OpenTox
|
|
199
231
|
count += 1
|
200
232
|
waiting_task.progress( count/d.compounds.size.to_f*100.0 ) if waiting_task
|
201
233
|
rescue => ex
|
202
|
-
LOGGER.warn "prediction for compound "+compound_uri.to_s+" failed: "+ex.message
|
234
|
+
LOGGER.warn "prediction for compound "+compound_uri.to_s+" failed: "+ex.message+" subjectid: #{subjectid}"
|
203
235
|
end
|
204
236
|
end
|
205
237
|
#@prediction_dataset.save(subjectid)
|
@@ -215,6 +247,7 @@ module OpenTox
|
|
215
247
|
@compound = Compound.new compound_uri
|
216
248
|
features = {}
|
217
249
|
|
250
|
+
#LOGGER.debug self.to_yaml
|
218
251
|
unless @prediction_dataset
|
219
252
|
@prediction_dataset = Dataset.create(CONFIG[:services]["opentox-dataset"], subjectid)
|
220
253
|
@prediction_dataset.add_metadata( {
|
@@ -225,7 +258,7 @@ module OpenTox
|
|
225
258
|
} )
|
226
259
|
end
|
227
260
|
|
228
|
-
if OpenTox::Feature.find(metadata[OT.dependentVariables]).feature_type == "regression"
|
261
|
+
if OpenTox::Feature.find(metadata[OT.dependentVariables], subjectid).feature_type == "regression"
|
229
262
|
all_activities = []
|
230
263
|
all_activities = @activities.values.flatten.collect! { |i| i.to_f }
|
231
264
|
@prediction_min_max[0] = (all_activities.to_scale.min/2)
|
@@ -255,7 +288,7 @@ module OpenTox
|
|
255
288
|
@prediction_dataset.metadata[OT.predictedVariables] = [value_feature_uri, confidence_feature_uri] unless @prediction_dataset.metadata[OT.predictedVariables]
|
256
289
|
|
257
290
|
if OpenTox::Feature.find(metadata[OT.dependentVariables], subjectid).feature_type == "classification"
|
258
|
-
@prediction_dataset.add @compound.uri, value_feature_uri, @value_map[prediction[:prediction]]
|
291
|
+
@prediction_dataset.add @compound.uri, value_feature_uri, @value_map[prediction[:prediction].to_s]
|
259
292
|
else
|
260
293
|
@prediction_dataset.add @compound.uri, value_feature_uri, prediction[:prediction]
|
261
294
|
end
|
@@ -365,7 +398,7 @@ module OpenTox
|
|
365
398
|
def database_activity(subjectid)
|
366
399
|
if @activities[@compound.uri]
|
367
400
|
if OpenTox::Feature.find(metadata[OT.dependentVariables], subjectid).feature_type == "classification"
|
368
|
-
@activities[@compound.uri].each { |act| @prediction_dataset.add @compound.uri, @metadata[OT.dependentVariables], @value_map[act] }
|
401
|
+
@activities[@compound.uri].each { |act| @prediction_dataset.add @compound.uri, @metadata[OT.dependentVariables], @value_map[act.to_s] }
|
369
402
|
else
|
370
403
|
@activities[@compound.uri].each { |act| @prediction_dataset.add @compound.uri, @metadata[OT.dependentVariables], act }
|
371
404
|
end
|
@@ -385,7 +418,7 @@ module OpenTox
|
|
385
418
|
dependent_uri = @metadata[OT.dependentVariables].first
|
386
419
|
feature = OpenTox::Feature.new File.join( @uri, "predicted", "value")
|
387
420
|
feature.add_metadata( {
|
388
|
-
RDF.type =>
|
421
|
+
RDF.type => OT.ModelPrediction,
|
389
422
|
OT.hasSource => @uri,
|
390
423
|
DC.creator => @uri,
|
391
424
|
DC.title => URI.decode(File.basename( dependent_uri )),
|
@@ -398,7 +431,7 @@ module OpenTox
|
|
398
431
|
dependent_uri = @metadata[OT.dependentVariables].first
|
399
432
|
feature = OpenTox::Feature.new File.join( @uri, "predicted", "confidence")
|
400
433
|
feature.add_metadata( {
|
401
|
-
RDF.type =>
|
434
|
+
RDF.type => OT.ModelPrediction,
|
402
435
|
OT.hasSource => @uri,
|
403
436
|
DC.creator => @uri,
|
404
437
|
DC.title => "#{URI.decode(File.basename( dependent_uri ))} confidence"
|
@@ -408,7 +441,7 @@ module OpenTox
|
|
408
441
|
|
409
442
|
# Save model at model service
|
410
443
|
def save(subjectid)
|
411
|
-
self.uri = RestClientWrapper.post(@uri,self.
|
444
|
+
self.uri = RestClientWrapper.post(@uri,self.to_json,{:content_type => "application/json", :subjectid => subjectid})
|
412
445
|
end
|
413
446
|
|
414
447
|
# Delete model at model service
|
data/lib/ontology.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
module OpenTox
|
2
2
|
module Ontology
|
3
3
|
module Echa
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
def self.qs(classname="Endpoints")
|
8
|
-
return "PREFIX ot:<http://www.opentox.org/api/1.1#>
|
4
|
+
|
5
|
+
def self.querystring(classname="Endpoints")
|
6
|
+
return CGI.escape("PREFIX ot:<http://www.opentox.org/api/1.1#>
|
9
7
|
PREFIX ota:<http://www.opentox.org/algorithms.owl#>
|
10
8
|
PREFIX owl:<http://www.w3.org/2002/07/owl#>
|
11
9
|
PREFIX dc:<http://purl.org/dc/elements/1.1/>
|
@@ -17,29 +15,44 @@ module OpenTox
|
|
17
15
|
where {
|
18
16
|
?endpoint rdfs:subClassOf otee:#{classname}.
|
19
17
|
?endpoint dc:title ?title.
|
20
|
-
}"
|
18
|
+
}")
|
21
19
|
end
|
22
|
-
|
20
|
+
|
23
21
|
def self.make_option_list(endpoint="Endpoints", level=1)
|
24
|
-
|
25
|
-
results =
|
22
|
+
out = ""
|
23
|
+
results = echa_endpoints(endpoint) rescue results = []
|
26
24
|
results.each do |result|
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
r = result.split(',')
|
26
|
+
endpointname = r.first.split("#").last
|
27
|
+
title = r[1..r.size-1]
|
28
|
+
out += "<option value='#{r.first}' id='#{endpointname}' class='level_#{level}'>#{title}</option>\n"
|
30
29
|
out += make_option_list(endpointname, level + 1)
|
31
30
|
end
|
32
31
|
return out
|
33
32
|
end
|
34
|
-
|
35
|
-
def self.
|
33
|
+
|
34
|
+
def self.endpoint_option_list(include_blank=true)
|
36
35
|
out = "<select id='endpoint' name='endpoint'>\n"
|
37
36
|
out += "<option value='' id='please_select'>Please select</option>\n" if include_blank
|
38
37
|
out += make_option_list
|
39
38
|
out += "</select>\n"
|
40
39
|
return out
|
41
40
|
end
|
42
|
-
|
41
|
+
|
42
|
+
# Gets Endpoints of specific level from ontology service
|
43
|
+
# Top level with endpoint="Endpoints"
|
44
|
+
# e.G. Ecotoxic effects endpoints with endpoint="EcotoxicEffects"
|
45
|
+
# if ontology service is not reachable it returns an empty array
|
46
|
+
# @param [String] endpoint
|
47
|
+
# @return [Array] of endpoints: e.G. "http://www.opentox.org/echaEndpoints.owl#EcotoxicEffects,Ecotoxic effects"
|
48
|
+
def self.echa_endpoints(endpoint)
|
49
|
+
begin
|
50
|
+
RestClientWrapper.get("#{ONTOLOGY_SERVER}?query=#{querystring(endpoint)}",:accept => "text/csv").collect{|l| l.gsub("\r\n", "") if l.match(/^http/)}.uniq.compact.sort
|
51
|
+
rescue
|
52
|
+
LOGGER.warn "OpenTox::Ontology::Echa.echa_endpoints ontology service is not reachable."
|
53
|
+
[]
|
54
|
+
end
|
55
|
+
end
|
43
56
|
|
44
57
|
def self.endpoints
|
45
58
|
RestClientWrapper.get("http://apps.ideaconsult.net:8080/ambit2/query/ndatasets_endpoint",:accept => "text/csv").collect { |line| line.split(',').first if line.match(/^http/) }.compact
|
@@ -51,5 +64,74 @@ module OpenTox
|
|
51
64
|
|
52
65
|
end
|
53
66
|
|
67
|
+
#Model Class for OpenTox::Ontology to register/deregister and check models in the ontology service
|
68
|
+
#@example Register a model URI to the ontology service, check if model URI exists and delete it
|
69
|
+
# uri = "http://mymodelservice.net/model/1" # model uri will be checked by the ontology service itself
|
70
|
+
# OpenTox::Ontology::Model.register(uri)
|
71
|
+
# puts OpenTox::Ontology::Model.exists?(uri) # => should return true
|
72
|
+
# OpenTox::Ontology::Model.delete(uri)
|
73
|
+
# puts OpenTox::Ontology::Model.exists?(uri) # => should return false
|
74
|
+
module Model
|
75
|
+
|
76
|
+
# Register an OpenTox resource into ontology service
|
77
|
+
# @param [String] uri, URI of recource to register
|
78
|
+
# @param [String] subjectid
|
79
|
+
def self.register(uri, subjectid=nil)
|
80
|
+
begin
|
81
|
+
RestClientWrapper.post(ONTOLOGY_SERVER, {:uri => uri}, {:subjectid => CGI.escape(subjectid)})
|
82
|
+
rescue
|
83
|
+
LOGGER.warn "OpenTox::Ontology::Model.register ontology service is not reachable. Failed to register URI: #{uri} with subjectid: #{subjectid}"
|
84
|
+
false
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Deregister an OpenTox resource into ontology service
|
89
|
+
# @param [String] uri, URI of recource to deregister/delete
|
90
|
+
# @param [String] subjectid
|
91
|
+
def self.delete(uri, subjectid=nil)
|
92
|
+
begin
|
93
|
+
RestClientWrapper.delete("#{ONTOLOGY_SERVER}?uri=#{CGI.escape(uri)}", {:subjectid => CGI.escape(subjectid)})
|
94
|
+
rescue
|
95
|
+
LOGGER.warn "OpenTox::Ontology::Model.exists ontology service is not reachable. Failed to delete URI: #{uri} with subjectid: #{subjectid}"
|
96
|
+
false
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Find an OpenTox resource in the ontology service
|
101
|
+
# @param [String] uri, URI of recource to find
|
102
|
+
# @param [String] subjectid
|
103
|
+
def self.exists?(uri, subjectid=nil)
|
104
|
+
begin
|
105
|
+
out = RestClientWrapper.get("#{ONTOLOGY_SERVER}?query=#{querystring(uri)}",:accept => "text/csv").collect{|l| l.gsub("\r\n", "") if l.match(/^http/)}.uniq.compact
|
106
|
+
return true if out.size > 0
|
107
|
+
false
|
108
|
+
rescue
|
109
|
+
LOGGER.warn "OpenTox::Ontology::Model.exists ontology service is not reachable. Failed to check for URI: #{uri} with subjectid: #{subjectid}"
|
110
|
+
false
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
# Query string to find a registered model
|
116
|
+
# @param [String] uri, model URI
|
117
|
+
def self.querystring(uri)
|
118
|
+
return CGI.escape("PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
119
|
+
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
120
|
+
PREFIX owl:<http://www.w3.org/2002/07/owl#>
|
121
|
+
PREFIX dc:<http://purl.org/dc/elements/1.1/>
|
122
|
+
PREFIX dcterms:<http://purl.org/dc/terms/>
|
123
|
+
PREFIX ot:<http://www.opentox.org/api/1.1#>
|
124
|
+
select distinct ?model ?title ?creator ?trainingDataset ?algorithm
|
125
|
+
where {
|
126
|
+
?model rdf:type ot:Model;
|
127
|
+
OPTIONAL {?model dc:title ?title}.
|
128
|
+
OPTIONAL {?model dc:creator ?creator}.
|
129
|
+
OPTIONAL {?model ot:trainingDataset ?trainingDataset}.
|
130
|
+
OPTIONAL {?model ot:algorithm ?algorithm }.
|
131
|
+
FILTER (?model = <#{uri}>)
|
132
|
+
}")
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
54
136
|
end
|
55
|
-
end
|
137
|
+
end
|
data/lib/opentox.rb
CHANGED
@@ -31,12 +31,14 @@ module OpenTox
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def add_metadata(metadata)
|
34
|
-
metadata.
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
if !metadata.nil?
|
35
|
+
metadata.each do |k,v|
|
36
|
+
if v.is_a? Array
|
37
|
+
@metadata[k] = [] unless @metadata[k]
|
38
|
+
@metadata[k] << v
|
39
|
+
else
|
40
|
+
@metadata[k] = v
|
41
|
+
end
|
40
42
|
end
|
41
43
|
end
|
42
44
|
end
|
@@ -46,7 +48,6 @@ module OpenTox
|
|
46
48
|
def to_rdfxml
|
47
49
|
s = Serializer::Owl.new
|
48
50
|
s.add_metadata(@uri,@metadata)
|
49
|
-
#s.add_parameters(@uri,@parameters) if @parameters
|
50
51
|
s.to_rdfxml
|
51
52
|
end
|
52
53
|
|
data/lib/serializer.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spreadsheet'
|
2
2
|
require 'yajl'
|
3
|
+
require 'yajl/json_gem'
|
3
4
|
|
4
5
|
module OpenTox
|
5
6
|
|
@@ -21,6 +22,7 @@ module OpenTox
|
|
21
22
|
OT.NominalFeature => { RDF["type"] => [{ "type" => "uri", "value" => OWL['Class'] }] } ,
|
22
23
|
OT.NumericFeature => { RDF["type"] => [{ "type" => "uri", "value" => OWL['Class'] }] } ,
|
23
24
|
OT.StringFeature => { RDF["type"] => [{ "type" => "uri", "value" => OWL['Class'] }] } ,
|
25
|
+
OT.ModelPrediction => { RDF["type"] => [{ "type" => "uri", "value" => OWL['Class'] }] } ,
|
24
26
|
OT.Dataset => { RDF["type"] => [{ "type" => "uri", "value" => OWL['Class'] }] } ,
|
25
27
|
OT.DataEntry => { RDF["type"] => [{ "type" => "uri", "value" => OWL['Class'] }] } ,
|
26
28
|
OT.FeatureValue => { RDF["type"] => [{ "type" => "uri", "value" => OWL['Class'] }] } ,
|
@@ -69,6 +71,7 @@ module OpenTox
|
|
69
71
|
OT.validation => { RDF["type"] => [{ "type" => "uri", "value" => OWL.ObjectProperty }] } ,
|
70
72
|
OT.crossvalidationInfo => { RDF["type"] => [{ "type" => "uri", "value" => OWL.ObjectProperty }] } ,
|
71
73
|
OT.dataset => { RDF["type"] => [{ "type" => "uri", "value" => OWL.ObjectProperty }] } ,
|
74
|
+
OT.hasSource => { RDF["type"] => [{ "type" => "uri", "value" => OWL.ObjectProperty }] } ,
|
72
75
|
|
73
76
|
DC.title => { RDF["type"] => [{ "type" => "uri", "value" => OWL.AnnotationProperty }] } ,
|
74
77
|
DC.identifier => { RDF["type"] => [{ "type" => "uri", "value" => OWL.AnnotationProperty }] } ,
|
@@ -131,7 +134,7 @@ module OpenTox
|
|
131
134
|
OT.actor => { RDF["type"] => [{ "type" => "uri", "value" => OWL.AnnotationProperty }] } ,
|
132
135
|
OT.errorCode => { RDF["type"] => [{ "type" => "uri", "value" => OWL.AnnotationProperty }] } ,
|
133
136
|
|
134
|
-
OT.hasSource => { RDF["type"] => [{ "type" => "uri", "value" => OWL.DatatypeProperty }] } ,
|
137
|
+
#OT.hasSource => { RDF["type"] => [{ "type" => "uri", "value" => OWL.DatatypeProperty }] } ,
|
135
138
|
OT.value => { RDF["type"] => [{ "type" => "uri", "value" => OWL.DatatypeProperty }] } ,
|
136
139
|
OT.paramScope => { RDF["type"] => [{ "type" => "uri", "value" => OWL.DatatypeProperty }] } ,
|
137
140
|
#OT.paramValue => { RDF["type"] => [{ "type" => "uri", "value" => OWL.DatatypeProperty }] } ,
|
@@ -216,20 +219,24 @@ module OpenTox
|
|
216
219
|
@@content_id = 1
|
217
220
|
add_content uri, content
|
218
221
|
end
|
222
|
+
|
223
|
+
def add_uri(uri,type)
|
224
|
+
@object[uri] = { RDF["type"] => [{ "type" => "uri", "value" => type }] }
|
225
|
+
end
|
219
226
|
|
220
227
|
private
|
221
228
|
@@content_id = 1
|
222
229
|
|
223
|
-
#
|
224
|
-
|
225
|
-
#
|
226
|
-
#
|
227
|
-
#
|
228
|
-
#
|
229
|
-
#
|
230
|
-
#
|
231
|
-
#
|
232
|
-
#
|
230
|
+
#Recursiv function to add content
|
231
|
+
#@example
|
232
|
+
# { DC.description => "bla",
|
233
|
+
# OT.similar_resources => [ "http://uri1", "http://uri2" ],
|
234
|
+
# OT.matrixCells =>
|
235
|
+
# [ { RDF.type => OT.MatrixCell, OT.cellIndex=1 OT.cellValue => "xy" },
|
236
|
+
# { RDF.type => OT.MatrixCell, OT.cellIndex=2 OT.cellValue => "z" } ],
|
237
|
+
# OT.info => { RDF.type => OT.ImportantInfo,
|
238
|
+
# DC.description => "blub" }
|
239
|
+
# }
|
233
240
|
# @param [String] uri
|
234
241
|
# @param [Hash] content as hash, uri must already have been added to @object
|
235
242
|
def add_content(uri, hash)
|
@@ -268,28 +275,30 @@ module OpenTox
|
|
268
275
|
# @param [Hash] metadata
|
269
276
|
def add_metadata(uri,metadata)
|
270
277
|
id = 0
|
271
|
-
metadata.
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
v.each do |value|
|
276
|
-
id+=1
|
277
|
-
genid = "_:genid#{id}"
|
278
|
-
@object[uri][u] << {"type" => "bnode", "value" => genid}
|
279
|
-
@object[genid] = { RDF["type"] => [{ "type" => "uri", "value" => OT.Parameter}] }
|
280
|
-
value.each do |name,entry|
|
281
|
-
@object[genid][name] = [{"type" => type(entry), "value" => entry }]
|
282
|
-
end
|
283
|
-
end
|
284
|
-
elsif v.is_a? Array #and u == RDF.type
|
285
|
-
@object[uri] = {} unless @object[uri]
|
286
|
-
v.each do |value|
|
278
|
+
if !metadata.nil?
|
279
|
+
metadata.each do |u,v|
|
280
|
+
#if v.is_a? Array and (u == OT.parameters or u == RDF.type)
|
281
|
+
if v.is_a? Array and u == OT.parameters#or u == RDF.type)
|
287
282
|
@object[uri][u] = [] unless @object[uri][u]
|
288
|
-
|
283
|
+
v.each do |value|
|
284
|
+
id+=1
|
285
|
+
genid = "_:genid#{id}"
|
286
|
+
@object[uri][u] << {"type" => "bnode", "value" => genid}
|
287
|
+
@object[genid] = { RDF["type"] => [{ "type" => "uri", "value" => OT.Parameter}] }
|
288
|
+
value.each do |name,entry|
|
289
|
+
@object[genid][name] = [{"type" => type(entry), "value" => entry }]
|
290
|
+
end
|
291
|
+
end
|
292
|
+
elsif v.is_a? Array #and u == RDF.type
|
293
|
+
@object[uri] = {} unless @object[uri]
|
294
|
+
v.each do |value|
|
295
|
+
@object[uri][u] = [] unless @object[uri][u]
|
296
|
+
@object[uri][u] << {"type" => type(value), "value" => value }
|
297
|
+
end
|
298
|
+
elsif v.is_a? String
|
299
|
+
@object[uri] = {} unless @object[uri]
|
300
|
+
@object[uri][u] = [{"type" => type(v), "value" => v }]
|
289
301
|
end
|
290
|
-
elsif v.is_a? String
|
291
|
-
@object[uri] = {} unless @object[uri]
|
292
|
-
@object[uri][u] = [{"type" => type(v), "value" => v }]
|
293
302
|
end
|
294
303
|
end
|
295
304
|
end
|
data/lib/task.rb
CHANGED
@@ -182,7 +182,7 @@ module OpenTox
|
|
182
182
|
end
|
183
183
|
|
184
184
|
def load_metadata
|
185
|
-
if (CONFIG[:
|
185
|
+
if (CONFIG[:json_hosts].include?(URI.parse(@uri).host))
|
186
186
|
result = RestClientWrapper.get(@uri, {:accept => 'application/x-yaml'}, nil, false)
|
187
187
|
@metadata = YAML.load result.to_s
|
188
188
|
@http_code = result.code
|
@@ -209,7 +209,7 @@ module OpenTox
|
|
209
209
|
|
210
210
|
def reload( accept_header=nil )
|
211
211
|
unless accept_header
|
212
|
-
if (CONFIG[:
|
212
|
+
if (CONFIG[:json_hosts].include?(URI.parse(uri).host))
|
213
213
|
accept_header = "application/x-yaml"
|
214
214
|
else
|
215
215
|
accept_header = 'application/rdf+xml'
|
data/lib/to-html.rb
CHANGED
@@ -33,10 +33,10 @@ module OpenTox
|
|
33
33
|
user = OpenTox::Authorization.get_user(subjectid) if subjectid
|
34
34
|
html += "<pre><p align=\"right\">"
|
35
35
|
unless user
|
36
|
-
html += "You are currently not signed in to "+$url_provider.
|
36
|
+
html += "You are currently not signed in to "+$url_provider.request.host.to_s+
|
37
37
|
", <a href="+$url_provider.url_for("/sign_in",:full)+">sign in</a>"
|
38
38
|
else
|
39
|
-
html += "You are signed in as '#{user}' to "+$url_provider.
|
39
|
+
html += "You are signed in as '#{user}' to "+$url_provider.request.host.to_s+
|
40
40
|
", <a href="+$url_provider.url_for("/sign_out",:full)+">sign out</a>"
|
41
41
|
end
|
42
42
|
html += " </p></pre>"
|
@@ -61,7 +61,7 @@ module OpenTox
|
|
61
61
|
html += "<form method='POST' action='"+$url_provider.url_for("/sign_in",:full)+"'>"
|
62
62
|
html += "<pre><p style=\"padding:15px; border:10px solid \#5D308A\">"
|
63
63
|
html += msg+"\n\n" if msg
|
64
|
-
html += "Please sign in to "+$url_provider.
|
64
|
+
html += "Please sign in to "+$url_provider.request.host.to_s+"\n\n"
|
65
65
|
html += "<table border=0>"
|
66
66
|
html += "<tr><td>user:</td><td><input type='text' name='user' size='15' /></td></tr>"+
|
67
67
|
"<tr><td>password:</td><td><input type='password' name='password' size='15' /></td></tr>"+
|
@@ -111,9 +111,10 @@ module OpenTox
|
|
111
111
|
end
|
112
112
|
|
113
113
|
get '/sign_out/?' do
|
114
|
-
|
114
|
+
logout
|
115
115
|
content_type "text/html"
|
116
|
-
content = "Sucessfully signed out from "+$url_provider.
|
116
|
+
content = "Sucessfully signed out from "+$url_provider.request.host.to_s+" ( Back to "+
|
117
|
+
$url_provider.url_for("",:full)+" )"
|
117
118
|
OpenTox.text_to_html(content)
|
118
119
|
end
|
119
120
|
|
@@ -123,11 +124,11 @@ get '/sign_in/?' do
|
|
123
124
|
end
|
124
125
|
|
125
126
|
post '/sign_in/?' do
|
126
|
-
subjectid =
|
127
|
+
subjectid = login(params[:user], params[:password])
|
127
128
|
if (subjectid)
|
128
|
-
response.set_cookie("subjectid",{:value=>subjectid})
|
129
129
|
content_type "text/html"
|
130
|
-
content = "Sucessfully signed in as '"+params[:user]+"' to "+$url_provider.
|
130
|
+
content = "Sucessfully signed in as '"+params[:user]+"' to "+$url_provider.request.host.to_s+" ( Back to "+
|
131
|
+
$url_provider.url_for("",:full)+" )"
|
131
132
|
OpenTox.text_to_html(content,subjectid)
|
132
133
|
else
|
133
134
|
content_type "text/html"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentox-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
-
-
|
8
|
-
- 1
|
7
|
+
- 3
|
9
8
|
- 0
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 3.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Christoph Helma, Martin Guetlein, Andreas Maunz, Micha Rautenberg, David Vorgrimmler
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-09-26 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -531,9 +531,8 @@ dependencies:
|
|
531
531
|
version_requirements: *id032
|
532
532
|
description: Ruby wrapper for the OpenTox REST API (http://www.opentox.org)
|
533
533
|
email: helma@in-silico.ch
|
534
|
-
executables:
|
535
|
-
|
536
|
-
- opentox-install-ubuntu.sh
|
534
|
+
executables: []
|
535
|
+
|
537
536
|
extensions: []
|
538
537
|
|
539
538
|
extra_rdoc_files:
|
@@ -544,8 +543,6 @@ files:
|
|
544
543
|
- README.markdown
|
545
544
|
- Rakefile
|
546
545
|
- VERSION
|
547
|
-
- bin/opentox-install-debian.sh
|
548
|
-
- bin/opentox-install-ubuntu.sh
|
549
546
|
- lib/algorithm.rb
|
550
547
|
- lib/authorization.rb
|
551
548
|
- lib/compound.rb
|
@@ -1,105 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
#Installation is tested on Debian Lenny Ubuntu 9.04
|
3
|
-
#Update the system
|
4
|
-
|
5
|
-
ERRLOG='install_err.log'
|
6
|
-
INSTALLLOG='install_log.log'
|
7
|
-
DATE=$(date +%Y/%m/%d\ %H:%M:%S)
|
8
|
-
|
9
|
-
echo "================================================="
|
10
|
-
echo "Please enshure that the sudo package is installed"
|
11
|
-
echo "on your system. "
|
12
|
-
echo "On Ubuntu Linux sudo is installed by default."
|
13
|
-
echo "If you are unshure check with it 'sudo ls'"
|
14
|
-
echo "and installed it with 'apt-get install sudo'"
|
15
|
-
echo "and add your username with visudo."
|
16
|
-
echo "================================================="
|
17
|
-
echo -n "To continue installation press y: "
|
18
|
-
read answer
|
19
|
-
if [ "$answer" != "y" ]
|
20
|
-
then
|
21
|
-
echo "exiting the script..."
|
22
|
-
exit 1
|
23
|
-
fi
|
24
|
-
|
25
|
-
echo "opentox webservice install log - " $DATE > $INSTALLLOG
|
26
|
-
echo "Installing: build-essential"
|
27
|
-
sudo apt-get install build-essential >> $INSTALLLOG 2>>$ERRLOG
|
28
|
-
echo "Installing: ruby 1.8 with its dev files"
|
29
|
-
sudo apt-get install ruby ruby1.8-dev >> $INSTALLLOG 2>>$ERRLOG
|
30
|
-
echo "Installing: gems rdoc rubygems and rake"
|
31
|
-
sudo apt-get install gems rdoc rubygems rake >> $INSTALLLOG 2>>$ERRLOG
|
32
|
-
|
33
|
-
echo "Installing rubygems from source. This may take some time"
|
34
|
-
wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz >> $INSTALLLOG 2>>$ERRLOG
|
35
|
-
tar xzfv rubygems-1.3.5.tgz 2>>$ERRLOG
|
36
|
-
cd rubygems-1.3.5 >> $INSTALLLOG 2>>$ERRLOG
|
37
|
-
sudo ruby setup.rb 2>>$ERRLOG
|
38
|
-
cd ..
|
39
|
-
|
40
|
-
echo "Adding http://gems.github.com to ruby gem sources"
|
41
|
-
sudo gem sources -a http://gems.github.com >> $INSTALLLOG 2>>$ERRLOG
|
42
|
-
|
43
|
-
#for debian lenny:
|
44
|
-
echo "Installing packages: zlib1g-dev tcl curl perl ssh tcl tk8.5"
|
45
|
-
sudo apt-get install zlib1g-dev tcl curl perl ssh tcl tk8.5 >> $INSTALLLOG 2>>$ERRLOG
|
46
|
-
echo "Installing git from source"
|
47
|
-
wget http://www.kernel.org/pub/software/scm/git/git-1.6.5.2.tar.gz >> $INSTALLLOG 2>>$ERRLOG
|
48
|
-
tar xzfv git-1.6.5.2.tar.gz 2>>$ERRLOG
|
49
|
-
cd git-1.6.5.2 >> $INSTALLLOG 2>>$ERRLOG
|
50
|
-
./configure 2>>$ERRLOG
|
51
|
-
make 2>>$ERRLOG
|
52
|
-
make install 2>>$ERRLOG
|
53
|
-
|
54
|
-
echo "Installing the opentox webservices"
|
55
|
-
mkdir webservices >> $INSTALLLOG 2>>$ERRLOG
|
56
|
-
cd webservices >> $INSTALLLOG 2>>$ERRLOG
|
57
|
-
|
58
|
-
git clone git://github.com/helma/opentox-compound.git >> $INSTALLLOG 2>>$ERRLOG
|
59
|
-
git clone git://github.com/helma/opentox-feature.git >> $INSTALLLOG 2>>$ERRLOG
|
60
|
-
git clone git://github.com/helma/opentox-dataset.git >> $INSTALLLOG 2>>$ERRLOG
|
61
|
-
git clone git://github.com/helma/opentox-algorithm.git >> $INSTALLLOG 2>>$ERRLOG
|
62
|
-
git clone git://github.com/helma/opentox-model.git >> $INSTALLLOG 2>>$ERRLOG
|
63
|
-
git clone git://github.com/helma/opentox-test.git >> $INSTALLLOG 2>>$ERRLOG
|
64
|
-
|
65
|
-
cd opentox-compound >> $INSTALLLOG 2>>$ERRLOG
|
66
|
-
git checkout -b development origin/development >> $INSTALLLOG 2>>$ERRLOG
|
67
|
-
cd ../opentox-feature >> $INSTALLLOG 2>>$ERRLOG
|
68
|
-
git checkout -b development origin/development >> $INSTALLLOG 2>>$ERRLOG
|
69
|
-
cd ../opentox-dataset >> $INSTALLLOG 2>>$ERRLOG
|
70
|
-
git checkout -b development origin/development >> $INSTALLLOG 2>>$ERRLOG
|
71
|
-
cd ../opentox-algorithm >> $INSTALLLOG 2>>$ERRLOG
|
72
|
-
git checkout -b development origin/development >> $INSTALLLOG 2>>$ERRLOG
|
73
|
-
cd ../opentox-model >> $INSTALLLOG 2>>$ERRLOG
|
74
|
-
git checkout -b development origin/development >> $INSTALLLOG 2>>$ERRLOG
|
75
|
-
cd .. >> $INSTALLLOG 2>>$ERRLOG
|
76
|
-
git clone git://github.com/helma/opentox-ruby-api-wrapper.git >> $INSTALLLOG 2>>$ERRLOG
|
77
|
-
cd opentox-ruby-api-wrapper >> $INSTALLLOG 2>>$ERRLOG
|
78
|
-
git checkout -b development origin/development >> $INSTALLLOG 2>>$ERRLOG
|
79
|
-
rake install >> $INSTALLLOG 2>>$ERRLOG
|
80
|
-
|
81
|
-
|
82
|
-
cd ../opentox-compound >> $INSTALLLOG 2>>$ERRLOG
|
83
|
-
echo "Installing libopenssl-ruby"
|
84
|
-
sudo apt-get install libopenssl-ruby >> $INSTALLLOG 2>>$ERRLOG
|
85
|
-
echo "Installing dtach"
|
86
|
-
rake dtach:install >> $INSTALLLOG 2>>$ERRLOG
|
87
|
-
echo "Installing openbabel"
|
88
|
-
rake openbabel:install >> $INSTALLLOG 2>>$ERRLOG
|
89
|
-
|
90
|
-
#debian lenny missed liblink:
|
91
|
-
ln -s /usr/local/lib/libopenbabel.so.3 /usr/lib/libopenbabel.so.3 >> $INSTALLLOG 2>>$ERRLOG
|
92
|
-
|
93
|
-
rake redis:download >> $INSTALLLOG 2>>$ERRLOG
|
94
|
-
rake redis:install >> $INSTALLLOG 2>>$ERRLOG
|
95
|
-
#edit /home/[username]/.opentox/config/test.yaml set :base_dir: /home/[username]/webservices
|
96
|
-
sudo apt-get install libgsl0-dev >> $INSTALLLOG 2>>$ERRLOG
|
97
|
-
sudo apt-get install swig >> $INSTALLLOG 2>>$ERRLOG
|
98
|
-
sudo apt-get install curl >> $INSTALLLOG 2>>$ERRLOG
|
99
|
-
cd ../opentox-algorithm >> $INSTALLLOG 2>>$ERRLOG
|
100
|
-
echo "Installing fminer"
|
101
|
-
rake fminer:install >> $INSTALLLOG 2>>$ERRLOG
|
102
|
-
sudo apt-get install libsqlite3-dev >> $INSTALLLOG 2>>$ERRLOG
|
103
|
-
|
104
|
-
|
105
|
-
mkdir ../opentox-model/db >> $INSTALLLOG 2>>$ERRLOG
|
@@ -1,375 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
#Installation is tested on Debian Ubuntu 9.10
|
3
|
-
#Update the system
|
4
|
-
|
5
|
-
FAILED=0
|
6
|
-
STARTPATH=$PWD
|
7
|
-
ERRLOG=$PWD/'install_err.log'
|
8
|
-
INSTALLLOG=$PWD/'install_log.log'
|
9
|
-
DATE=$(date +%Y/%m/%d\ %H:%M:%S)
|
10
|
-
BRANCH=$1
|
11
|
-
GEMVERSION="1.3.5"
|
12
|
-
GITVERSION="1.6.5.2"
|
13
|
-
RAPTORVERSION="1.4.20"
|
14
|
-
RASQALVERSION="0.9.16"
|
15
|
-
RASQALVERSION2="0.9.15"
|
16
|
-
REDLANDVERSION="1.0.7"
|
17
|
-
REDBINDVERSION="1.0.7.1"
|
18
|
-
|
19
|
-
if [ "$BRANCH" = '' ]
|
20
|
-
then
|
21
|
-
echo "Please enter: sudo ./[filename] [brunchtpy]"
|
22
|
-
exit 1
|
23
|
-
fi
|
24
|
-
echo "================================================="
|
25
|
-
echo "Selected branch is: $BRANCH"
|
26
|
-
echo "================================================="
|
27
|
-
echo "Please enshure that the sudo package is installed"
|
28
|
-
echo "on your system. "
|
29
|
-
echo "On Ubuntu Linux sudo is installed by default."
|
30
|
-
echo "If you are unsure check with it 'sudo ls'"
|
31
|
-
echo "and installed it with 'apt-get install sudo'"
|
32
|
-
echo "and add your username with visudo."
|
33
|
-
echo "================================================="
|
34
|
-
echo "Some programs and the OpenTox webservices will be installed in the current folder."
|
35
|
-
echo "================================================="
|
36
|
-
echo -n "To continue installation press y: "
|
37
|
-
read answer
|
38
|
-
if [ "$answer" != "y" ]
|
39
|
-
then
|
40
|
-
echo "exiting the script..."
|
41
|
-
exit 1
|
42
|
-
fi
|
43
|
-
|
44
|
-
echo "opentox webservice install log - " $DATE > $INSTALLLOG
|
45
|
-
echo "opentox webservice install err log - " $DATE > $ERRLOG
|
46
|
-
echo "Installing: build-essential"
|
47
|
-
sudo apt-get install build-essential | tee -a $INSTALLLOG
|
48
|
-
|
49
|
-
echo "Installing: ruby 1.8 with its dev files"
|
50
|
-
sudo apt-get install ruby ruby1.8-dev | tee -a $INSTALLLOG
|
51
|
-
|
52
|
-
echo "Installing: gems rdoc rubygems libxml-parser-ruby1.8 libxml++2.6-dev libyaml-ruby libzlib-ruby sqlite3 libsqlite3-dev libsqlite3-ruby1.8 and rake"
|
53
|
-
sudo apt-get install gems rdoc rubygems libxml-parser-ruby1.8 libxml++2.6-dev libyaml-ruby libzlib-ruby rake sqlite3 libsqlite3-dev libsqlite3-ruby1.8 | tee -a $INSTALLLOG
|
54
|
-
|
55
|
-
#RUBYGEMS
|
56
|
-
echo "Installing rubygems from source. This may take some time"
|
57
|
-
if [ ! -d $STARTPATH/rubygems-$GEMVERSION ];
|
58
|
-
then
|
59
|
-
wget http://rubyforge.org/frs/download.php/60718/rubygems-$GEMVERSION.tgz >>$INSTALLLOG 2>>$ERRLOG
|
60
|
-
tar xzfv rubygems-$GEMVERSION.tgz >>$INSTALLLOG 2>>$ERRLOG
|
61
|
-
cd rubygems-$GEMVERSION
|
62
|
-
sudo ruby setup.rb >>$INSTALLLOG 2>>$ERRLOG
|
63
|
-
cd ..
|
64
|
-
sudo rm rubygems-$GEMVERSION.tgz
|
65
|
-
CHECKGEM=`gem -v`
|
66
|
-
if [ "$CHECKGEM" == "$GEMVERSION" ]
|
67
|
-
then
|
68
|
-
echo "Adding http://gems.github.com to ruby gem sources"
|
69
|
-
sudo gem sources -a http://gems.github.com >>$INSTALLLOG 2>>$ERRLOG
|
70
|
-
|
71
|
-
echo "================================================="
|
72
|
-
echo "Rubygems version $GEMVERSION successfully installed."
|
73
|
-
echo "================================================="
|
74
|
-
else
|
75
|
-
echo "Rubygems version $GEMVERSION installation failed."
|
76
|
-
FAILED=1
|
77
|
-
exit $FAILED
|
78
|
-
fi
|
79
|
-
else
|
80
|
-
echo "rubygems-$GEMVERSION folder already exist. "
|
81
|
-
fi
|
82
|
-
|
83
|
-
echo "Installing packages: zlib1g-dev tcl curl perl ssh tcl tk8.5 libopenssl-ruby libgsl0-dev swig r-base rinruby"
|
84
|
-
sudo apt-get install zlib1g-dev tcl curl perl libopenssl-ruby libgsl0-dev r-base | tee -a $INSTALLLOG
|
85
|
-
sudo apt-get install ssh tcl tk8.5 | tee -a $INSTALLLOG
|
86
|
-
sudo apt-get install swig | tee -a $INSTALLLOG
|
87
|
-
sudo apt-get install postgresql-server-dev-8.4 | tee -a $INSTALLLOG
|
88
|
-
|
89
|
-
|
90
|
-
#echo "Installing gems jeweler sinatra emk-sinatra-url-for dm-core cehoffman-sinatra-respond_to rest-client rack-contrib thin cucumber datamapper data_objects do_sqlite3 rinruby"
|
91
|
-
sudo gem install jeweler | tee -a $INSTALLLOG
|
92
|
-
sudo gem install sinatra | tee -a $INSTALLLOG
|
93
|
-
sudo gem install emk-sinatra-url-for -s http://gems.github.com | tee -a $INSTALLLOG
|
94
|
-
sudo gem install dm-core | tee -a $INSTALLLOG
|
95
|
-
sudo gem install sinatra-respond_to | tee -a $INSTALLLOG
|
96
|
-
sudo gem install rest-client | tee -a $INSTALLLOG
|
97
|
-
sudo gem install rack-contrib | tee -a $INSTALLLOG
|
98
|
-
sudo gem install thin | tee -a $INSTALLLOG
|
99
|
-
sudo gem install cucumber | tee -a $INSTALLLOG
|
100
|
-
sudo gem install datamapper | tee -a $INSTALLLOG
|
101
|
-
sudo gem install data_objects | tee -a $INSTALLLOG
|
102
|
-
sudo gem install do_sqlite3 | tee -a $INSTALLLOG
|
103
|
-
sudo gem install rinruby | tee -a $INSTALLLOG
|
104
|
-
sudo gem cleanup | tee -a $INSTALLLOG
|
105
|
-
|
106
|
-
echo "Installing LibRDF-ruby"
|
107
|
-
sudo apt-get install librdf0 librdf-ruby | tee -a $INSTALLLOG
|
108
|
-
|
109
|
-
#GIT
|
110
|
-
echo "Installing git from source"
|
111
|
-
echo "This could take a while..."
|
112
|
-
if [ ! -d $STARTPATH/git-$GITVERSION ];
|
113
|
-
then
|
114
|
-
wget http://www.kernel.org/pub/software/scm/git/git-$GITVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG
|
115
|
-
tar xzfv git-$GITVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG
|
116
|
-
cd git-$GITVERSION
|
117
|
-
./configure >>$INSTALLLOG 2>>$ERRLOG
|
118
|
-
make >>$INSTALLLOG 2>>$ERRLOG
|
119
|
-
sudo make install >>$INSTALLLOG 2>>$ERRLOG
|
120
|
-
cd ..
|
121
|
-
sudo rm git-$GITVERSION.tar.gz
|
122
|
-
CHECKGIT=`git --version`
|
123
|
-
if [ "$CHECKGIT" == "git version $GITVERSION" ]
|
124
|
-
then
|
125
|
-
echo "================================================="
|
126
|
-
echo "Git version $GITVERSION successfully installed."
|
127
|
-
echo "================================================="
|
128
|
-
else
|
129
|
-
echo "Git version $GITVERSION installation failed."
|
130
|
-
FAILED=1
|
131
|
-
exit $FAILED
|
132
|
-
fi
|
133
|
-
else
|
134
|
-
echo "git-$GITVERSION folder exists."
|
135
|
-
fi
|
136
|
-
|
137
|
-
#REDLAND
|
138
|
-
if [ ! -d $STARTPATH/redland ];
|
139
|
-
then
|
140
|
-
echo "Making Redland folder."
|
141
|
-
mkdir redland >>$INSTALLLOG 2>>$ERRLOG
|
142
|
-
cd redland
|
143
|
-
echo "Installing Redland raptor"
|
144
|
-
if [ ! -d $STARTPATH/redland/raptor-$RAPTORVERSION ];
|
145
|
-
then
|
146
|
-
wget wget http://download.librdf.org/source/raptor-$RAPTORVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG
|
147
|
-
tar xzfv raptor-$RAPTORVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG
|
148
|
-
cd raptor-$RAPTORVERSION
|
149
|
-
./configure >>$INSTALLLOG 2>>$ERRLOG
|
150
|
-
sudo make >>$INSTALLLOG 2>>$ERRLOG
|
151
|
-
sudo make install >>$INSTALLLOG 2>>$ERRLOG
|
152
|
-
cd ..
|
153
|
-
sudo rm raptor-$RAPTORVERSION.tar.gz
|
154
|
-
CHECKRAPTOR=`raptor-config --version`
|
155
|
-
if [ "$CHECKRAPTOR" == "$RAPTORVERSION" ]
|
156
|
-
then
|
157
|
-
echo "================================================="
|
158
|
-
echo "Raptor version $RAPTORVERSION successfully installed."
|
159
|
-
echo "================================================="
|
160
|
-
else
|
161
|
-
echo "Raptor version $RAPTORVERSION installation failed."
|
162
|
-
FAILED=1
|
163
|
-
exit $FAILED
|
164
|
-
fi
|
165
|
-
else
|
166
|
-
echo "raptor-$RAPTORVERSION folder exists."
|
167
|
-
fi
|
168
|
-
|
169
|
-
echo "Installing Redland rasqal"
|
170
|
-
wget wget http://download.librdf.org/source/rasqal-$RASQALVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG
|
171
|
-
tar xzfv rasqal-$RASQALVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG
|
172
|
-
cd rasqal-$RASQALVERSION
|
173
|
-
./configure >>$INSTALLLOG 2>>$ERRLOG
|
174
|
-
sudo make >>$INSTALLLOG 2>>$ERRLOG
|
175
|
-
sudo make install >>$INSTALLLOG 2>>$ERRLOG
|
176
|
-
cd ..
|
177
|
-
sudo rm rasqal-$RASQALVERSION.tar.gz
|
178
|
-
CHECKRASQAL=`rasqal-config --version`
|
179
|
-
if [ "$CHECKRASQAL" == "$RASQALVERSION2" -o "$CHECKRASQAL" == "$RASQALVERSION" ]
|
180
|
-
then
|
181
|
-
echo "================================================="
|
182
|
-
echo "Raptor version $RASQALVERSION2 or higher successfully installed."
|
183
|
-
echo "================================================="
|
184
|
-
else
|
185
|
-
echo "Raptor version $RASQALVERSION2 or higher installation failed."
|
186
|
-
FAILED=1
|
187
|
-
exit $FAILED
|
188
|
-
fi
|
189
|
-
|
190
|
-
echo "Installing Redland redland"
|
191
|
-
wget wget http://download.librdf.org/source/redland-$REDLANDVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG
|
192
|
-
tar xzfv redland-$REDLANDVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG
|
193
|
-
cd redland-$REDLANDVERSION
|
194
|
-
./configure >>$INSTALLLOG 2>>$ERRLOG
|
195
|
-
sudo make >>$INSTALLLOG 2>>$ERRLOG
|
196
|
-
sudo make install >>$INSTALLLOG 2>>$ERRLOG
|
197
|
-
cd ..
|
198
|
-
sudo rm redland-$REDLANDVERSION.tar.gz
|
199
|
-
CHECKREDLAND=`redland-config --version`
|
200
|
-
if [ "$CHECKREDLAND" == "$REDLANDVERSION" ]
|
201
|
-
then
|
202
|
-
echo "================================================="
|
203
|
-
echo "Redland version $REDLANDVERSION successfully installed."
|
204
|
-
echo "================================================="
|
205
|
-
else
|
206
|
-
echo "Redland version $REDLANDVERSION installation failed."
|
207
|
-
FAILED=1
|
208
|
-
exit $FAILED
|
209
|
-
fi
|
210
|
-
|
211
|
-
|
212
|
-
echo "Installing Redland Bindings with ruby"
|
213
|
-
wget http://download.librdf.org/source/redland-bindings-$REDBINDVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG
|
214
|
-
tar xzfv redland-bindings-$REDBINDVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG
|
215
|
-
cd redland-bindings-$REDBINDVERSION
|
216
|
-
./configure --with-ruby >>$INSTALLLOG 2>>$ERRLOG
|
217
|
-
sudo make >>$INSTALLLOG 2>>$ERRLOG
|
218
|
-
sudo make install >>$INSTALLLOG 2>>$ERRLOG
|
219
|
-
cd ..
|
220
|
-
sudo rm redland-bindings-$REDBINDVERSION.tar.gz
|
221
|
-
cd ..
|
222
|
-
#CHECKREDBIND=`??? --version`
|
223
|
-
#if [ "$CHECKREDBIND" == "$REDBINDVERSION" ]
|
224
|
-
#then
|
225
|
-
# echo "================================================="
|
226
|
-
# echo "Redland Bindings version $REDBINDVERSION successfully installed."
|
227
|
-
# echo "================================================="
|
228
|
-
#else
|
229
|
-
# echo "Redland Bindings version $REDBINDVERSION installation failed."
|
230
|
-
# FAILED=1
|
231
|
-
# exit $FAILED
|
232
|
-
#fi
|
233
|
-
else
|
234
|
-
echo "Redland folder exists."
|
235
|
-
fi
|
236
|
-
|
237
|
-
echo "Installing the opentox webservices"
|
238
|
-
mkdir webservices
|
239
|
-
cd webservices
|
240
|
-
|
241
|
-
echo "Install the opentox-ruby-api-wrapper"
|
242
|
-
echo "This could take a while..."
|
243
|
-
git clone git://github.com/helma/opentox-ruby-api-wrapper.git >>$INSTALLLOG 2>>$ERRLOG
|
244
|
-
cd opentox-ruby-api-wrapper
|
245
|
-
git checkout -b $BRANCH origin/$BRANCH >>$INSTALLLOG 2>>$ERRLOG
|
246
|
-
OTAPIVERSION=`cat VERSION`
|
247
|
-
sudo rake install | tee -a $INSTALLLOG
|
248
|
-
cd ..
|
249
|
-
CHECKOTAPI=`gem list | grep "opentox-ruby-api-wrapper" | grep "$OTAPIVERSION"`
|
250
|
-
if [ ! "$CHECKOTAPI" = '' ]
|
251
|
-
then
|
252
|
-
echo "================================================="
|
253
|
-
echo "opentox-ruby-api-wrapper ($OTAPIVERSION) successfully installed."
|
254
|
-
echo "================================================="
|
255
|
-
else
|
256
|
-
echo "opentox-ruby-api-wrapper ($OTAPIVERSION) installation failed."
|
257
|
-
FAILED=1
|
258
|
-
exit $FAILED
|
259
|
-
fi
|
260
|
-
|
261
|
-
echo "Installing the webservices: compound, dataset, algorithm, model, task, feature"
|
262
|
-
git clone git://github.com/helma/opentox-compound.git >>$INSTALLLOG 2>>$ERRLOG
|
263
|
-
git clone git://github.com/helma/opentox-dataset.git >>$INSTALLLOG 2>>$ERRLOG
|
264
|
-
git clone git://github.com/helma/opentox-algorithm.git >>$INSTALLLOG 2>>$ERRLOG
|
265
|
-
git clone git://github.com/helma/opentox-model.git >>$INSTALLLOG 2>>$ERRLOG
|
266
|
-
git clone git://github.com/helma/opentox-task.git >>$INSTALLLOG 2>>$ERRLOG
|
267
|
-
git clone git://github.com/helma/opentox-feature.git >>$INSTALLLOG 2>>$ERRLOG
|
268
|
-
|
269
|
-
cd opentox-compound
|
270
|
-
git checkout -b $BRANCH origin/$BRANCH >>$INSTALLLOG 2>>$ERRLOG
|
271
|
-
cd ../opentox-dataset
|
272
|
-
git checkout -b $BRANCH origin/$BRANCH >>$INSTALLLOG 2>>$ERRLOG
|
273
|
-
cd ../opentox-algorithm
|
274
|
-
git checkout -b $BRANCH origin/$BRANCH >>$INSTALLLOG 2>>$ERRLOG
|
275
|
-
cd ../opentox-model
|
276
|
-
git checkout -b $BRANCH origin/$BRANCH >>$INSTALLLOG 2>>$ERRLOG
|
277
|
-
cd ../opentox-task
|
278
|
-
git checkout -b $BRANCH origin/$BRANCH >>$INSTALLLOG 2>>$ERRLOG
|
279
|
-
cd ../opentox-task
|
280
|
-
git checkout -b development origin/development >>$INSTALLLOG 2>>$ERRLOG
|
281
|
-
cd ..
|
282
|
-
|
283
|
-
#edit /home/[username]/.opentox/config/test.yaml set :base_dir: /home/[username]/webservices
|
284
|
-
|
285
|
-
echo "Installing the tests"
|
286
|
-
git clone git://github.com/helma/opentox-test.git >>$INSTALLLOG 2>>$ERRLOG
|
287
|
-
cd opentox-test
|
288
|
-
git checkout -b $BRANCH origin/$BRANCH >>$INSTALLLOG 2>>$ERRLOG
|
289
|
-
|
290
|
-
echo "Installing openbabel"
|
291
|
-
cd ../opentox-compound
|
292
|
-
sudo rake openbabel:install | tee -a $INSTALLLOG
|
293
|
-
sudo ldconfig >>$INSTALLLOG 2>>$ERRLOG
|
294
|
-
|
295
|
-
ln -s /usr/local/lib/libopenbabel.so.3 /usr/lib/libopenbabel.so.3 >> $INSTALLLOG 2>>$ERR
|
296
|
-
#VERSION=` --version`
|
297
|
-
#if [ "$VERSION" == "$RAPTORVERSION" ]
|
298
|
-
#then
|
299
|
-
# echo "================================================="
|
300
|
-
# echo "Raptor version $RAPTORVERSION successfully installed."
|
301
|
-
# echo "================================================="
|
302
|
-
#else
|
303
|
-
# echo "Raptor version $RAPTORVERSION installation failed."
|
304
|
-
# FAILED=1
|
305
|
-
# exit $FAILED
|
306
|
-
#fi
|
307
|
-
|
308
|
-
|
309
|
-
#check /webservices/opentox-algorithm/fminer.rb for 1,0/ture,false bug
|
310
|
-
BUGCHECK1=`grep "@@fminer.AddActivity(true, id)" $STARTPATH/webservices/opentox-algorithm/fminer.rb`
|
311
|
-
BUGCHECK2=`grep "@@fminer.AddActivity(false, id)" $STARTPATH/webservices/opentox-algorithm/fminer.rb`
|
312
|
-
if [ -z "$BUGCHECK1$BUGCHECK2" ]
|
313
|
-
then
|
314
|
-
echo "fminer.rb is correct."
|
315
|
-
else
|
316
|
-
sed -i 's/@@fminer.AddActivity(true, id)/@@fminer.AddActivity(1, id)/g' $STARTPATH/webservices/opentox-algorithm/fminer.rb
|
317
|
-
sed -i 's/@@fminer.AddActivity(false, id)/@@fminer.AddActivity(0, id)/g' $STARTPATH/webservices/opentox-algorithm/fminer.rb
|
318
|
-
echo "fminer.rb updated."
|
319
|
-
fi
|
320
|
-
|
321
|
-
#todo: configure libfminer Makefile (location of ruby.h)
|
322
|
-
#-> fixed by using davor's repository
|
323
|
-
|
324
|
-
|
325
|
-
cd ../opentox-algorithm
|
326
|
-
echo "Installing fminer"
|
327
|
-
echo "This could take a while..."
|
328
|
-
sudo updatedb
|
329
|
-
sudo rake fminer:install | tee -a $INSTALLLOG
|
330
|
-
cd ..
|
331
|
-
FMINERVERSION=`ls $STARTPATH/webservices/opentox-algorithm/libfminer | grep "fminer.so"`
|
332
|
-
if [ "$FMINERVERSION" == "fminer.so" ]
|
333
|
-
then
|
334
|
-
echo "================================================="
|
335
|
-
echo "Fminer successfully installed."
|
336
|
-
echo "================================================="
|
337
|
-
else
|
338
|
-
echo "Fminer installation failed."
|
339
|
-
FAILED=1
|
340
|
-
exit $FAILED
|
341
|
-
fi
|
342
|
-
|
343
|
-
if [ $FAILED == 0 ]
|
344
|
-
then
|
345
|
-
#get username
|
346
|
-
echo "Please enter username:"
|
347
|
-
read USERNAME
|
348
|
-
|
349
|
-
#change rights from root to user
|
350
|
-
sudo chown -R $USERNAME: $STARTPATH/webservices/
|
351
|
-
sudo chown -R $USERNAME: ~/.opentox/
|
352
|
-
fi
|
353
|
-
|
354
|
-
if [ "$FAILED" == "1" ]
|
355
|
-
then
|
356
|
-
echo "================================================="
|
357
|
-
echo "Installation script failed!"
|
358
|
-
echo "================================================="
|
359
|
-
exit 1
|
360
|
-
else
|
361
|
-
echo "================================================="
|
362
|
-
echo "opentox-install-script is completed."
|
363
|
-
echo "================================================="
|
364
|
-
echo "Configuration:"
|
365
|
-
echo "Edit the settings in $HOME/.opentox/config/{development|production|test}.yaml for your environment."
|
366
|
-
echo "================================================="
|
367
|
-
echo "Start the webservices local:"
|
368
|
-
echo "cd webservices/opentox-test/"
|
369
|
-
echo "rake opentox:services:start"
|
370
|
-
echo "================================================="
|
371
|
-
echo "Test local webservices:"
|
372
|
-
echo "rake features"
|
373
|
-
echo "================================================="
|
374
|
-
fi
|
375
|
-
exit 0
|