summaryrefslogtreecommitdiff
path: root/lib/import.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2016-12-12 12:46:24 +0100
committerChristoph Helma <helma@in-silico.ch>2016-12-12 12:46:24 +0100
commit8e4cd2f6654de5b88cdad91eb0c5050be13222f1 (patch)
treedf52e4730b9cc60f7e94e15cf6337543e437f93d /lib/import.rb
parent2176251f76703cc9953a408938e846de026b3d4c (diff)
modena import workarounds
Diffstat (limited to 'lib/import.rb')
-rw-r--r--lib/import.rb28
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/import.rb b/lib/import.rb
index aa2ee75..38970e5 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"
@@ -78,6 +78,24 @@ module OpenTox
category = "P-CHEM"
warnings = ["Category changed from TOX to P-CHEM"]
end
+ if bundle["title"].match /MODENA/ # fix MODENA endpoint names
+ case study["protocol"]["category"]["term"]
+ when /BAO_0003009/
+ warnings = ["Original name was '#{name}'"]
+ name = "Cell Viability Assay " + name
+ unless name.match(/SLOPE/)
+ end
+ when /BAO_0010001/
+ warnings = ["Original name was '#{name}'"]
+ name = "ATP Assay " + name
+ when /NPO_1709/
+ warnings = ["Original name was '#{name}'"]
+ name = "LDH Release Assay " + name
+ when /NPO_1911/
+ warnings = ["Original name was '#{name}'"]
+ name = "MTT Assay " + name
+ end
+ end
feature = klass.find_or_create_by(
:name => name,
:unit => unit,
@@ -94,6 +112,7 @@ module OpenTox
nanoparticle.save
print "#{n}, "
end
+ puts
end
datasets.each { |u,d| d.save }
end
@@ -119,4 +138,3 @@ module OpenTox
end
end
-