diff options
author | Christoph Helma <helma@in-silico.ch> | 2016-04-08 13:04:56 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2016-04-08 13:04:56 +0200 |
commit | f3780d7507092b643216054fa3ca1e6146281e43 (patch) | |
tree | 23df1009e9c66b1d896cd30499451a511abdda4f /lib | |
parent | b85e6d6b503b40d9448ff6857523271558780434 (diff) |
enm import test
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compound.rb | 1 | ||||
-rw-r--r-- | lib/lazar.rb | 1 | ||||
-rw-r--r-- | lib/nanoparticle.rb | 45 |
3 files changed, 42 insertions, 5 deletions
diff --git a/lib/compound.rb b/lib/compound.rb index 2a79fd6..a7518ed 100644 --- a/lib/compound.rb +++ b/lib/compound.rb @@ -21,6 +21,7 @@ module OpenTox field :default_fingerprint_size, type: Integer field :physchem_descriptors, type: Hash, default: {} field :dataset_ids, type: Array, default: [] + # TODO separate between physchem, bio and tox field :features, type: Hash, default: {} index({smiles: 1}, {unique: true}) diff --git a/lib/lazar.rb b/lib/lazar.rb index 39dd8fa..0e2cec2 100644 --- a/lib/lazar.rb +++ b/lib/lazar.rb @@ -81,5 +81,6 @@ CLASSES = ["Feature","Compound","Dataset","Validation","CrossValidation","LeaveO "crossvalidation.rb", "leave-one-out-validation.rb", "experiment.rb", + "import.rb", ].each{ |f| require_relative f } OpenTox::PhysChem.descriptors # load descriptor features 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 |