summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2016-04-08 13:04:56 +0200
committerChristoph Helma <helma@in-silico.ch>2016-04-08 13:04:56 +0200
commitf3780d7507092b643216054fa3ca1e6146281e43 (patch)
tree23df1009e9c66b1d896cd30499451a511abdda4f /data
parentb85e6d6b503b40d9448ff6857523271558780434 (diff)
enm import test
Diffstat (limited to 'data')
-rw-r--r--data/enm-import.rb25
1 files changed, 11 insertions, 14 deletions
diff --git a/data/enm-import.rb b/data/enm-import.rb
index 65fd3c7..37bc22b 100644
--- a/data/enm-import.rb
+++ b/data/enm-import.rb
@@ -1,6 +1,7 @@
require_relative '../lib/lazar.rb'
include OpenTox
-
+$mongo.database.drop
+$gridfs = $mongo.database.fs
#get list of bundle URIs
bundles = JSON.parse(RestClientWrapper.get('https://data.enanomapper.net/bundle?media=application%2Fjson'))["dataset"]
@@ -13,38 +14,34 @@ bundles.each do |bundle|
:name => np["values"]["https://data.enanomapper.net/identifier/name"],
:source => np["compound"]["URI"],
)
+ nanoparticle.bundles << uri
+ nanoparticle.bundles.uniq!
np["composition"].each do |comp|
case comp["relation"]
when "HAS_CORE"
- nanoparticle[:core] = comp["component"]["compound"]["URI"]
+ nanoparticle.core = comp["component"]["compound"]["URI"]
when "HAS_COATING"
- nanoparticle[:coating] ||= []
- nanoparticle[:coating] << comp["component"]["compound"]["URI"]
+ nanoparticle.coating << comp["component"]["compound"]["URI"]
end
end if np["composition"]
np["values"].each do |u,v|
if u.match(/property/)
- name, unit = nil
+ name, unit, source = nil
features.each do |uri,feat|
if u.match(/#{uri}/)
name = feat["title"]
unit = feat["units"]
+ source = uri
end
end
feature = Feature.find_or_create_by(
:name => name,
:unit => unit,
- #:source => uri
+ :source => source
)
- nanoparticle[:features] ||= {}
- if v.size == 1 and v.first.keys == ["loValue"]
- nanoparticle[:features][feature.id] = v.first["loValue"]
- else
- #TODO
- end
end
+ v.each{|value| nanoparticle.parse_ambit_value feature, value} if v.is_a? Array
end
- p nanoparticle
- nanoparticle.save
+ nanoparticle.save!
end
end