summaryrefslogtreecommitdiff
path: root/lib/import.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2016-09-30 17:11:30 +0200
committerChristoph Helma <helma@in-silico.ch>2016-09-30 17:11:30 +0200
commit9e8537997d84e78e6545a66a0d09c33e76c8b7cf (patch)
tree3fda7a94d4bea42e60340074e5bd8633ed136907 /lib/import.rb
parent2c54492126a501bd67ad59ef34792d0676396805 (diff)
npo uri as source, spectral count unit f proteomics features
Diffstat (limited to 'lib/import.rb')
-rw-r--r--lib/import.rb31
1 files changed, 25 insertions, 6 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