opentox-ruby-api-wrapper 1.2.6 → 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ begin
10
10
  gem.email = "helma@in-silico.ch"
11
11
  gem.homepage = "http://github.com/helma/opentox-ruby-api-wrapper"
12
12
  gem.authors = ["Christoph Helma"]
13
- ["sinatra", "rest-client", "rack", "rack-contrib", "rack-flash", "thin", "emk-sinatra-url-for", "cehoffman-sinatra-respond_to", "dm-more", "dm-core", "sinatra-static-assets"].each do |dep|
13
+ ["sinatra", "rest-client", "rack", "rack-contrib", "rack-flash", "thin", "emk-sinatra-url-for", "cehoffman-sinatra-respond_to", "dm-more", "dm-core", "sinatra-static-assets", "do_sqlite3", "do_postgres"].each do |dep|
14
14
  gem.add_dependency dep
15
15
  end
16
16
  gem.add_development_dependency "cucumber"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.6
1
+ 1.2.7
@@ -39,6 +39,7 @@ module OpenTox
39
39
  end
40
40
 
41
41
  def self.create_model(params)
42
+ LOGGER.debug params
42
43
  @uri = RestClient.post File.join(@@config[:services]["opentox-algorithm"], "lazar"), :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri], :feature_generation_uri => File.join(@@config[:services]["opentox-algorithm"], "fminer")
43
44
  end
44
45
 
@@ -21,20 +21,20 @@ module OpenTox
21
21
  @uri = File.join(@@config[:services]["opentox-compound"],URI.escape(@inchi))
22
22
  elsif params[:uri]
23
23
  @uri = params[:uri]
24
- if params[:uri].match(/InChI/) # shortcut for IST services
24
+ case params[:uri]
25
+ when /ambit/ # Ambit does not deliver InChIs reliably
26
+ smiles = RestClient.get @uri, :accept => 'chemical/x-daylight-smiles'
27
+ @inchi = obconversion(smiles,'smi','inchi')
28
+ when /InChI/ # shortcut for IST services
25
29
  @inchi = params[:uri].sub(/^.*InChI/, 'InChI')
26
30
  else
27
31
  @inchi = RestClient.get @uri, :accept => 'chemical/x-inchi'
28
- # AMBIT does not provide InChIs
29
- #smiles = RestClient.get(@uri, :accept => 'chemical/x-daylight-smiles').split(/\s+/).first # fix ambit output
30
- #@inchi = obconversion(smiles,'smi','inchi')
31
32
  end
32
33
  end
33
34
  end
34
35
 
35
36
  # Get the (canonical) smiles
36
37
  def smiles
37
- #RestClient.get(@uri, :accept => 'chemical/x-daylight-smiles').split(/\s+/).first # fix ambit output
38
38
  obconversion(@inchi,'inchi','can')
39
39
  end
40
40
 
@@ -0,0 +1,21 @@
1
+ # database
2
+ if @@config[:database]
3
+ require 'dm-core'
4
+ require 'dm-serializer'
5
+ require 'dm-timestamps'
6
+ require 'dm-types'
7
+ case @@config[:database][:adapter]
8
+ when /sqlite/i
9
+ db_dir = File.join(ENV['HOME'], ".opentox", "db")
10
+ FileUtils.mkdir_p db_dir
11
+ DataMapper::setup(:default, "sqlite3://#{db_dir}/opentox.sqlite3")
12
+ else
13
+ DataMapper.setup(:default, {
14
+ :adapter => @@config[:database][:adapter],
15
+ :database => @@config[:database][:database],
16
+ :username => @@config[:database][:username],
17
+ :password => @@config[:database][:password],
18
+ :host => @@config[:database][:host]})
19
+ end
20
+ end
21
+
@@ -87,7 +87,7 @@ module OpenTox
87
87
  def self.find(uri)
88
88
  dataset = Dataset.new
89
89
  data = `curl "#{uri}"`
90
- #data = RestClient.get uri, :accept => 'application/rdf+xml' # unclear why this does not work for complex uris, Dataset.find works from irb
90
+ #data = RestClient.get(uri, :accept => 'application/rdf+xml') # unclear why this does not work for complex uris, Dataset.find works from irb
91
91
  dataset.rdf = data
92
92
  dataset
93
93
  end
@@ -2,7 +2,7 @@ require 'logger'
2
2
  # set default environment
3
3
  ENV['RACK_ENV'] = 'test' unless ENV['RACK_ENV']
4
4
 
5
- # load configuration
5
+ # load/setup configuration
6
6
  basedir = File.join(ENV['HOME'], ".opentox")
7
7
  config_dir = File.join(basedir, "config")
8
8
  config_file = File.join(config_dir, "#{ENV['RACK_ENV']}.yaml")
@@ -19,6 +19,26 @@ else
19
19
  puts "Please edit #{config_file} and restart your application."
20
20
  exit
21
21
  end
