lazar 1.1.0 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 698fd96821077269f4c31fdfca6bead6beab36f0
4
- data.tar.gz: 2fd49abf99e8f5367b83764735c5c2e49caad4d2
3
+ metadata.gz: 4e7ee9c1cb08576d2bb23d8e8e44986d2dba9f9b
4
+ data.tar.gz: a88d6469cf221fb10d159498d6c35620cfcd3fe8
5
5
  SHA512:
6
- metadata.gz: ef5d243c765f5d1d6bb4c2dbd53bf2cdcca380df532cef8c48447b907ff01086f1b50c261e1f494827a30e52e7d8e62e2c077334cdbe30370546680ffd018886
7
- data.tar.gz: d9bb905832388dcb44bb3211fb6976c4e0894d75eb02fdf60c17fe19f25dec73ba24b5585fea8cb85e77b6793b46518462cf1d9b2488c465332b9db3af132028
6
+ metadata.gz: b9dcd28f5b1ccbf93135a0aad1fef42e6dde4c765e5addb94f624a4e2e08d25c3dadf238c68b0e58d4ec36ad8700ad02fcc7fe66d54665c0316df36829b8f302
7
+ data.tar.gz: d91ea1ea8684ee5aecff7663081a424ec2ffea66a6149c102c9074a80d57c3aa22d71e4a71ab91d4958260175238bd984bacd71a28b406b815b25102f8c2469f
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.3
data/lazar.gemspec CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  # specify any dependencies here; for example:
21
21
  s.add_runtime_dependency 'bundler'
22
22
  s.add_runtime_dependency 'rest-client'
23
+ s.add_runtime_dependency 'addressable'
23
24
  s.add_runtime_dependency 'nokogiri'
24
25
  s.add_runtime_dependency 'rserve-client'
25
26
  s.add_runtime_dependency 'mongoid'
data/lib/import.rb CHANGED
@@ -10,18 +10,17 @@ module OpenTox
10
10
  def self.import
11
11
  # time critical step: JSON parsing (>99%), Oj brings only minor speed gains (~1%)
12
12
  datasets = {}
13
- bundles = JSON.parse(RestClientWrapper.get('https://data.enanomapper.net/bundle?media=application%2Fjson'))["dataset"]
13
+ bundles = JSON.parse(RestClientWrapper.get('https://data.enanomapper.net/bundle', {}, {accept: :json}))["dataset"]
14
14
  bundles.each do |bundle|
15
15
  datasets[bundle["URI"]] = Dataset.find_or_create_by(:source => bundle["URI"],:name => bundle["title"].strip)
16
16
  $logger.debug bundle["title"].strip
17
- nanoparticles = JSON.parse(RestClientWrapper.get(bundle["dataset"]+"?media=application%2Fjson"))["dataEntry"]
17
+ nanoparticles = JSON.parse(RestClientWrapper.get(bundle["dataset"], {}, {accept: :json}))["dataEntry"]
18
18
  nanoparticles.each_with_index do |np,n|
19
19
  core_id = nil
20
20
  coating_ids = []
21
21
  np["composition"].each do |c|
22
22
  uri = c["component"]["compound"]["URI"]
23
- uri = CGI.escape File.join(uri,"&media=application/json")
24
- data = JSON.parse(RestClientWrapper.get "https://data.enanomapper.net/query/compound/url/all?media=application/json&search=#{uri}")
23
+ data = JSON.parse(RestClientWrapper.get("https://data.enanomapper.net/query/compound/url/all?search=#{uri}", {}, {accept: :json}))
25
24
  source = data["dataEntry"][0]["compound"]["URI"]
26
25
  smiles = data["dataEntry"][0]["values"]["https://data.enanomapper.net/feature/http%3A%2F%2Fwww.opentox.org%2Fapi%2F1.1%23SMILESDefault"]
27
26
  names = []
@@ -52,7 +51,7 @@ module OpenTox
52
51
  nanoparticle.dataset_ids << datasets[bundle_uri].id
53
52
  end
54
53
 
55
- studies = JSON.parse(RestClientWrapper.get(File.join(np["compound"]["URI"],"study")))["study"]
54
+ studies = JSON.parse(RestClientWrapper.get(File.join(np["compound"]["URI"],"study"), {}, {accept: :json}))["study"]
56
55
  studies.each do |study|
