summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavor <vorgrimmlerdavid@gmx.de>2012-05-03 10:32:59 +0200
committerdavor <vorgrimmlerdavid@gmx.de>2012-05-03 10:32:59 +0200
commit3bdbc9b22518da6059859684b179fea55ee185f1 (patch)
tree0147bc498bfbf8c270bb4f7bc170c2030458872f
parentff53b7b3bf1ffe3447d107870eedbbd00ad71eef (diff)
Added chem. name / value transformation to report.nestle
If mol or mg is given in the feature name the values(actual and predicted) will be transformed.
-rwxr-xr-xlib/ot_predictions.rb81
-rwxr-xr-xreport/report_content.rb2
-rwxr-xr-xreport/report_factory.rb2
3 files changed, 77 insertions, 8 deletions
diff --git a/lib/ot_predictions.rb b/lib/ot_predictions.rb
index 2752fcc..805ffe0 100755
--- a/lib/ot_predictions.rb
+++ b/lib/ot_predictions.rb
@@ -19,7 +19,11 @@ module Lib
def compound(instance_index)
@compounds[instance_index]
end
-
+
+ def compounds()
+ @compounds
+ end
+
def compute_stats()
res = {}
case feature_type
@@ -36,7 +40,7 @@ module Lib
end
def self.to_array( predictions, add_pic=false, format=false, validation_uris=nil )
-
+
confidence_available = false
predictions.each do |p|
confidence_available |= p.confidence_values_available?
@@ -44,12 +48,34 @@ module Lib
res = []
conf_column = nil
count = 0
+
predictions.each do |p|
v_uris = validation_uris[count] if validation_uris
count += 1
+ cmpds_mw = {}
+ ds = OpenTox::Dataset.new()
+ ds.save
+
+ # Get MW of compounds
+ p.compounds.each do |c_uri|
+ ds.add_compound(c_uri)
+ ds.save
+ end
+ mw_algorithm_uri = File.join(CONFIG[:services]["opentox-algorithm"],"pc/MW")
+ mw_uri = OpenTox::RestClientWrapper.post(mw_algorithm_uri, {:dataset_uri=>ds.uri})
+ mw_ds = OpenTox::Dataset.find(mw_uri)
+ p.compounds.each do |c_uri|
+ cmpds_mw[c_uri] = mw_ds.data_entries[c_uri][mw_uri.to_s + "/feature/MW"].first
+ end
+ mw_ds.delete
+ ds.delete
+
+ # Get prediction feature
+ val = OpenTox::Validation.find(v_uris.first)
+ p_feature = val.metadata[OT::predictionFeature].to_s.split("/").last
+
(0..p.num_instances-1).each do |i|
a = []
-
#PENDING!
begin
#a.push( "http://ambit.uni-plovdiv.bg:8080/ambit2/depict/cdk?search="+
@@ -60,9 +86,44 @@ module Lib
#a.push("Could not add pic: "+ex.message)
#a.push(p.identifier(i))
end
-
- a << (format ? p.actual_value(i).to_nice_s : p.actual_value(i))
- a << (format ? p.predicted_value(i).to_nice_s : p.predicted_value(i))
+
+ if cmpds_mw[p.identifier(i)].nil? || (p.feature_type=="classification")
+ a << (format ? p.actual_value(i).to_nice_s : p.actual_value(i))
+ a << (format ? p.predicted_value(i).to_nice_s : p.predicted_value(i))
+ else # Converting values to mg values if found in prediction feature name
+ if p.actual_value(i).nil?
+ a << (format ? p.actual_value(i).to_nice_s : p.actual_value(i))
+ else
+ if p_feature.downcase.include? "ptd50"
+ td50 = (((10**(-1.0*p.actual_value(i)))*(cmpds_mw[p.identifier(i)].to_f*1000))*1000).round / 1000.0
+ a << (format ? "pTD50: " + p.actual_value(i).to_nice_s + "\n[TD50: " + td50.to_s.chomp + "]" : p.actual_value(i))
+ elsif p_feature.downcase.include? "mol"
+ mg = (((10**(-1.0*p.actual_value(i)))*(cmpds_mw[p.identifier(i)].to_f*1000))*1000).round / 1000.0
+ a << (format ? "log mol/kg bw/day: " + p.actual_value(i).to_nice_s + "\n[mg/kg bw/day: " + mg.to_s.chomp + "]": p.actual_value(i))
+ elsif p_feature.downcase.include? "mg"
+ mg = ((10**p.actual_value(i))*1000).round / 1000.0
+ a << (format ? "log mg/kg bw/day: " + p.actual_value(i).to_nice_s + "\n[mg/kg bw/day: " + mg.to_s.chomp + "]": p.actual_value(i))
+ else
+ a << (format ? p.actual_value(i).to_nice_s : p.actual_value(i))
+ end
+ end
+ if p.predicted_value(i).nil?
+ a << (format ? p.predicted_value(i).to_nice_s : p.predicted_value(i))
+ else
+ if p_feature.downcase.include? "ptd50"
+ td50 = (((10**(-1.0*p.predicted_value(i)))*(cmpds_mw[p.identifier(i)].to_f*1000))*1000).round / 1000.0
+ a << (format ? "pTD50: " + p.predicted_value(i).to_nice_s + "\n[TD50: " + td50.to_s.chomp + "]": p.predicted_value(i))
+ elsif p_feature.downcase.include? "mol"
+ mg = (((10**(-1.0*p.predicted_value(i)))*(cmpds_mw[p.identifier(i)].to_f*1000))*1000).round / 1000.0
+ a << (format ? "log mol/kg bw/day: " + p.predicted_value(i).to_nice_s + "\n[mg/kg bw/day: " + mg.to_s.chomp + "]": p.predicted_value(i))
+ elsif p_feature.downcase.include? "mg"
+ mg = ((10**p.predicted_value(i))*1000).round / 1000.0
+ a << (format ? "log mg/kg bw/day: " + p.predicted_value(i).to_nice_s + "\n[mg/kg bw/day: " + mg.to_s.chomp + "]": p.predicted_value(i))
+ else
+ a << (format ? p.predicted_value(i).to_nice_s : p.predicted_value(i))
+ end
+ end
+ end
if p.feature_type=="classification"
if (p.predicted_value(i)!=nil and p.actual_value(i)!=nil)
if p.classification_miss?(i)
@@ -82,6 +143,12 @@ module Lib
a << v_uris[i]
end
a << p.identifier(i)
+ # Get chemical names and add pubchem_iupac_name
+ c = OpenTox::Compound.new(p.identifier(i))
+ c_names = c.to_names_hash
+ a << c_names["pubchem_iupac_name"]
+ a << cmpds_mw[p.identifier(i)]
+
res << a
end
end
@@ -103,6 +170,8 @@ module Lib
header << "Confidence value" if predictions[0].confidence_values_available?
header << "Validation URI" if validation_uris
header << "Compound URI"
+ header << "Chemical name (pubchem_iupac_name)"
+ header << "Molecular weight (openbabel)"
res.insert(0, header)
return res
diff --git a/report/report_content.rb b/report/report_content.rb
index 033b367..0d2c7ec 100755
--- a/report/report_content.rb
+++ b/report/report_content.rb
@@ -412,4 +412,4 @@ class Reports::ReportContent
@tmp_files.delete(tmp_file_name) if @tmp_files.has_key?(tmp_file_name)
end
-end \ No newline at end of file
+end
diff --git a/report/report_factory.rb b/report/report_factory.rb
index f73ffd9..c9cab86 100755
--- a/report/report_factory.rb
+++ b/report/report_factory.rb
@@ -124,7 +124,7 @@ module Reports::ReportFactory
report.end_section
report.add_result(validation_set, Validation::ALL_PROPS, "All Results", "All Results")
- report.add_predictions( validation_set, false )
+ report.add_predictions( validation_set, true )
task.progress(100) if task
report
end