opentox-ruby 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/compound.rb +3 -3
- data/lib/helper.rb +2 -1
- data/lib/parser.rb +51 -15
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.1
|
data/lib/compound.rb
CHANGED
@@ -159,9 +159,9 @@ module OpenTox
|
|
159
159
|
# @param [Array] deactivating Array with deactivating Smarts strings
|
160
160
|
# @return [String] URI for compound image with highlighted fragments
|
161
161
|
def matching_smarts_image_uri(activating, deactivating)
|
162
|
-
activating_smarts =
|
163
|
-
deactivating_smarts =
|
164
|
-
File.join @uri, "smarts/activating",
|
162
|
+
activating_smarts = "\"#{activating.collect{|smarts| CGI.escape(smarts)}.join("\"/\"")}\""
|
163
|
+
deactivating_smarts = "\"#{deactivating.collect{|smarts| CGI.escape(smarts)}.join("\"/\"")}\""
|
164
|
+
File.join @uri, "smarts/activating", activating_smarts, "deactivating", deactivating_smarts
|
165
165
|
end
|
166
166
|
|
167
167
|
|
data/lib/helper.rb
CHANGED
@@ -44,8 +44,9 @@ helpers do
|
|
44
44
|
|
45
45
|
def uri_available?(urlStr)
|
46
46
|
url = URI.parse(urlStr)
|
47
|
+
subjectidstr = @subjectid ? "?subjectid=#{CGI.escape @subjectid}" : ""
|
47
48
|
Net::HTTP.start(url.host, url.port) do |http|
|
48
|
-
return http.head("#{url.request_uri}
|
49
|
+
return http.head("#{url.request_uri}#{subjectidstr}").code == "200"
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
data/lib/parser.rb
CHANGED
@@ -277,7 +277,16 @@ module OpenTox
|
|
277
277
|
def load_spreadsheet(book)
|
278
278
|
book.default_sheet = 0
|
279
279
|
add_features book.row(1)
|
280
|
-
|
280
|
+
|
281
|
+
# AM: fix mixed read in
|
282
|
+
regression_features=false
|
283
|
+
2.upto(book.last_row) { |i|
|
284
|
+
row = book.row(i)
|
285
|
+
regression_features = detect_regression_features row
|
286
|
+
break if regression_features==true
|
287
|
+
}
|
288
|
+
|
289
|
+
2.upto(book.last_row) { |i| add_values book.row(i),regression_features }
|
281
290
|
warnings
|
282
291
|
@dataset
|
283
292
|
end
|
@@ -289,11 +298,21 @@ module OpenTox
|
|
289
298
|
row = 0
|
290
299
|
input = csv.split("\n")
|
291
300
|
add_features split_row(input.shift)
|
292
|
-
|
301
|
+
|
302
|
+
|
303
|
+
# AM: fix mixed read in
|
304
|
+
regression_features=false
|
305
|
+
input.each { |row|
|
306
|
+
row = split_row(row)
|
307
|
+
regression_features = detect_regression_features row
|
308
|
+
break if regression_features==true
|
309
|
+
}
|
310
|
+
input.each { |row| add_values split_row(row),regression_features }
|
293
311
|
warnings
|
294
312
|
@dataset
|
295
313
|
end
|
296
314
|
|
315
|
+
|
297
316
|
private
|
298
317
|
|
299
318
|
def warnings
|
@@ -335,7 +354,20 @@ module OpenTox
|
|
335
354
|
end
|
336
355
|
end
|
337
356
|
|
338
|
-
def
|
357
|
+
def detect_regression_features row
|
358
|
+
row.shift
|
359
|
+
regression_features=false
|
360
|
+
row.each_index do |i|
|
361
|
+
value = row[i]
|
362
|
+
type = feature_type(value)
|
363
|
+
if type == OT.NumericFeature
|
364
|
+
regression_features=true
|
365
|
+
end
|
366
|
+
end
|
367
|
+
regression_features
|
368
|
+
end
|
369
|
+
|
370
|
+
def add_values(row, regression_features=false)
|
339
371
|
|
340
372
|
smiles = row.shift
|
341
373
|
compound = Compound.from_smiles(smiles)
|
@@ -353,19 +385,23 @@ module OpenTox
|
|
353
385
|
|
354
386
|
@feature_types[feature] << type
|
355
387
|
|
356
|
-
|
357
|
-
when OT.NominalFeature
|
358
|
-
case value.to_s
|
359
|
-
when TRUE_REGEXP
|
360
|
-
val = true
|
361
|
-
when FALSE_REGEXP
|
362
|
-
val = false
|
363
|
-
end
|
364
|
-
when OT.NumericFeature
|
388
|
+
if (regression_features)
|
365
389
|
val = value.to_f
|
366
|
-
|
367
|
-
|
368
|
-
|
390
|
+
else
|
391
|
+
case type
|
392
|
+
when OT.NominalFeature
|
393
|
+
case value.to_s
|
394
|
+
when TRUE_REGEXP
|
395
|
+
val = true
|
396
|
+
when FALSE_REGEXP
|
397
|
+
val = false
|
398
|
+
end
|
399
|
+
when OT.NumericFeature
|
400
|
+
val = value.to_f
|
401
|
+
when OT.StringFeature
|
402
|
+
val = value.to_s
|
403
|
+
@activity_errors << smiles+", "+row.join(", ")
|
404
|
+
end
|
369
405
|
end
|
370
406
|
if val!=nil
|
371
407
|
@dataset.add(compound.uri, feature, val)
|
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: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.
|
9
|
+
- 1
|
10
|
+
version: 2.0.1
|
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-06-15 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|