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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
# Make updates in this file and copy to container (even if stopped !)
# docker cp service-tests.rb service-tests:/home/ist/service-tests/service-tests.rb
require 'minitest/autorun'
require 'rest-client'
require 'nokogiri'
require 'csv'
class WebServiceTests < Minitest::Test
def get_models
require '../lazar/lib/lazar.rb'
$models = OpenTox::Model::Validation.all
$r_model = $models.select{|m| m if m.model.name == "LOAEL (training_log10)"}[0].id.to_s
$c_model = $models.select{|m| m if m.model.name == "Mutagenicity (kazius)"}[0].id.to_s
end
def test_virtuoso
puts "\nhttps://virtuoso.in-silico.ch"
assert_raises RestClient::NotFound do
response = RestClient.get "https://virtuoso.in-silico.ch"
end
end
def test_insilico_website
puts "\nhttps://in-silico.ch"
response = RestClient.get "https://in-silico.ch"
assert_equal response.code, 200
xml = Nokogiri::HTML.parse(response.body)
value = xml.at('li.active').text.strip
assert_equal "Software and services", value
end
def test_predictive_toxicology
puts "\nhttps://predictive-toxicology.org/"
response = RestClient.get "https://predictive-toxicology.org/"
assert_equal response.code, 200
xml = Nokogiri::HTML.parse(response.body)
value = xml.at('title').text
assert_equal "Predictive Toxicology", value
end
def test_lazar_batch
puts "\nhttps://lazar-batch.in-silico.ch"
require '../batch-login.rb'
assert_raises RestClient::Unauthorized do
response = RestClient.get "https://lazar-batch.in-silico.ch"
end
assert_raises RestClient::Unauthorized do
response = RestClient::Request.execute method: :get, url: "https://lazar-batch.in-silico.ch", user: $user+"f", password: $passwd
end
assert_raises RestClient::Unauthorized do
response = RestClient::Request.execute method: :get, url: "https://lazar-batch.in-silico.ch", user: $user, password: $passwd+"f"
end
response = RestClient::Request.execute method: :get, url: "https://lazar-batch.in-silico.ch", user: $user, password: $passwd
xml = Nokogiri::HTML.parse(response.body)
assert_match xml.at('h1').text.gsub(/\n/,"").strip, "lazar toxicity predictions"
# batch
get_models
response = RestClient::Request.execute method: :post,
url: "https://lazar-batch.in-silico.ch/predict",
user: $user,
password: $passwd,
payload: {
multipart: true,
fileselect: File.new('./test.csv', 'rb'),
selection: {$r_model => ""}
}
assert_equal response.code, 200
xml = Nokogiri::HTML.parse(response.body)
value = xml.css('h5').text
assert_equal "Lowest observed adverse effect level (LOAEL) (Rat)", value
value = xml.at_css('a#detailsbutton_0').text.strip
assert_equal "Details", value
end
def test_dump
puts "\nhttps://dump.in-silico.ch"
response = RestClient.get "https://dump.in-silico.ch"
assert_equal response.code, 200
xml = Nokogiri::HTML.parse(response.body)
dumpsize = xml.at('pre').text.split.last.to_i
response = RestClient.get "https://dump.in-silico.ch/dump.tar.gz"
assert_equal response.body.size.to_i, dumpsize
end
def test_lazar
puts "\nhttps://lazar.in-silico.ch"
get_models
response = RestClient.get "https://lazar.in-silico.ch"
assert_equal response.code, 200
xml = Nokogiri::HTML.parse(response.body)
assert_match xml.at('h1').text.gsub(/\n/,"").strip, "lazar toxicity predictions"
puts "\npredict regression: https://lazar.in-silico.ch/predict"
# regression
response = RestClient.post "https://lazar.in-silico.ch/predict", {identifier: "O=[N+]([O-])c1ccccc1", selection: {$r_model=>""}}
xml = Nokogiri::HTML.parse(response.body)
value = xml.css('td')[1].css('p')[2].text.split[1].to_f
assert value.between?(0.06,0.09)
puts "\npredict classification: https://lazar.in-silico.ch/predict"
# classification
response = RestClient.post "https://lazar.in-silico.ch/predict", {identifier: "O=[N+]([O-])c1ccccc1", selection: {$c_model=>""}}
xml = Nokogiri::HTML.parse(response.body)
value = xml.css('td')[1].css('p')[4].text.split.last
assert_equal "mutagenic", value
# regression
puts "\nmodel details regression: https://lazar.in-silico.ch/predict/modeldetails/#{$r_model}"
response = RestClient.get "https://lazar.in-silico.ch/predict/modeldetails/#{$r_model}"
xml = Nokogiri::HTML.parse(response.body)
puts "check metadata\n"
links = xml.css('a')
assert_equal "https://github.com/opentox/loael-paper/blob/revision/data/training_log10.csv", links[0].children.text.strip
assert_equal "training_log10", links[1].children.text.strip
assert_equal "Algorithm::Similarity.tanimoto", links[2].children.text.strip
assert_equal "Algorithm::Caret.rf", links[3].children.text.strip
text = xml.css('div.panel-body')[0]
a,b = text.children[4].text.strip.split("\n")
assert_equal "Type:", a.strip
assert_equal "Regression", b.strip
a,b = text.children[6].text.strip.split("\n")
assert_equal "Training compounds:", a.strip
assert_equal "671", b.strip
text = xml.css('div.panel-body')[1]
a,b,c = text.children[8].text.strip.split
assert_equal "Descriptors:", a.strip
assert_equal "fingerprint,", b.strip
assert_equal "MP2D", c.strip
# classification
puts "\nmodel details classification: https://lazar.in-silico.ch/predict/modeldetails/#{$c_model}"
response = RestClient.get "https://lazar.in-silico.ch/predict/modeldetails/#{$c_model}"
xml = Nokogiri::HTML.parse(response.body)
puts "check metadata\n"
links = xml.css('a')
assert_equal "http://cheminformatics.org/datasets/", links[0].children.text.strip
assert_equal "kazius", links[1].children.text.strip
assert_equal "Algorithm::Similarity.tanimoto", links[2].children.text.strip
assert_equal "Algorithm::Classification.weighted_majority_vote", links[3].children.text.strip
text = xml.css('div.panel-body')[0]
a,b = text.children[4].text.strip.split("\n")
assert_equal "Type:", a.strip
assert_equal "Classification", b.strip
a,b = text.children[6].text.strip.split("\n")
assert_equal "Training compounds:", a.strip
assert_equal "4069", b.strip
text = xml.css('div.panel-body')[1]
a,b,c = text.children[8].text.strip.split
assert_equal "Descriptors:", a.strip
assert_equal "fingerprint,", b.strip
assert_equal "MP2D", c.strip
end
def test_nano_lazar
puts "\nhttps://nano-lazar.in-silico.ch"
response = RestClient.get "https://nano-lazar.in-silico.ch"
assert_equal response.code, 200
xml = Nokogiri::HTML.parse(response.body)
assert_match xml.at('h1').text.gsub(/\n/,"").strip, "nano-lazar toxicity predictions"
params = {example_coating_0: "N-(2-Mercaptopropionyl)glycine",
example_core: "Au",
example_id: "5878a6097b6c9b003a862710",
example_pc: "{}",
input_coating_0: "N-(2-Mercaptopropionyl)glycine",
input_core: "Au",
prediction_model: "5878aa1d7b6c9b003a8629b1",
type: "fingerprint"
}
puts "\npredict example: https://nano-lazar.in-silico.ch/predict"
response = RestClient.post "https://nano-lazar.in-silico.ch/predict", params
xml = Nokogiri::HTML.parse(response.body)
value = xml.css('tbody').css('tr')[1].css('td')[0].css('a').text.gsub(/\n/,"").strip
assert_equal value, "G15.AC"
end
def test_aop
puts "\nhttps://aop.in-silico.ch"
response = RestClient.get "https://aop.in-silico.ch"
assert_equal response.code, 200
xml = Nokogiri::HTML.parse(response.body)
assert_match xml.at('h1').text.gsub(/\n/,"").strip, "PubChem read across"
puts "\nhttps://aop.in-silico.ch/cid/31703"
response = RestClient.get "https://aop.in-silico.ch/cid/31703"
assert_equal response.code, 200
xml = Nokogiri::HTML.parse(response.body)
value = xml.at('th').text.split.first.strip
assert_equal "(7S,9S)-7-[(2R,4S,5S,6S)-4-amino-5-hydroxy-6-methyloxan-2-yl]oxy-6,9,11-trihydroxy-9-(2-hydroxyacetyl)-4-methoxy-8,10-dihydro-7H-tetracene-5,12-dione", value
end
def test_dg2_Elena
puts "\nhttps://dg2.in-silico.ch"
response = RestClient.get "https://dg2.in-silico.ch"
assert_equal response.code, 200
xml = Nokogiri::HTML.parse(response.body)
batch_file_id = xml.search("label")[4].attributes["for"].value.gsub(/existing|\[|\]/,"")
batch_file_name = xml.search("label")[4].text.strip
assert_match xml.at('h1').text.gsub(/\n/,"").strip, "lazar toxicity predictions"
puts "\nsingle prediction Mazzatorta: https://dg2.in-silico.ch/predict"
response = RestClient.post "https://dg2.in-silico.ch/predict", {identifier: "O=[N+]([O-])c1ccccc1", selection: {"Mazzatorta"=>""}}
xml = Nokogiri::HTML.parse(response.body)
value = xml.css('td')[1].css('p')[0].text.split[1].to_f
assert value, 0.384
puts "\nsingle prediction lazar LOAEL: https://dg2.in-silico.ch/predict"
response = RestClient.post "https://dg2.in-silico.ch/predict", {identifier: "O=[N+]([O-])c1ccccc1", selection: {"5ba4e38b5e110b01688fa0ca"=>""}}
xml = Nokogiri::HTML.parse(response.body)
value = xml.css('td')[1].css('p')[2].text.split[1].to_f
assert value, 0.0807
puts "\nbatch prediction with first dataset in existing list\n"
response = RestClient.post "https://dg2.in-silico.ch/predict", {existing: {batch_file_id=>""}, selection: {"5ba4e38b5e110b01688fa0ca"=>""}}
assert_equal response.code, 200
xml = Nokogiri::HTML.parse(response.body)
title = xml.search("h3").text
assert_equal title, "Batch Prediction Results:RHC_input"
sleep 3
href = xml.search("a#downbutton_0")[0]["href"]
puts "\ndownload csv batch results\n"
response = RestClient.get href
csv = CSV.new(response.body)
header = csv.first
["ID", "Original ID", "Input", "Endpoint"].each do |h|
assert_includes header, h
end
puts "\nmodel details lazar LOAEL: https://dg2.in-silico.ch/predict/modeldetails/5ba4e38b5e110b01688fa0ca"
response = RestClient.get "https://dg2.in-silico.ch/predict/modeldetails/5ba4e38b5e110b01688fa0ca"
xml = Nokogiri::HTML.parse(response.body)
puts "check metadata\n"
links = xml.css('a')
assert_equal "https://github.com/opentox/loael-paper/blob/revision/data/training_log10.csv", links[0].children.text.strip
assert_equal "training_log10", links[1].children.text.strip
assert_equal "Algorithm::Similarity.tanimoto", links[2].children.text.strip
assert_equal "Algorithm::Caret.rf", links[3].children.text.strip
text = xml.css('div.panel-body')[0]
a,b = text.children[4].text.strip.split("\n")
assert_equal "Type:", a.strip
assert_equal "Regression", b.strip
a,b = text.children[6].text.strip.split("\n")
assert_equal "Training compounds:", a.strip
assert_equal "671", b.strip
text = xml.css('div.panel-body')[1]
a,b,c = text.children[8].text.strip.split
assert_equal "Descriptors:", a.strip
assert_equal "fingerprint,", b.strip
assert_equal "MP2D", c.strip
end
def test_dg3_Elena
puts "\nhttps://dg3.in-silico.ch"
response = RestClient.get "https://dg3.in-silico.ch"
assert_equal response.code, 200
xml = Nokogiri::HTML.parse(response.body)
assert_match xml.at('h1').text.gsub(/\n/,"").strip, "lazar toxicity predictions"
end
def test_test1_Elena
puts "\nhttps://test1.in-silico.ch"
response = RestClient.get "https://test1.in-silico.ch"
assert_equal response.code, 200
xml = Nokogiri::HTML.parse(response.body)
assert_match xml.at('h1').text.gsub(/\n/,"").strip, "Nestec Toxicity Predictions"
end
#def test_git_server
#TODO Net::HTTPBadResponse: wrong status line: "SSH-2.0-OpenSSH_7.8"
# response = RestClient.get "https://git.in-silico.ch"
#end
def test_git_server_website
puts "\nhttps://git.in-silico.ch"
response = RestClient.get "https://git.in-silico.ch"
assert_equal response.code, 200
end
def test_orn_lazar_website
puts "\nhttps://lazar.prod.openrisknet.org/"
response = RestClient.get "https://lazar.prod.openrisknet.org/"
assert_equal response.code, 200
end
def test_server_invalid_cert
puts "\ninvalid cert test4"
assert_raises RestClient::SSLCertificateNotVerified do
response = RestClient.get "https://test4.in-silico.ch"
end
end
end
|