From 9e8537997d84e78e6545a66a0d09c33e76c8b7cf Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Fri, 30 Sep 2016 17:11:30 +0200 Subject: npo uri as source, spectral count unit f proteomics features --- lib/import.rb | 31 +++++++++++++++++++++++++------ lib/nanoparticle.rb | 18 ++++-------------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/lib/import.rb b/lib/import.rb index e187e3c..17894a9 100644 --- a/lib/import.rb +++ b/lib/import.rb @@ -62,24 +62,43 @@ module OpenTox np["bundles"].keys.each do |bundle_uri| nanoparticle.dataset_ids << datasets[bundle_uri].id end + dataset = datasets[np["bundles"].keys.first] proteomics_features = {} + category = study["protocol"]["topcategory"] + source = study["protocol"]["category"]["term"] + study["effects"].each do |effect| + effect["result"]["textValue"] ? klass = NominalFeature : klass = NumericFeature effect["conditions"].delete_if { |k, v| v.nil? } + if study["protocol"]["category"]["title"].match(/Proteomics/) and effect["result"]["textValue"] and effect["result"]["textValue"].length > 50 # parse proteomics data + JSON.parse(effect["result"]["textValue"]).each do |identifier, value| # time critical step - proteomics_features[identifier] ||= NumericFeature.find_or_create_by(:name => identifier, :category => "Proteomics") + proteomics_features[identifier] ||= NumericFeature.find_or_create_by(:name => identifier, :category => "Proteomics", :unit => "Spectral counts", :source => source) nanoparticle.parse_ambit_value proteomics_features[identifier], value, dataset end else name = effect["endpoint"] - name = "log2(Net cell association)" if name == "Log2 transformed" # use a sensible name + unit = effect["result"]["unit"] + warnings = [] + case name + when "Log2 transformed" # use a sensible name + name = "log2(Net cell association)" + warnings = ["Original name was 'Log2 transformed'"] + unit = "log2(mL/ug(Mg))" + when "Total protein (BCA assay)" + category = "P-CHEM" + warnings = ["Category changed from TOX to P-CHEM"] + end feature = klass.find_or_create_by( - :name => effect["endpoint"], - :unit => effect["result"]["unit"], - :category => study["protocol"]["topcategory"], - :conditions => effect["conditions"] + :name => name, + :unit => unit, + :category => category, + :conditions => effect["conditions"], + :source => study["protocol"]["category"]["term"], + :warnings => warnings ) nanoparticle.parse_ambit_value feature, effect["result"], dataset end diff --git a/lib/nanoparticle.rb b/lib/nanoparticle.rb index d6261ee..b1a3835 100644 --- a/lib/nanoparticle.rb +++ b/lib/nanoparticle.rb @@ -5,7 +5,7 @@ module OpenTox field :core, type: Hash, default: {} field :coating, type: Array, default: [] - field :proteomics, type: Hash, default: {} + #field :proteomics, type: Hash, default: {} attr_accessor :scaled_values @@ -63,26 +63,16 @@ module OpenTox physchem_descriptors[feature.id.to_s] << value physchem_descriptors[feature.id.to_s].uniq! when "Proteomics" - #proteomics[feature.id.to_s] ||= [] - #proteomics[feature.id.to_s] << value - #proteomics[feature.id.to_s].uniq! physchem_descriptors[feature.id.to_s] ||= [] physchem_descriptors[feature.id.to_s] << value physchem_descriptors[feature.id.to_s].uniq! when "TOX" - if feature.name == "Total protein (BCA assay)" - physchem_descriptors[feature.id.to_s] ||= [] - physchem_descriptors[feature.id.to_s] << value - physchem_descriptors[feature.id.to_s].uniq! - else - dataset.add self, feature, value - end - dataset.save - dataset_ids << dataset.id - dataset_ids.uniq! + dataset.add self, feature, value else warn "Unknown feature type '#{feature.category}'. Value '#{value}' not inserted." end + dataset_ids << dataset.id + dataset_ids.uniq! end end -- cgit v1.2.3