From 611bac891177f8d9185d45486dd574b6ef4d1912 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 9 May 2016 15:11:46 +0200 Subject: nanoparticle models fixed --- data/enm-import.rb | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 data/enm-import.rb (limited to 'data/enm-import.rb') diff --git a/data/enm-import.rb b/data/enm-import.rb deleted file mode 100644 index 37bc22b..0000000 --- a/data/enm-import.rb +++ /dev/null @@ -1,47 +0,0 @@ -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"] -bundles.each do |bundle| - uri = bundle["URI"] - nanoparticles = JSON.parse(RestClientWrapper.get(bundle["dataset"]+"?media=application%2Fjson"))["dataEntry"] - features = JSON.parse(RestClientWrapper.get(bundle["property"]+"?media=application%2Fjson"))["feature"] - nanoparticles.each do |np| - nanoparticle = Nanoparticle.find_or_create_by( - :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"] - when "HAS_COATING" - nanoparticle.coating << comp["component"]["compound"]["URI"] - end - end if np["composition"] - np["values"].each do |u,v| - if u.match(/property/) - 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 => source - ) - end - v.each{|value| nanoparticle.parse_ambit_value feature, value} if v.is_a? Array - end - nanoparticle.save! - end -end -- cgit v1.2.3