22
+
23
+ # database
24
+ if @@config[:database]
25
+ ['dm-core', 'dm-serializer', 'dm-timestamps', 'dm-types'].each{|lib| require lib }
26
+ case @@config[:database][:adapter]
27
+ when /sqlite/i
28
+ db_dir = File.join(basedir, "db")
29
+ FileUtils.mkdir_p db_dir
30
+ DataMapper::setup(:default, "sqlite3://#{db_dir}/opentox.sqlite3")
31
+ else
32
+ DataMapper.setup(:default, {
33
+ :adapter => @@config[:database][:adapter],
34
+ :database => @@config[:database][:database],
35
+ :username => @@config[:database][:username],
36
+ :password => @@config[:database][:password],
37
+ :host => @@config[:database][:host]})
38
+ end
39
+ end
40
+
41
+ # logging
22
42
  logfile = "#{LOG_DIR}/#{ENV["RACK_ENV"]}.log"
23
43
  LOGGER = Logger.new(logfile,'daily') # daily rotation
24
44
  LOGGER.level = Logger::DEBUG
@@ -50,6 +50,14 @@ module OpenTox
50
50
  RestClient.post(@@config[:services]["opentox-model"], data, :content_type => "application/x-yaml").to_s
51
51
  end
52
52
 
53
+ # def self.create(task)
54
+ # @uri = RestClient.post(@@config[:services]["opentox-model"], :task_uri => task.uri)
55
+ # end
56
+
57
+ # def yaml=(data)
58
+ # RestClient.put(@@uri, data, :content_type => "application/x-yaml").to_s
59
+ # end
60
+
53
61
  def endpoint
54
62
  YAML.load(RestClient.get(uri))[:endpoint]
55
63
  end
@@ -10,7 +10,7 @@ module OpenTox
10
10
  end
11
11
 
12
12
  def self.create
13
- uri = RestClient.post @@config[:services]["opentox-task"], nil
13
+ uri = RestClient.post @@config[:services]["opentox-task"], {}
14
14
  Task.new(uri)
15
15
  end
16
16
 
@@ -26,19 +26,6 @@ module OpenTox
26
26
  task_uris = RestClient.get(@@config[:services]["opentox-task"]).split(/\n/)
27
27
  task_uris.collect{|uri| Task.new(uri)}
28
28
  end
29
-
30
- def started
31
- #LOGGER.info File.join(@uri,'started')
32
- RestClient.put File.join(@uri,'started'), {}
33
- end
34
-
35
- def cancel
36
- RestClient.put File.join(@uri,'cancelled'), {}
37
- end
38
-
39
- def completed(uri)
40
- RestClient.put File.join(@uri,'completed'), :resource => uri
41
- end
42
29
 
43
30
  def created_at
44
31
  RestClient.get File.join(@uri, 'created_at')
@@ -55,6 +42,26 @@ module OpenTox
55
42
  def resource
56
43
  RestClient.get File.join(@uri, 'resource')
57
44
  end
45
+
46
+ def started
47
+ RestClient.put File.join(@uri,'started'), {}
48
+ end
49
+
50
+ def cancel
51
+ RestClient.put File.join(@uri,'cancelled'), {}
52
+ end
53
+
54
+ def failed
55
+ RestClient.put File.join(@uri,'failed'), {}
56
+ end
57
+
58
+ def parent=(task)
59
+ RestClient.put File.join(@uri,'parent'), {:uri => task.uri}
60
+ end
61
+
62
+ def completed(uri)
63
+ RestClient.put File.join(@uri,'completed'), :resource => uri
64
+ end
58
65
 
59
66
  def pid=(pid)
60
67
  RestClient.put File.join(@uri, 'pid'), :pid => pid
@@ -64,8 +71,12 @@ module OpenTox
64
71
  self.status.to_s == 'completed'
65
72
  end
66
73
 
74
+ def failed?
75
+ self.status.to_s == 'failed'
76
+ end
77
+
67
78
  def wait_for_completion
68
- until self.completed?
79
+ until self.completed? or self.failed?
69
80
  sleep 1
70
81
  end
71
82
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentox-ruby-api-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Helma
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-31 00:00:00 +01:00
12
+ date: 2010-02-08 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -122,6 +122,26 @@ dependencies:
122
122
  - !ruby/object:Gem::Version
123
123
  version: "0"
124
124
  version:
125
+ - !ruby/object:Gem::Dependency
126
+ name: do_sqlite3
127
+ type: :runtime
128
+ version_requirement:
129
+ version_requirements: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: "0"
134
+ version:
135
+ - !ruby/object:Gem::Dependency
136
+ name: do_postgres
137
+ type: :runtime
138
+ version_requirement:
139
+ version_requirements: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: "0"
144
+ version:
125
145
  - !ruby/object:Gem::Dependency
126
146
  name: cucumber
127
147
  type: :development
@@ -151,6 +171,8 @@ files:
151
171
  - bin/yaml2owl.rb
152
172
  - lib/algorithm.rb
153
173
  - lib/compound.rb
174
+ - lib/config/config_ru.rb
175
+ - lib/config/database.rb
154
176
  - lib/dataset.rb
155
177
  - lib/environment.rb
156
178
  - lib/helper.rb
@@ -160,7 +182,6 @@ files:
160
182
  - lib/owl.rb
161
183
  - lib/spork.rb
162
184
  - lib/task.rb
163
- - lib/tasks/config.rb
164
185
  - lib/tasks/opentox.rb
165
186
  - lib/templates/config.yaml
166
187
  - lib/utils.rb