Class: OpenTox::Model::Generic
- Inherits:
-
Object
- Object
- OpenTox::Model::Generic
- Includes:
- OpenTox::Model
- Defined in:
- lib/model.rb
Overview
Generic OpenTox model class for all API compliant services
Instance Attribute Summary
Attributes included from OpenTox
Class Method Summary collapse
-
.find(uri, subjectid = nil) ⇒ OpenTox::Model::Generic
Find Generic Opentox Model via URI, and loads metadata, could raise NotFound/NotAuthorized error.
Instance Method Summary collapse
-
#feature_type(subjectid = nil) ⇒ String
provides feature type, possible types are “regression” or “classification”.
Methods included from OpenTox::Model
Methods included from OpenTox
#add_metadata, all, #delete, #initialize, #load_metadata, login, text_to_html, #to_rdfxml
Class Method Details
.find(uri, subjectid = nil) ⇒ OpenTox::Model::Generic
Find Generic Opentox Model via URI, and loads metadata, could raise NotFound/NotAuthorized error
30 31 32 33 34 35 36 |
# File 'lib/model.rb', line 30 def self.find(uri,subjectid=nil) return nil unless uri model = Generic.new(uri) model.(subjectid) raise "could not load model metadata '"+uri.to_s+"'" if model.==nil or model..size==0 model end |
Instance Method Details
#feature_type(subjectid = nil) ⇒ String
provides feature type, possible types are “regression” or “classification”
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/model.rb', line 40 def feature_type(subjectid=nil) return @feature_type if @feature_type # dynamically perform restcalls if necessary (subjectid) if @metadata==nil or @metadata.size==0 or (@metadata.size==1 && @metadata.values[0]==@uri) algorithm = OpenTox::Algorithm::Generic.find(@metadata[OT.algorithm], subjectid) algorithm_title = algorithm ? algorithm.[DC.title] : nil algorithm_type = algorithm ? algorithm.[OT.isA] : nil dependent_variable = OpenTox::Feature.find( @metadata[OT.dependentVariables],subjectid ) dependent_variable_type = dependent_variable ? dependent_variable.feature_type : nil type_indicators = [dependent_variable_type, @metadata[OT.isA], @metadata[DC.title], @uri, algorithm_type, algorithm_title] type_indicators.each do |type| case type when /(?i)classification/ @feature_type = "classification" break when /(?i)regression/ @feature_type = "regression" end end raise "unknown model "+type_indicators.inspect unless @feature_type @feature_type end |