57
56
  dataset = datasets[np["bundles"].keys.first]
58
57
  proteomics_features = {}
data/lib/lazar.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require "bundler/setup"
3
3
  require "rest-client"
4
+ require 'addressable'
4
5
  require 'yaml'
5
6
  require 'json'
6
7
  require 'logger'
@@ -49,6 +50,7 @@ rlib = File.expand_path(File.join(File.dirname(__FILE__),"..","R"))
49
50
  # http://stackoverflow.com/questions/19619582/number-of-processors-cores-in-command-line
50
51
  NR_CORES = `getconf _NPROCESSORS_ONLN`.to_i
51
52
  R = Rserve::Connection.new
53
+ R.eval ".libPaths('#{rlib}')"
52
54
  R.eval "
53
55
  suppressPackageStartupMessages({
54
56
  library(labeling,lib=\"#{rlib}\")
data/lib/model.rb CHANGED
@@ -46,15 +46,18 @@ module OpenTox
46
46
  model.prediction_feature_id = prediction_feature.id
47
47
  model.training_dataset_id = training_dataset.id
48
48
  model.name = "#{prediction_feature.name} (#{training_dataset.name})"
49
- # TODO: check if this works for gem version, add gem versioning?
49
+ # git or gem versioning
50
50
  dir = File.dirname(__FILE__)
51
- commit = `cd #{dir}; git rev-parse HEAD`.chomp
52
- branch = `cd #{dir}; git rev-parse --abbrev-ref HEAD`.chomp
53
- url = `cd #{dir}; git config --get remote.origin.url`.chomp
54
- if branch
51
+ path = File.expand_path("../", File.expand_path(dir))
52
+ if Dir.exists?(dir+"/.git")
53
+ commit = `git rev-parse HEAD`.chomp
54
+ branch = `git rev-parse --abbrev-ref HEAD`.chomp
55
+ url = `git config --get remote.origin.url`.chomp
55
56
  model.version = {:url => url, :branch => branch, :commit => commit}
56
57
  else
57
- model.version = {:warning => "git is not installed"}
58
+ version = File.open(path+"/VERSION", &:gets).chomp
59
+ url = "https://rubygems.org/gems/lazar/versions/"+version
60
+ model.version = {:url => url, :branch => "gem", :commit => version}
58
61
  end
59
62
 
60
63
  # set defaults#
@@ -395,6 +398,7 @@ module OpenTox
395
398
  include Mongoid::Timestamps
396
399
 
397
400
  field :endpoint, type: String
401
+ field :qmrf, type: Hash
398
402
  field :species, type: String
399
403
  field :source, type: String
400
404
  field :unit, type: String
data/lib/overwrite.rb CHANGED
@@ -197,7 +197,7 @@ module URI
197
197
  # @param [String]
198
198
  # @return [TrueClass,FalseClass]
199
199
  def self.valid? uri
200
- u = URI.parse(uri)
200
+ u = Addressable::URI.parse(uri)
201
201
  u.scheme!=nil and u.host!=nil
202
202
  rescue URI::InvalidURIError
203
203
  false
@@ -26,6 +26,7 @@ module OpenTox
26
26
 
27
27
  define_singleton_method method do |uri,payload={},headers={},waiting_task=nil|
28
28
 
29
+ uri = Addressable::URI.encode(uri)
29
30
  # check input
30
31
  bad_request_error "Headers are not a hash: #{headers.inspect} for #{uri}." unless headers==nil or headers.is_a?(Hash)
31
32
  headers[:subjectid] ||= @@subjectid
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/lazar.rb'
3
+ include OpenTox
4
+ newfile = ARGV[0].sub(/.csv/,"_mmol_log10.csv")
5
+ p newfile
6
+ CSV.open(newfile, "wb") do |csv|
7
+ CSV.read(ARGV[0]).each do |line|
8
+ smi,mol = line
9
+ if mol.numeric?
10
+ c = Compound.from_smiles smi
11
+ #delog = 10**(-1*mol.to_f) #if values already -log10 but mol
12
+ mmol = mol.to_f*1000
13
+ log = -Math.log10(mmol)
14
+ csv << [smi, log]
15
+ else
16
+ csv << [smi, mol.gsub(/mol/,'mmol')]
17
+ end
18
+ end
19
+ end
data/test/Rpackages.rb ADDED
@@ -0,0 +1,14 @@
1
+ require_relative "setup.rb"
2
+
3
+ class LazarRpackagesTest < MiniTest::Test
4
+
5
+ def test_user_packages_installed
6
+ packages = ["caret", "randomForest", "ggplot2", "pls", "doMC", "gridExtra", "foreach", "iterators", "stringi"]
7
+ packages.each do |p|
8
+ r = R.eval "require(#{p})"
9
+ assert_equal 1, r.payload[0]
10
+ end
11
+ end
12
+
13
+ end
14
+
data/test/compound.rb CHANGED
@@ -61,7 +61,9 @@ print c.sdf
61
61
 
62
62
  def test_chemblid
63
63
  c = OpenTox::Compound.from_inchi "InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"
64
- assert_equal "CHEMBL277500", c.chemblid
64
+ assert_equal "CHEMBL1531487", c.chemblid
65
+ c = OpenTox::Compound.from_smiles "OC[C@](c1onc(n1)c1ncn2c1CN(C)C(=O)c1c2cccc1Cl)(O)C"
66
+ assert_equal "CHEMBL145418", c.chemblid
65
67
  end
66
68
 
67
69
  def test_sdf_storage
@@ -108,7 +110,7 @@ print c.sdf
108
110
 
109
111
  def test_molecular_weight
110
112
  c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C"
111
- assert_equal 100.15888, c.molecular_weight
113
+ assert_equal 100.15888, c.molecular_weight.round(5)
112
114
  end
113
115
 
114
116
  def test_physchem
data/test/setup.rb CHANGED
@@ -5,6 +5,7 @@ require_relative '../lib/lazar.rb'
5
5
  include OpenTox
6
6
  #$mongo.database.drop
7
7
  #$gridfs = $mongo.database.fs # recreate GridFS indexes
8
+ PhysChem.descriptors
8
9
  TEST_DIR ||= File.expand_path(File.dirname(__FILE__))
9
10
  DATA_DIR ||= File.join(TEST_DIR,"data")
10
11
  training_dataset = Dataset.where(:name => "Protein Corona Fingerprinting Predicts the Cellular Interaction of Gold and Silver Nanoparticles").first
@@ -84,7 +84,7 @@ class ValidationRegressionTest < MiniTest::Test
84
84
  repeated_cv = RepeatedCrossValidation.create model
85
85
  repeated_cv.crossvalidations.each do |cv|
86
86
  assert cv.r_squared > 0.34, "R^2 (#{cv.r_squared}) should be larger than 0.034"
87
- assert cv.rmse < 0.5, "RMSE (#{cv.rmse}) should be smaller than 0.5"
87
+ assert cv.rmse < 1.5, "RMSE (#{cv.rmse}) should be smaller than 0.5"
88
88
  end
89
89
  end
90
90
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Helma, Martin Guetlein, Andreas Maunz, Micha Rautenberg, David Vorgrimmler,
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-05-26 00:00:00.000000000 Z
12
+ date: 2018-04-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -39,6 +39,20 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: addressable
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: nokogiri
44
58
  requirement: !ruby/object:Gem::Requirement
@@ -155,6 +169,8 @@ files:
155
169
  - scripts/mg2mmol.rb
156
170
  - scripts/mirror-enm2test.rb
157
171
  - scripts/mmol2-log10.rb
172
+ - scripts/mol2mmol-log10.rb
173
+ - test/Rpackages.rb
158
174
  - test/all.rb
159
175
  - test/compound.rb
160
176
  - test/data/EPAFHM.csv
@@ -221,11 +237,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
237
  version: '0'
222
238
  requirements: []
223
239
  rubyforge_project: lazar
224
- rubygems_version: 2.5.2
240
+ rubygems_version: 2.6.8
225
241
  signing_key:
226
242
  specification_version: 4
227
243
  summary: Lazar framework
228
244
  test_files:
245
+ - test/Rpackages.rb
229
246
  - test/all.rb
230
247
  - test/compound.rb
231
248
  - test/data/EPAFHM.csv