diff options
author | Christoph Helma <helma@in-silico.ch> | 2015-10-08 10:43:43 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2015-10-08 10:43:43 +0200 |
commit | 1a56148aadef031c4f487bc23fda43f4ac5b7369 (patch) | |
tree | 3555c5883ed0c292b105c40c185ebba3e5bd4e3e /lib/algorithm.rb | |
parent | 394d564699756288569169ff3e198d6d7702f092 (diff) | |
parent | e3217075b602a950a0ee995fcfa731d97b5ba3eb (diff) |
new master branch
Diffstat (limited to 'lib/algorithm.rb')
-rw-r--r-- | lib/algorithm.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/algorithm.rb b/lib/algorithm.rb new file mode 100644 index 0000000..113f847 --- /dev/null +++ b/lib/algorithm.rb @@ -0,0 +1,21 @@ +module OpenTox + + module Algorithm + + # Generic method to execute algorithms + # Algorithms should: + # - accept a Compound, an Array of Compounds or a Dataset as first argument + # - optional parameters as second argument + # - return an object corresponding to the input type as result (eg. Compound -> value, Array of Compounds -> Array of values, Dataset -> Dataset with values + # @param [OpenTox::Compound,Array,OpenTox::Dataset] Input object + # @param [Hash] Algorithm parameters + # @return Algorithm result + def self.run algorithm, object, parameters=nil + bad_request_error "Cannot run '#{algorithm}' algorithm. Please provide an OpenTox::Algorithm." unless algorithm =~ /^OpenTox::Algorithm/ + klass,method = algorithm.split('.') + parameters.nil? ? Object.const_get(klass).send(method,object) : Object.const_get(klass).send(method,object, parameters) + end + + end +end + |