summaryrefslogtreecommitdiff
path: root/lib/nanoparticle.rb
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 /lib/nanoparticle.rb
parentb85e6d6b503b40d9448ff6857523271558780434 (diff)
enm import test
Diffstat (limited to 'lib/nanoparticle.rb')
-rw-r--r--lib/nanoparticle.rb45
1 files changed, 40 insertions, 5 deletions
diff --git a/lib/nanoparticle.rb b/lib/nanoparticle.rb
index 3783ece..cda431a 100644
--- a/lib/nanoparticle.rb
+++ b/lib/nanoparticle.rb
@@ -3,13 +3,48 @@ module OpenTox
class Nanoparticle
include OpenTox
- field :particle_id, type: String
+ #field :particle_id, type: String
field :core, type: String
- field :coatings, type: Array
+ field :coating, type: Array, default: []
- #field :physchem_descriptors, type: Hash, default: {}
- #field :toxicities, type: Hash, default: {}
- field :features, type: Hash, default: {}
+ field :physchem_descriptors, type: Hash, default: {}
+ field :toxicities, type: Hash, default: {}
+ #field :features, type: Hash, default: {}
+ field :bundles, type: Array, default: []
+
+ def predict
+ end
+
+ def add_feature feature, value
+ if feature.source.match /property\/P-CHEM/
+ physchem_descriptors[feature.id.to_s] ||= []
+ physchem_descriptors[feature.id.to_s] << value
+ elsif feature.source.match /property\/TOX/
+ toxicities[feature.id.to_s] ||= []
+ toxicities[feature.id.to_s] << value
+ else
+ $logger.warn "Unknown feature type '#{feature.source}'. Value '#{value}' not inserted."
+ warnings << "Unknown feature type '#{feature.source}'. Value '#{value}' not inserted."
+ end
+ end
+
+ def parse_ambit_value feature, v
+ if v.keys == ["loValue"]
+ add_feature feature, v["loValue"]
+ elsif v.keys.size == 2 and v["loQualifier"] == "mean"
+ add_feature feature, {:mean => v["loValue"]}
+ elsif v.keys.size == 2 and v["loQualifier"] #== ">="
+ add_feature feature, {:min => v["loValue"],:max => Float::INFINITY}
+ elsif v.keys.size == 2 and v["upQualifier"] #== ">="
+ add_feature feature, {:max => v["upValue"],:min => -Float::INFINITY}
+ elsif v.size == 4 and v["loQualifier"] and v["upQualifier"]
+ add_feature feature, {:min => v["loValue"],:max => v["upValue"]}
+ elsif v == {} # do nothing
+ else
+ $logger.warn "Cannot parse Ambit eNanoMapper value '#{v}' for feature '#{feature.name}'."
+ warnings << "Cannot parse Ambit eNanoMapper value '#{v}' for feature '#{feature.name}'."
+ end
+ end
end
end