summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2016-10-13 14:39:04 +0200
committerChristoph Helma <helma@in-silico.ch>2016-10-13 14:39:04 +0200
commit9e99495ecbff147218023c136bade9e56a502fed (patch)
tree54ba18b16c2b20cc173dd7668416ea7e1a233b7d /lib
parentc3a7e75cb36908da36d155cad5478800e32aaf5f (diff)
descriptor tests fixed
Diffstat (limited to 'lib')
-rw-r--r--lib/compound.rb14
-rw-r--r--lib/model.rb4
-rw-r--r--lib/nanoparticle.rb2
3 files changed, 8 insertions, 12 deletions
diff --git a/lib/compound.rb b/lib/compound.rb
index 72882d0..b47364c 100644
--- a/lib/compound.rb
+++ b/lib/compound.rb
@@ -75,11 +75,7 @@ module OpenTox
fingerprints[type]
end
- def calculated_properties types=["PhysChem::OPENBABEL"]
- descriptors = []
- types.each do |t|
- descriptors += PhysChem.descriptors OpenTox.const_get(t)
- end
+ def calculate_properties descriptors=PhysChem::OPENBABEL
# TODO: speedup java descriptors
calculated_ids = properties.keys
# BSON::ObjectId instances are not allowed as keys in a BSON document.
@@ -98,7 +94,8 @@ module OpenTox
end
end
save
- properties.select{|id,v| descriptors.collect{|d| d.id.to_s}.include? id}
+ descriptors.collect{|d| properties[d.id.to_s]}
+ #properties.select{|id,v| descriptors.collect{|d| d.id.to_s}.include? id}
end
def smarts_match smarts, count=false
@@ -303,8 +300,9 @@ module OpenTox
# Calculate molecular weight of Compound with OB and store it in object
# @return [Float] molecular weight
def molecular_weight
- mw_feature = PhysChem.find_or_create_by(:name => "Openbabel.MW")
- calculated_properties[mw_feature.id.to_s]
+ mw_feature = PhysChem.find_or_create_by(:name => "Openbabel.MW").id.to_s
+ calculate_properties unless properties[mw_feature]
+ properties[mw_feature]
end
private
diff --git a/lib/model.rb b/lib/model.rb
index 859df8b..7029c31 100644
--- a/lib/model.rb
+++ b/lib/model.rb
@@ -131,7 +131,7 @@ module OpenTox
end
else
# parse independent_variables
- if (model.algorithms[:descriptors] & ["PhysChem::OPENBABEL","PhysChem::CDK","PhysChem::JOELIB"]).empty?
+ if (model.algorithms[:descriptors] & [PhysChem::OPENBABEL,PhysChem::CDK,PhysChem::JOELIB]).empty?
properties = model.substances.collect { |s| s.properties }
all_property_ids = properties.collect{|p| p.keys}.flatten.uniq
model.descriptor_ids = all_property_ids.select{|id| model.algorithms[:descriptors].include? Feature.find(id).category }
@@ -139,7 +139,7 @@ module OpenTox
# calculate physchem properties
else
- properties = model.substances.collect { |s| s.calculated_properties(model.algorithms[:descriptors]) }
+ properties = model.substances.collect { |s| s.calculate_properties(model.algorithms[:descriptors]) }
model.descriptor_ids = properties.collect{|p| p.keys}.flatten.uniq
model.independent_variables = model.descriptor_ids.collect{|i| properties.collect{|p| p[i]}}
end
diff --git a/lib/nanoparticle.rb b/lib/nanoparticle.rb
index f74f263..23e155c 100644
--- a/lib/nanoparticle.rb
+++ b/lib/nanoparticle.rb
@@ -6,8 +6,6 @@ module OpenTox
field :core, type: Hash, default: {}
field :coating, type: Array, default: []
- attr_accessor :scaled_values
-
def add_feature feature, value, dataset
unless feature.name == "ATOMIC COMPOSITION" or feature.name == "FUNCTIONAL GROUP" # redundand
case feature.category