blob: 256a06a7edfd2ede4ef02ffe1e6baf85860a11d2 (
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
|
require 'test_helper'
class OpentoxRubyApiWrapperTest < Test::Unit::TestCase
def setup
@pids = []
port = 5000
[ "opentox-compound", "opentox-feature" , "opentox-dataset" , "opentox-fminer" , "opentox-lazar" ].each do |component|
ENV[component.upcase.gsub(/-/,'_')] = "http://localhost:#{port}/"
=begin
Dir.chdir ENV['HOME'] + '/webservices/' + component
Dir["test.sqlite3"].each { |f| FileUtils.rm_rf(f) }
file = 'application.rb'
@pids << fork {`urxvt -title #{component} -e thin --debug --rackup config.ru start -p #{port} -e test`}
Process.detach(@pids.last)
=end
port += 1
end
end
=begin
def teardown
@pids.each do |pid|
begin
Process.kill(9,pid)
puts "killed " + pid.to_s
rescue
puts "failed to kill process" + pid.to_s
end
end
end
=end
def test_create_dataset_and_model_and_make_a_prediction
#sleep 15
dataset = OpenTox::Dataset.new :name => "Hamster Carcinogenicity", :filename => "test/hamster_carcinogenicity.csv"
puts dataset.uri
wait_for_completion dataset
assert_match(/#{ENV['OPENTOX_DATASET']}\d+$/,dataset.uri)
assert_equal("Hamster Carcinogenicity",dataset.name)
lazar = OpenTox::Lazar.new :dataset_uri => dataset.uri
puts lazar.uri
wait_for_completion lazar
assert_match(/#{ENV['OPENTOX_LAZAR']}model\/\d+$/,lazar.uri)
query_structure = OpenTox::Compound.new :smiles => 'c1ccccc1NN'
prediction = lazar.predict query_structure
puts prediction.uri
wait_for_completion prediction
puts prediction.to_yaml
assert_equal(true, prediction.classification)
assert_match(/\d+/, prediction.classification)
end
end
def wait_for_completion(object)
timeout = 60
time = 0
while (!object.finished? and time < timeout)
sleep 1
time += 1
end
puts "timeout" if timeout >= 60
end
|