From 05386e748270c337c66f6f379317ea4b25905236 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 4 May 2016 19:24:42 +0200 Subject: first reasonable results for nanoparticle crossvalidation --- lib/nanoparticle.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'lib/nanoparticle.rb') diff --git a/lib/nanoparticle.rb b/lib/nanoparticle.rb index 83b97a9..dda4a9f 100644 --- a/lib/nanoparticle.rb +++ b/lib/nanoparticle.rb @@ -8,7 +8,7 @@ module OpenTox field :bundles, type: Array, default: [] def nanoparticle_neighbors params - Dataset.find(params[:training_dataset_id]).nanoparticles.collect{|np| {"_id" => np.id, "tanimoto" => 1}} + Dataset.find(params[:training_dataset_id]).nanoparticles.collect{|np| np["tanimoto"] = 1; np} end def add_feature feature, value @@ -19,7 +19,19 @@ module OpenTox physchem_descriptors[feature.id.to_s].uniq! when "TOX" toxicities[feature.id.to_s] ||= [] - toxicities[feature.id.to_s] << value + # TODO generic way of parsing TOX values + if feature.name == "7.99 Toxicity (other) ICP-AES" and feature.unit == "mL/ug(Mg)" + toxicities[feature.id.to_s] << -Math.log10(value) + #if value.numeric? + #begin + #rescue + #p feature + #p value + #exit + #end + else + toxicities[feature.id.to_s] << value + end toxicities[feature.id.to_s].uniq! else warn "Unknown feature type '#{feature.category}'. Value '#{value}' not inserted." @@ -29,7 +41,7 @@ module OpenTox def parse_ambit_value feature, v v.delete "unit" - # TODO: mmol/log10 conversion + # TODO: ppm instead of weights if v.keys == ["textValue"] add_feature feature, v["textValue"] elsif v.keys == ["loValue"] -- cgit v1.2.3