summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2015-07-21 10:52:03 +0200
committerChristoph Helma <helma@in-silico.ch>2015-07-21 10:52:03 +0200
commite797fda1f946490d288e0ea7fd4eaf58eb18a746 (patch)
tree1c466c157979d754e20d500a66102fc086ce8d6a
parent51e7a29c8aac568ff8ef04de5b15d2f6db8f66da (diff)
intermediary commit before switching to generalised storage model
-rw-r--r--lib/dataset.rb29
1 files changed, 22 insertions, 7 deletions
diff --git a/lib/dataset.rb b/lib/dataset.rb
index 2a777bb..5e9da44 100644
--- a/lib/dataset.rb
+++ b/lib/dataset.rb
@@ -2,19 +2,28 @@ require 'csv'
module OpenTox
- # Ruby wrapper for OpenTox Dataset Webservices (http://opentox.org/dev/apis/api-1.2/dataset).
+ class MeasuredDataset < Dataset
+ end
+
+ class CalculatedDataset < Dataset
+ field :creator, type: String
+ end
+
+ class LazarPredictionDataset < CalculatedDataset
+ field :dependent_variables, type: BSON::ObjectId
+ field :predicted_variables, type: Array
+ end
+
+ # provides a basic datastructure similar to R dataframes
+ # descriptor/feature c
class Dataset
include Mongoid::Document
field :feature_ids, type: Array, default: []
field :inchis, type: Array, default: []
field :data_entries, type: Array, default: []
- field :warnings, type: Array, default: []
field :source, type: String
-
- # TODO subclass Datasets
- field :dependent_variables, type: BSON::ObjectId
- field :predicted_variables, type: Array
+ field :warnings, type: Array, default: []
# Readers
@@ -33,7 +42,7 @@ module OpenTox
end
def add_compound(compound)
- self.inchis << compound.id
+ self.inchis << compound.inchi
end
def features=(features)
@@ -111,6 +120,12 @@ module OpenTox
save
end
+ def self.from_csv_file file
+ dataset = self.new
+ dataset.upload file
+ dataset
+ end
+
# @param compound [OpenTox::Compound]
# @param feature [OpenTox::Feature]
# @param value [Object] (will be converted to String)