summaryrefslogtreecommitdiff
path: root/lib/compound.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2015-11-09 14:58:34 +0100
committerChristoph Helma <helma@in-silico.ch>2015-11-09 14:58:34 +0100
commite63e97086ac05e7a86f1a53bdcbc72eec0cabf16 (patch)
treea6277bdf8db1d36d9ed5550c518e6a384f98cb48 /lib/compound.rb
parent3e8dfcbbb189996ed119b7628ec39a4e6758b088 (diff)
leave one out validation implemented
Diffstat (limited to 'lib/compound.rb')
-rw-r--r--lib/compound.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/compound.rb b/lib/compound.rb
index ad0eaba..d5a4cbb 100644
--- a/lib/compound.rb
+++ b/lib/compound.rb
@@ -344,16 +344,20 @@ module OpenTox
return mg
end
- # Get mg from mmol
- # @return [Float] value in mg
- def mmol_to_mg(value, mw)
+ # Get mg from mmol
+ # @return [Float] value in mg
+ def mmol_to_mg(value, mw)
mg = (value.to_f)*(mw.to_f)
return mg
end
- # Get mg from logmg
- # @return [Float] value in mg
- def logmg_to_mg(value)
+ def mg_to_mmol mg
+ mg.to_f/molecular_weight
+ end
+
+ # Get mg from logmg
+ # @return [Float] value in mg
+ def logmg_to_mg(value)
mg = 10**value.to_f
return mg
end
@@ -364,7 +368,7 @@ module OpenTox
if self["molecular_weight"]==0.0 || self["molecular_weight"].nil?
update(:molecular_weight => OpenTox::Algorithm::Descriptor.physchem(self, ["Openbabel.MW"]).first)
end
- self["molecular_weight"]
+ self["molecular_weight"].to_f
end