opentox-ruby-api-wrapper 1.5.7 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -25,7 +25,8 @@ begin
25
25
  "roo",
26
26
  "spreadsheet",
27
27
  "google-spreadsheet-ruby",
28
- "tmail"
28
+ "tmail",
29
+ "rinruby"
29
30
  ].each { |dep| gem.add_dependency dep }
30
31
  [ "dm-core",
31
32
  'dm-serializer',
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.7
1
+ 1.6.0
data/lib/compound.rb CHANGED
@@ -1,3 +1,6 @@
1
+ @@cactus_uri="http://cactus.nci.nih.gov/chemical/structure/"
2
+ @@ambit_uri="http://ambit.uni-plovdiv.bg:8080/ambit2/depict/cdk?search="
3
+
1
4
  module OpenTox
2
5
 
3
6
  class Compound #< OpenTox
@@ -6,7 +9,6 @@ module OpenTox
6
9
 
7
10
  # Initialize with <tt>:uri => uri</tt>, <tt>:smiles => smiles</tt> or <tt>:name => name</tt> (name can be also an InChI/InChiKey, CAS number, etc)
8
11
  def initialize(params)
9
- @@cactus_uri="http://cactus.nci.nih.gov/chemical/structure/"
10
12
  if params[:smiles]
11
13
  @inchi = smiles2inchi(params[:smiles])
12
14
  @uri = File.join(@@config[:services]["opentox-compound"],URI.escape(@inchi))
@@ -45,12 +47,17 @@ module OpenTox
45
47
  obconversion(@inchi,'inchi','sdf')
46
48
  end
47
49
 
48
- def image
50
+ def gif
49
51
  RestClientWrapper.get("#{@@cactus_uri}#{@inchi}/image")
50
52
  end
51
53
 
54
+ def png
55
+ RestClientWrapper.get("#{@@ambit_uri}#{smiles}")
56
+ end
57
+
52
58
  def image_uri
53
- "#{@@cactus_uri}#{@inchi}/image"
59
+ "#{@@ambit_uri}#{smiles}"
60
+ #"#{@@cactus_uri}#{@inchi}/image"
54
61
  end
55
62
 
56
63
  # Matchs a smarts string
@@ -69,6 +76,12 @@ module OpenTox
69
76
  smarts_array.collect{|s| s if match?(s)}.compact
70
77
  end
71
78
 
79
+ # AM
80
+ # Match an array of smarts features, returns (0)1 for (non)matching features at each pos
81
+ def match_all(smarts_array)
82
+ smarts_array.collect{|s| match?(s) ? 1 : 0 }
83
+ end
84
+
72
85
  def sdf2inchi(sdf)
73
86
  obconversion(sdf,'sdf','inchi')
74
87
  end
data/lib/dataset.rb CHANGED
@@ -86,8 +86,10 @@ module OpenTox
86
86
  def get_predicted_class(compound, feature)
87
87
  v = get_value(compound, feature)
88
88
  if v.is_a?(Hash)
89
- if v.has_key?(:classification)
90
- return v[:classification]
89
+ k = v.keys.grep(/classification/).first
90
+ unless k.empty?
91
+ #if v.has_key?(:classification)
92
+ return v[k]
91
93
  else
92
94
  return "no classification key"
93
95
  end
@@ -103,12 +105,37 @@ module OpenTox
103
105
  end
104
106
  end
105
107
 
108
+ # returns regression value
109
+ def get_predicted_regression(compound, feature)
110
+ v = get_value(compound, feature)
111
+ if v.is_a?(Hash)
112
+ k = v.keys.grep(/regression/).first
113
+ unless k.empty?
114
+ return v[k]
115
+ else
116
+ return "no regression key"
117
+ end
118
+ elsif v.is_a?(Array)
119
+ raise "predicted regression value is an array\n"+
120
+ "value "+v.to_s+"\n"+
121
+ "value-class "+v.class.to_s+"\n"+
122
+ "dataset "+@uri.to_s+"\n"+
123
+ "compound "+compound.to_s+"\n"+
124
+ "feature "+feature.to_s+"\n"
125
+ else
126
+ return v
127
+ end
128
+ end
129
+
106
130
  # returns prediction confidence if available
107
131
  def get_prediction_confidence(compound, feature)
108
132
  v = get_value(compound, feature)
109
133
  if v.is_a?(Hash)
110
- if v.has_key?(:confidence)
111
- return v[:confidence].abs
134
+ k = v.keys.grep(/confidence/).first
135
+ unless k.empty?
136
+ #if v.has_key?(:confidence)
137
+ return v[k].abs
138
+ #return v["http://ot-dev.in-silico.ch/model/lazar#confidence"].abs
112
139
  else
113
140
  # PENDING: return nil isntead of raising an exception
114
141
  raise "no confidence key"
data/lib/environment.rb CHANGED
@@ -41,7 +41,7 @@ if @@config[:database]
41
41
  end
42
42
  end
43
43
 
44
- # mail for error messages
44
+ # load mail settings for error messages
45
45
  load File.join config_dir,"mail.rb" if File.exists?(File.join config_dir,"mail.rb")
46
46
 
47
47
  # hack: store sinatra in global var to make url_for and halt methods accessible
@@ -107,12 +107,12 @@ end
107
107
 
108
108
  logfile = "#{LOG_DIR}/#{ENV["RACK_ENV"]}.log"
109
109
  LOGGER = MyLogger.new(logfile,'daily') # daily rotation
110
- LOGGER.level = Logger::WARN if ENV["RACK_ENV"] == 'production'
111
-
112
- #LOGGER = MyLogger.new(STDOUT)
113
- #LOGGER.datetime_format = "%Y-%m-%d %H:%M:%S "
114
-
115
- #LOGGER.level = Logger::DEBUG
110
+ LOGGER.formatter = Logger::Formatter.new #this is neccessary to restore the formating in case active-record is loaded
111
+ if @@config[:logger] and @@config[:logger] == "debug"
112
+ LOGGER.level = Logger::DEBUG
113
+ else
114
+ LOGGER.level = Logger::WARN
115
+ end
116
116
 
117
117
  if File.exist?(user_file)
118
118
  @@users = YAML.load_file(user_file)
@@ -137,8 +137,8 @@ OT = Redland::Namespace.new 'http://www.opentox.org/api/1.1#'
137
137
  XML = Redland::Namespace.new 'http://www.w3.org/2001/XMLSchema#'
138
138
 
139
139
  # Regular expressions for parsing classification data
140
- TRUE_REGEXP = /^(true|active|$1^)/
141
- FALSE_REGEXP = /^(false|inactive|$0^)/
140
+ TRUE_REGEXP = /^(true|active|1|1.0)$/i
141
+ FALSE_REGEXP = /^(false|inactive|0|0.0)$/i
142
142
 
143
143
  # Task durations
144
144
  DEFAULT_TASK_MAX_DURATION = @@config[:default_task_max_duration]
data/lib/features.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # CH: should go into validation service
2
+ # - not a complete OT object
3
+ # - only used twice
4
+ # - what about ./validation/validation/validation_service.rb:241: value = OpenTox::Feature.new(:uri => a.uri).value(prediction_feature).to_s
1
5
  module OpenTox
2
6
 
3
7
  module Feature
@@ -12,4 +16,4 @@ module OpenTox
12
16
  end
13
17
 
14
18
  end
15
- end
19
+ end
data/lib/model.rb CHANGED
@@ -61,8 +61,10 @@ module OpenTox
61
61
 
62
62
  def classification?
63
63
  #HACK replace with request to ontology server
64
- if @title =~ /lazar classification/
64
+ if @title =~ /(?i)classification/
65
65
  return true
66
+ elsif @title =~ /(?i)regression/
67
+ return false
66
68
  elsif @uri =~/ntua/ and @title =~ /mlr/
67
69
  return false
68
70
  elsif @uri =~/tu-muenchen/ and @title =~ /regression|M5P|GaussP/
@@ -30,7 +30,7 @@
30
30
  opentox-algorithm: "http://localhost/algorithm/"
31
31
  opentox-model: "http://localhost/model/"
32
32
  opentox-task: "http://localhost/task/"
33
- opentox-validation: "http://opentox.informatik.uni-freiburg.de/validation/"
33
+ opentox-validation: "http://localhost/validation/"
34
34
  #
35
35
  # Accept headers:
36
36
  #
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentox-ruby-api-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 5
9
- - 7
10
- version: 1.5.7
8
+ - 6
9
+ - 0
10
+ version: 1.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Christoph Helma, Martin Guetlein
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-28 00:00:00 +02:00
18
+ date: 2010-07-19 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -229,21 +229,21 @@ dependencies:
229
229
  type: :runtime
230
230
  version_requirements: *id015
231
231
  - !ruby/object:Gem::Dependency
232
- name: dm-core
232
+ name: rinruby
233
233
  prerelease: false
234
234
  requirement: &id016 !ruby/object:Gem::Requirement
235
235
  none: false
236
236
  requirements:
237
237
  - - ">="
238
238
  - !ruby/object:Gem::Version
239
- hash: 1
239
+ hash: 3
240
240
  segments:
241
- - 1
242
- version: "1"
241
+ - 0
242
+ version: "0"
243
243
  type: :runtime
244
244
  version_requirements: *id016
245
245
  - !ruby/object:Gem::Dependency
246
- name: dm-serializer
246
+ name: dm-core
247
247
  prerelease: false
248
248
  requirement: &id017 !ruby/object:Gem::Requirement
249
249
  none: false
@@ -257,7 +257,7 @@ dependencies:
257
257
  type: :runtime
258
258
  version_requirements: *id017
259
259
  - !ruby/object:Gem::Dependency
260
- name: dm-timestamps
260
+ name: dm-serializer
261
261
  prerelease: false
262
262
  requirement: &id018 !ruby/object:Gem::Requirement
263
263
  none: false
@@ -271,7 +271,7 @@ dependencies:
271
271
  type: :runtime
272
272
  version_requirements: *id018
273
273
  - !ruby/object:Gem::Dependency
274
- name: dm-types
274
+ name: dm-timestamps
275
275
  prerelease: false
276
276
  requirement: &id019 !ruby/object:Gem::Requirement
277
277
  none: false
@@ -285,7 +285,7 @@ dependencies:
285
285
  type: :runtime
286
286
  version_requirements: *id019
287
287
  - !ruby/object:Gem::Dependency
288
- name: dm-migrations
288
+ name: dm-types
289
289
  prerelease: false
290
290
  requirement: &id020 !ruby/object:Gem::Requirement
291
291
  none: false
@@ -299,7 +299,7 @@ dependencies:
299
299
  type: :runtime
300
300
  version_requirements: *id020
301
301
  - !ruby/object:Gem::Dependency
302
- name: dm-mysql-adapter
302
+ name: dm-migrations
303
303
  prerelease: false
304
304
  requirement: &id021 !ruby/object:Gem::Requirement
305
305
  none: false
@@ -313,9 +313,23 @@ dependencies:
313
313
  type: :runtime
314
314
  version_requirements: *id021
315
315
  - !ruby/object:Gem::Dependency
316
- name: haml
316
+ name: dm-mysql-adapter
317
317
  prerelease: false
318
318
  requirement: &id022 !ruby/object:Gem::Requirement
319
+ none: false
320
+ requirements:
321
+ - - ">="
322
+ - !ruby/object:Gem::Version
323
+ hash: 1
324
+ segments:
325
+ - 1
326
+ version: "1"
327
+ type: :runtime
328
+ version_requirements: *id022
329
+ - !ruby/object:Gem::Dependency
330
+ name: haml
331
+ prerelease: false
332
+ requirement: &id023 !ruby/object:Gem::Requirement
319
333
  none: false
320
334
  requirements:
321
335
  - - ">="
@@ -325,11 +339,11 @@ dependencies:
325
339
  - 3
326
340
  version: "3"
327
341
  type: :runtime
328
- version_requirements: *id022
342
+ version_requirements: *id023
329
343
  - !ruby/object:Gem::Dependency
330
344
  name: cucumber
331
345
  prerelease: false
332
- requirement: &id023 !ruby/object:Gem::Requirement
346
+ requirement: &id024 !ruby/object:Gem::Requirement
333
347
  none: false
334
348
  requirements:
335
349
  - - ">="
@@ -339,11 +353,11 @@ dependencies:
339
353
  - 0
340
354
  version: "0"
341
355
  type: :development
342
- version_requirements: *id023
356
+ version_requirements: *id024
343
357
  - !ruby/object:Gem::Dependency
344
358
  name: jeweler
345
359
  prerelease: false
346
- requirement: &id024 !ruby/object:Gem::Requirement
360
+ requirement: &id025 !ruby/object:Gem::Requirement
347
361
  none: false
348
362
  requirements:
349
363
  - - ">="
@@ -353,12 +367,12 @@ dependencies:
353
367
  - 0
354
368
  version: "0"
355
369
  type: :development
356
- version_requirements: *id024
370
+ version_requirements: *id025
357
371
  description: Ruby wrapper for the OpenTox REST API (http://www.opentox.org)
358
372
  email: helma@in-silico.ch
359
373
  executables:
360
- - yaml2owl.rb
361
374
  - opentox-install-ubuntu.sh
375
+ - yaml2owl.rb
362
376
  - opentox-install-debian.sh
363
377
  extensions: []
364
378