summaryrefslogtreecommitdiff
path: root/lib/compound.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2015-11-04 17:50:32 +0100
committerChristoph Helma <helma@in-silico.ch>2015-11-04 17:50:32 +0100
commitc23f4b8a915c0df4f34b6c3787829e1f513df571 (patch)
tree298faed0b20077615357a6bc0a4b6d7e61bd8a16 /lib/compound.rb
parentca2bb0f90335b1f2c4ecc28ee423e85b281ffcf0 (diff)
parent2081bda2b72f34758847fe699fecf890dae1e3df (diff)
Merge branch 'development' of github.com:opentox/lazar into development
Diffstat (limited to 'lib/compound.rb')
-rw-r--r--lib/compound.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/compound.rb b/lib/compound.rb
index c5e7f02..ad0eaba 100644
--- a/lib/compound.rb
+++ b/lib/compound.rb
@@ -21,6 +21,7 @@ module OpenTox
field :png_id, type: BSON::ObjectId
field :svg_id, type: BSON::ObjectId
field :sdf_id, type: BSON::ObjectId
+ field :molecular_weight, type: Float
field :fingerprints, type: Hash, default: {}
field :default_fingerprint_size, type: Integer
field :dataset_ids, type: Array, default: []
@@ -335,6 +336,37 @@ module OpenTox
#$mongo["compounds"].aggregate(aggregate).collect{ |r| [r["_id"], r["tanimoto"]] }
end
+
+ # Get mg from logmmol (for nch LOAEL/pTD50 data)
+ # @return [Float] value in mg
+ def logmmol_to_mg(value, mw)
+ mg = (10**(-1.0*value.to_f)*(mw.to_f*1000))
+ return mg
+ end
+
+ # 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)
+ mg = 10**value.to_f
+ return mg
+ end
+
+ # Calculate molecular weight of Compound with OB and store it in object
+ # @return [Float] molecular weight
+ def molecular_weight
+ 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"]
+ end
+
private