summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2017-08-14 11:19:37 +0000
committergebele <gebele@in-silico.ch>2017-08-14 11:19:37 +0000
commitb2b9cc5d14d10a62025486c5b3abbbeb06bf0ec6 (patch)
treeb7a53a54fab65652a2b67d2cc6946810238ec6fb /lib
parentd04c3e870daaf6e42d08c8f8d32ab2f430e23b98 (diff)
parent6136efbd4066aeeb569424fbba619523ee038f95 (diff)
bumped version
Diffstat (limited to 'lib')
-rw-r--r--lib/import.rb9
-rw-r--r--lib/lazar.rb1
-rw-r--r--lib/model.rb1
-rw-r--r--lib/overwrite.rb2
-rw-r--r--lib/rest-client-wrapper.rb1
5 files changed, 8 insertions, 6 deletions
diff --git a/lib/import.rb b/lib/import.rb
index 96e7ad1..0857717 100644
--- a/lib/import.rb
+++ b/lib/import.rb
@@ -10,18 +10,17 @@ module OpenTox
def self.import
# time critical step: JSON parsing (>99%), Oj brings only minor speed gains (~1%)
datasets = {}
- bundles = JSON.parse(RestClientWrapper.get('https://data.enanomapper.net/bundle?media=application%2Fjson'))["dataset"]
+ bundles = JSON.parse(RestClientWrapper.get('https://data.enanomapper.net/bundle', {}, {accept: :json}))["dataset"]
bundles.each do |bundle|
datasets[bundle["URI"]] = Dataset.find_or_create_by(:source => bundle["URI"],:name => bundle["title"].strip)
$logger.debug bundle["title"].strip
- nanoparticles = JSON.parse(RestClientWrapper.get(bundle["dataset"]+"?media=application%2Fjson"))["dataEntry"]
+ nanoparticles = JSON.parse(RestClientWrapper.get(bundle["dataset"], {}, {accept: :json}))["dataEntry"]
nanoparticles.each_with_index do |np,n|
core_id = nil
coating_ids = []
np["composition"].each do |c|
uri = c["component"]["compound"]["URI"]
- uri = CGI.escape File.join(uri,"&media=application/json")
- data = JSON.parse(RestClientWrapper.get "https://data.enanomapper.net/query/compound/url/all?media=application/json&search=#{uri}")
+ data = JSON.parse(RestClientWrapper.get("https://data.enanomapper.net/query/compound/url/all?search=#{uri}", {}, {accept: :json}))
source = data["dataEntry"][0]["compound"]["URI"]
smiles = data["dataEntry"][0]["values"]["https://data.enanomapper.net/feature/http%3A%2F%2Fwww.opentox.org%2Fapi%2F1.1%23SMILESDefault"]
names = []
@@ -52,7 +51,7 @@ module OpenTox
nanoparticle.dataset_ids << datasets[bundle_uri].id
end
- studies = JSON.parse(RestClientWrapper.get(File.join(np["compound"]["URI"],"study")))["study"]
+ studies = JSON.parse(RestClientWrapper.get(File.join(np["compound"]["URI"],"study"), {}, {accept: :json}))["study"]
studies.each do |study|
dataset = datasets[np["bundles"].keys.first]
proteomics_features = {}
diff --git a/lib/lazar.rb b/lib/lazar.rb
index a756742..fff5598 100644
--- a/lib/lazar.rb
+++ b/lib/lazar.rb
@@ -1,6 +1,7 @@
require 'rubygems'
require "bundler/setup"
require "rest-client"
+require 'addressable'
require 'yaml'
require 'json'
require 'logger'
diff --git a/lib/model.rb b/lib/model.rb
index 475a346..ba52c84 100644
--- a/lib/model.rb
+++ b/lib/model.rb
@@ -395,6 +395,7 @@ module OpenTox
include Mongoid::Timestamps
field :endpoint, type: String
+ field :qmrf, type: Hash
field :species, type: String
field :source, type: String
field :unit, type: String
diff --git a/lib/overwrite.rb b/lib/overwrite.rb
index 91bc9e1..89e57a0 100644
--- a/lib/overwrite.rb
+++ b/lib/overwrite.rb
@@ -197,7 +197,7 @@ module URI
# @param [String]
# @return [TrueClass,FalseClass]
def self.valid? uri
- u = URI.parse(uri)
+ u = Addressable::URI.parse(uri)
u.scheme!=nil and u.host!=nil
rescue URI::InvalidURIError
false
diff --git a/lib/rest-client-wrapper.rb b/lib/rest-client-wrapper.rb
index f76a296..c9fd40f 100644
--- a/lib/rest-client-wrapper.rb
+++ b/lib/rest-client-wrapper.rb
@@ -26,6 +26,7 @@ module OpenTox
define_singleton_method method do |uri,payload={},headers={},waiting_task=nil|
+ uri = Addressable::URI.encode(uri)
# check input
bad_request_error "Headers are not a hash: #{headers.inspect} for #{uri}." unless headers==nil or headers.is_a?(Hash)
headers[:subjectid] ||= @@subjectid