diff options
author | Christoph Helma <helma@in-silico.ch> | 2016-05-12 15:23:01 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2016-05-12 15:23:01 +0200 |
commit | b8bb12c8a163c238d7d4387c1914e2100bb660df (patch) | |
tree | 791d1524e2294d8a3a38658607a644d7576784ae /lib/import.rb | |
parent | 937bfbaf058aea5973927cb3bf6b51028b312ed9 (diff) |
enm study import fixed
Diffstat (limited to 'lib/import.rb')
-rw-r--r-- | lib/import.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/import.rb b/lib/import.rb index dfe5e2d..3c6966e 100644 --- a/lib/import.rb +++ b/lib/import.rb @@ -9,16 +9,18 @@ module OpenTox #get list of bundle URIs bundles = JSON.parse(RestClientWrapper.get('https://data.enanomapper.net/bundle?media=application%2Fjson'))["dataset"] File.open(File.join(dir,"bundles.json"),"w+"){|f| f.puts JSON.pretty_generate(bundles)} - datasets = [] bundles.each do |bundle| + p bundle["title"] nanoparticles = JSON.parse(RestClientWrapper.get(bundle["dataset"]+"?media=application%2Fjson"))["dataEntry"] + p nanoparticles.size nanoparticles.each do |nanoparticle| uuid = nanoparticle["values"]["https://data.enanomapper.net/identifier/uuid"] $logger.debug uuid File.open(File.join(dir,"nanoparticle-#{uuid}.json"),"w+"){|f| f.puts JSON.pretty_generate(nanoparticle)} studies = JSON.parse(RestClientWrapper.get(File.join(nanoparticle["compound"]["URI"],"study")))["study"] + p uuid if studies.size < 1 studies.each do |study| - File.open(File.join(dir,"study-#{uuid}.json"),"w+"){|f| f.puts JSON.pretty_generate(study)} + File.open(File.join(dir,"study-#{study["uuid"]}.json"),"w+"){|f| f.puts JSON.pretty_generate(study)} end end end @@ -37,7 +39,7 @@ module OpenTox :source => np["compound"]["URI"], ) np["bundles"].keys.each do |bundle_uri| - datasets[bundle_uri].substance_ids << nanoparticle.id + #datasets[bundle_uri].substance_ids << nanoparticle.id nanoparticle["dataset_ids"] << datasets[bundle_uri].id end bundle = datasets[np["bundles"].keys.first].id if np["bundles"].size == 1 |