diff options
author | gebele <gebele@in-silico.ch> | 2016-12-20 16:26:09 +0000 |
---|---|---|
committer | gebele <gebele@in-silico.ch> | 2016-12-20 16:26:09 +0000 |
commit | 76912e72cf52c2a10423226ababb2b6d7f4b84ca (patch) | |
tree | e167ec15c9b9434c027a341db50a3e7ea4955c34 /lib/import.rb | |
parent | da086fad5b45c0d7b59feb40d0108ac620613933 (diff) | |
parent | a5abdd27b8c9b3f1cf65a567bfd9eb17ecc91a72 (diff) |
Merge branch 'development'1.0.0
Diffstat (limited to 'lib/import.rb')
-rw-r--r-- | lib/import.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/import.rb b/lib/import.rb index aa2ee75..7a68335 100644 --- a/lib/import.rb +++ b/lib/import.rb @@ -6,12 +6,12 @@ module OpenTox include OpenTox # time critical step: JSON parsing (>99%), Oj brings only minor speed gains (~1%) - def self.import dir="." + def self.import datasets = {} bundles = JSON.parse(RestClientWrapper.get('https://data.enanomapper.net/bundle?media=application%2Fjson'))["dataset"] bundles.each do |bundle| - datasets[bundle["URI"]] = Dataset.find_or_create_by(:source => bundle["URI"],:name => bundle["title"]) - $logger.debug bundle["title"] + 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.each_with_index do |np,n| core_id = nil @@ -29,7 +29,7 @@ module OpenTox compound.name = names.first compound.names = names.compact else - compound = Compound.find_or_create_by(:name => names.first,:names => names) + compound = Compound.find_or_create_by(:name => names.first,:names => names.compact) end compound.save if c["relation"] == "HAS_CORE" @@ -94,6 +94,7 @@ module OpenTox nanoparticle.save print "#{n}, " end + puts end datasets.each { |u,d| d.save } end @@ -119,4 +120,3 @@ module OpenTox end end - |