summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2015-08-01 18:03:09 +0200
committerChristoph Helma <helma@in-silico.ch>2015-08-01 18:03:09 +0200
commit2d02fabfafccb164093062a962f392bb7d13647a (patch)
tree08d29519c45652dd1b43e2b0895875abfbc5e8d0
parentf93333d7f5df30875eae9135f4b5e65a98d923b6 (diff)
50 times faster bbrc setup by eliminating @fminer.add_fminer_data
-rw-r--r--lib/data_entry.rb40
-rw-r--r--lib/dataset.rb13
-rw-r--r--lib/feature.rb1
-rw-r--r--lib/opentox-client.rb2
4 files changed, 5 insertions, 51 deletions
diff --git a/lib/data_entry.rb b/lib/data_entry.rb
deleted file mode 100644
index 4eeb66d..0000000
--- a/lib/data_entry.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-module OpenTox
-
- class DataEntry
- field :feature_id, type: BSON::ObjectId
- field :compound_id, type: BSON::ObjectId
- # Kludge because csv import removes type information
- #field :feature_id, type: String
- #field :compound_id, type: String
- field :value
- field :warnings, type: String
- field :unit, type: String
- store_in collection: "data_entries"
- belongs_to :dataset
- has_one :compound
- has_one :feature
-
- # preferred method for the insertion of data entries
- # @example DataEntry.find_or_create compound,feature,value
- # @param compound [OpenTox::Compound]
- # @param feature [OpenTox::Feature]
- # @param value
- def self.find_or_create compound, feature, value
- self.find_or_create_by(
- :compound_id => compound.id,
- :feature_id => feature.id,
- :value => value
- )
- end
-
- # preferred method for accessing values
- # @example DataEntry[compound,feature]
- # @param compound [OpenTox::Compound]
- # @param feature [OpenTox::Feature]
- # @return value
- def self.[](compound,feature)
- self.where(:compound_id => compound.id.to_s, :feature_id => feature.id.to_s).distinct(:value).first
- end
-
- end
-end
diff --git a/lib/dataset.rb b/lib/dataset.rb
index 38e195b..45f7119 100644
--- a/lib/dataset.rb
+++ b/lib/dataset.rb
@@ -5,6 +5,10 @@ module OpenTox
class LazarPrediction < Dataset
field :creator, type: String
+ def value compound
+ end
+ def confidence compound
+ end
end
class DescriptorDataset < Dataset
@@ -21,7 +25,6 @@ module OpenTox
class Dataset
include Mongoid::Document
- attr_accessor :bulk
attr_writer :data_entries
# associations like has_many, belongs_to deteriorate performance
@@ -31,11 +34,6 @@ module OpenTox
field :source, type: String
field :warnings, type: Array, default: []
- def initialize params=nil
- super params
- @bulk = []
- end
-
def save_all
dump = Marshal.dump(@data_entries)
file = Mongo::Grid::File.new(dump, :filename => "#{self.id.to_s}.data_entries")
@@ -344,10 +342,8 @@ module OpenTox
next
elsif numeric[j]
@data_entries[i][j] = v.to_f
- #dataset.bulk << [cid,feature_ids[j],v.to_f]
else
@data_entries[i][j] = v.strip
- #dataset.bulk << [cid,feature_ids[j],v.strip]
end
end
end
@@ -359,7 +355,6 @@ module OpenTox
$logger.debug "Value parsing: #{Time.now-time} (Compound creation: #{compound_time})"
time = Time.now
- #dataset.bulk_write
save_all
$logger.debug "Saving: #{Time.now-time}"
diff --git a/lib/feature.rb b/lib/feature.rb
index e565875..0801a47 100644
--- a/lib/feature.rb
+++ b/lib/feature.rb
@@ -9,7 +9,6 @@ module OpenTox
field :supervised, type: Boolean
field :source, as: :title, type: String
#belongs_to :dataset
- #belongs_to :data_entry
end
class NominalFeature < Feature
diff --git a/lib/opentox-client.rb b/lib/opentox-client.rb
index f296837..7a5c8c0 100644
--- a/lib/opentox-client.rb
+++ b/lib/opentox-client.rb
@@ -10,7 +10,7 @@ require 'mongoid'
ENV["MONGOID_ENV"] = "development"
Mongoid.load!("#{ENV['HOME']}/.opentox/config/mongoid.yml")
-CLASSES = ["Compound", "Feature", "DataEntry","Dataset"]#, "Validation", "Task", "Investigation"]
+CLASSES = ["Compound", "Feature", "Dataset"]#, "Validation", "Task", "Investigation"]
#CLASSES = ["Feature", "Dataset", "Validation", "Task", "Investigation"]
# Regular expressions for parsing classification data