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
|
# application.rb
# Loads sub-repositories, library code, and webapps.
# Author: Andreas Maunz
require 'statsample'
# Require sub-Repositories
require_relative 'libfminer/libbbrc/bbrc' # include before openbabel
require_relative 'libfminer/liblast/last' #
require_relative 'last-utils/lu.rb'
# Library Code
$logger.debug "Algorithm booting: #{$algorithm.collect{ |k,v| "#{k}: '#{v}'"} }"
Dir['./lib/*.rb'].each { |f| require f; also_reload f } # Libs
[
"descriptor.rb",
"feature-selection.rb",
"fminer.rb",
"lazar.rb",
"test.rb"
].each do |f|
require_relative f
also_reload f # Webapps
end
# Entry point
module OpenTox
class Application < Service
# for service check
head '/?' do
#$logger.debug "Algorithm service is running."
end
get '/?' do
render [ to('/lazar', :full),
to('/fminer/bbrc', :full),
to('/fminer/last', :full),
#to('/feature-selection/recursive-feature-elimination', :full),
to('/descriptor') ].join("\n") + "\n"
end
# generic route to swagger API file - hotfix because opentox-server route do not work
get "/api/algorithm.json" do
response['Content-Type'] = "application/json"
api_file = File.join("api", "algorithm.json")
bad_request_error "API Documentation in Swagger JSON is not implemented.", uri("/algorithm/api") unless File.exists?(api_file)
File.read(api_file)
end
end
end
|