Module: OpenTox::Algorithm
- Includes:
- OpenTox
- Included in:
- Dataset, Fminer, Generic, Lazar, Similarity, Substructure, Model::Lazar
- Defined in:
- lib/algorithm.rb
Overview
Wrapper for OpenTox Algorithms
Defined Under Namespace
Modules: Dataset, Fminer, Neighbors, Similarity, Substructure Classes: Generic, Lazar
Instance Attribute Summary
Attributes included from OpenTox
Class Method Summary collapse
-
.gauss(x, sigma = 0.3) ⇒ Float
Gauss kernel.
-
.median(array) ⇒ Float
Median of an array.
Instance Method Summary collapse
-
#run(params = nil, waiting_task = nil) ⇒ String
Execute algorithm with parameters, please consult the OpenTox API and the webservice documentation for acceptable parameters.
-
#to_rdfxml ⇒ application/rdf+xml
Get OWL-DL representation in RDF/XML format.
Methods included from OpenTox
#add_metadata, all, #delete, #initialize, #load_metadata, login, text_to_html
Class Method Details
.gauss(x, sigma = 0.3) ⇒ Float
Gauss kernel
249 250 251 252 |
# File 'lib/algorithm.rb', line 249 def self.gauss(x, sigma = 0.3) d = 1.0 - x Math.exp(-(d*d)/(2*sigma*sigma)) end |
.median(array) ⇒ Float
Median of an array
257 258 259 260 261 262 |
# File 'lib/algorithm.rb', line 257 def self.median(array) return nil if array.empty? array.sort! m_pos = array.size / 2 return array.size % 2 == 1 ? array[m_pos] : (array[m_pos-1] + array[m_pos])/2 end |
Instance Method Details
#run(params = nil, waiting_task = nil) ⇒ String
Execute algorithm with parameters, please consult the OpenTox API and the webservice documentation for acceptable parameters
18 19 20 |
# File 'lib/algorithm.rb', line 18 def run(params=nil, waiting_task=nil) RestClientWrapper.post(@uri, params, {:accept => 'text/uri-list'}, waiting_task).to_s end |
#to_rdfxml ⇒ application/rdf+xml
Get OWL-DL representation in RDF/XML format
24 25 26 27 28 |
# File 'lib/algorithm.rb', line 24 def to_rdfxml s = Serializer::Owl.new s.add_algorithm(@uri,@metadata) s.to_rdfxml end |