summaryrefslogtreecommitdiff
path: root/lib/import.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/import.rb')
-rw-r--r--lib/import.rb10
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
-