sdf export fixed
authorhelma@in-silico.ch <helma@in-silico.ch>
Tue, 6 Nov 2018 18:01:58 +0000 (19:01 +0100)
committerhelma@in-silico.ch <helma@in-silico.ch>
Tue, 6 Nov 2018 18:01:58 +0000 (19:01 +0100)
lib/dataset.rb
lib/model.rb

index 42733e4..b09d7bf 100644 (file)
@@ -199,7 +199,6 @@ module OpenTox
         end
         dataset.parse_table table
       end
-      dataset.save
       dataset
     end
 
@@ -290,7 +289,7 @@ module OpenTox
 
       all_substances = []
       table.each_with_index do |vals,i|
-        original_id.name.match(/LineID$/) ? original_id_value = i+1 : original_id_value = vals.shift.strip
+        original_id.name.match(/LineID$/) ? original_id_value = i+1 : original_id_value = vals.shift.to_s.strip
         identifier = vals.shift.strip
         begin
           case compound_format
@@ -368,13 +367,17 @@ module OpenTox
     # @return [String] SDF string
     def to_sdf
       sdf = ""
-      substances.each do |substance|
-        sdf_lines = substance.sdf.sub(/\$\$\$\$\n/,"").split("\n")
-        sdf_lines[0] = substance.smiles
+      compounds.each do |compound|
+        sdf_lines = compound.sdf.sub(/\$\$\$\$\n/,"").split("\n")
+        sdf_lines[0] = compound.smiles
         sdf += sdf_lines.join("\n")
-        features.each do |f|
-          sdf += "\n> <#{f.name}>\n"
-          sdf += values(substance,f).uniq.join ","
+        bioactivity_features.each do |f|
+          v = values(compound,f)
+          unless v.empty?
+            sdf += "\n> <#{f.name}>\n"
+            sdf += v.uniq.join ","
+            sdf += "\n"
+          end
         end
         sdf += "\n$$$$\n"
       end
index a0c60f0..966460b 100644 (file)
@@ -481,13 +481,13 @@ module OpenTox
       end
 
       # TODO from_pubchem_aid
-      def self.from_dataset training_dataset: , prediction_feature: , species: , endpoint: 
+      def self.from_dataset training_dataset: , prediction_feature: , species: , endpoint: , folds: 10, repeats: 5
         model_validation = Model::Validation.create species: species, endpoint: endpoint
-        p "create model"
+        #p "create model"
         model = Lazar.create training_dataset: training_dataset, prediction_feature: prediction_feature
         model_validation[:model_id] = model.id
-        p "create_crossvalidations"
-        model_validation[:repeated_crossvalidation_id] = OpenTox::Validation::RepeatedCrossValidation.create(model).id # full class name required
+        #p "create_crossvalidations"
+        model_validation[:repeated_crossvalidation_id] = OpenTox::Validation::RepeatedCrossValidation.create(model,folds,repeats).id # full class name required
         model_validation.save
         model_validation
       end