summaryrefslogtreecommitdiff
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
parent2176251f76703cc9953a408938e846de026b3d4c (diff)
modena import workarounds
-rw-r--r--lib/import.rb28
-rw-r--r--lib/nanoparticle.rb6
2 files changed, 29 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
-
diff --git a/lib/nanoparticle.rb b/lib/nanoparticle.rb
index 02d9a89..06db4d2 100644
--- a/lib/nanoparticle.rb
+++ b/lib/nanoparticle.rb
@@ -40,6 +40,12 @@ module OpenTox
properties[feature.id.to_s] << value
properties[feature.id.to_s].uniq!
when "TOX"
+ if feature.name.match("Cell Viability Assay") and !feature.name.match("SLOPE") # -log10 transformation
+ value = -Math.log10(value)
+ feature.unit = "-log10(#{feature.unit})" unless feature.unit.match "log10"
+ feature.warnings += ["-log10 transformed values"] unless feature.warnings.include? "-log10 transformed values"
+ feature.save
+ end
dataset.add self, feature, value
else
warn "Unknown feature type '#{feature.category}'. Value '#{value}' not inserted."