summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2016-10-13 10:11:09 +0200
committerChristoph Helma <helma@in-silico.ch>2016-10-13 10:11:09 +0200
commit8d325866dd7cacdd04bd2306a9144a5e7300c7c8 (patch)
tree5e730f20a26e58e41cdff9c22bd5647c886ca834 /lib
parent1810b12e7faf2f0677482a3c7a8c23e0e11b8d29 (diff)
molecular_weight fixed
Diffstat (limited to 'lib')
-rw-r--r--lib/compound.rb5
-rw-r--r--lib/model.rb4
-rw-r--r--lib/regression.rb1
3 files changed, 5 insertions, 5 deletions
diff --git a/lib/compound.rb b/lib/compound.rb
index 0f178ce..ca9d5e3 100644
--- a/lib/compound.rb
+++ b/lib/compound.rb
@@ -75,9 +75,10 @@ module OpenTox
fingerprints[type]
end
- def calculated_properties types=["OPENBABEL"]
+ def calculated_properties types=["PhysChem::OPENBABEL"]
descriptors = []
types.each do |t|
+ p t
descriptors += PhysChem.descriptors OpenTox.const_get(t)
end
# TODO: speedup java descriptors
@@ -304,7 +305,7 @@ module OpenTox
# @return [Float] molecular weight
def molecular_weight
mw_feature = PhysChem.find_or_create_by(:name => "Openbabel.MW")
- calculated_physchem([mw_feature])[mw_feature.id.to_s]
+ calculated_properties[mw_feature.id.to_s]
end
private
diff --git a/lib/model.rb b/lib/model.rb
index f3f0603..859df8b 100644
--- a/lib/model.rb
+++ b/lib/model.rb
@@ -126,7 +126,8 @@ module OpenTox
end
model.descriptor_ids = model.fingerprints.flatten.uniq
model.descriptor_ids.each do |d|
- model.independent_variables << model.substance_ids.collect_with_index{|s,i| model.fingerprints[i].include? d}
+ # resulting model may break BSON size limit (e.g. f Kazius dataset
+ model.independent_variables << model.substance_ids.collect_with_index{|s,i| model.fingerprints[i].include? d} if model.algorithms[:prediction][:method].match /Caret/
end
else
# parse independent_variables
@@ -225,7 +226,6 @@ module OpenTox
else
# call prediction algorithm
result = Algorithm.run algorithms[:prediction][:method], dependent_variables:neighbor_dependent_variables,independent_variables:neighbor_independent_variables ,weights:neighbor_similarities, query_variables:query_descriptors
- p result
prediction.merge! result
prediction[:neighbors] = neighbor_ids.collect_with_index{|id,i| {:id => id, :measurement => neighbor_dependent_variables[i], :similarity => neighbor_similarities[i]}}
end
diff --git a/lib/regression.rb b/lib/regression.rb
index bed6df8..d1724fd 100644
--- a/lib/regression.rb
+++ b/lib/regression.rb
@@ -4,7 +4,6 @@ module OpenTox
class Regression
def self.weighted_average dependent_variables:, independent_variables:nil, weights:, query_variables:
- #def self.weighted_average descriptors:nil, neighbors:, parameters:nil, method:nil, relevant_features:nil
# TODO: prediction_interval
weighted_sum = 0.0
sim_sum = 0.0