-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathKINOMOStrategyFunction-class.R
45 lines (36 loc) · 1.14 KB
/
KINOMOStrategyFunction-class.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#' @include KINOMOStrategy-class.R
NULL
#'
setClass('KINOMOStrategyFunction'
, representation(
algorithm = 'function' # the function that implements the algorithm
)
, contains = 'KINOMOStrategy'
)
setMethod('run', signature(object='KINOMOStrategyFunction', y='matrix', x='KINOMOfit'),
function(object, y, x, ...){
if( !is.function(fun <- algorithm(object)) )
stop("KINOMOStrategyFunction '", name(object), "': algorithm is not defined.")
# run the function that defines the algorithm and return the result
fun(y, x, ...)
}
)
#' @export
KINOMOFormals.KINOMOStrategyFunction <- function(x, ...){
args <- formals(x@algorithm)
args[-(1:2)]
}
#' Returns the single R function that implements the KINOMO algorithm -- as stored in
#' slot \code{algorithm}.
setMethod('algorithm', signature(object='KINOMOStrategyFunction'),
function(object){
slot(object, 'algorithm')
}
)
#' Sets the function that implements the KINOMO algorithm, stored in slot \code{algorithm}.
setReplaceMethod('algorithm', signature(object='KINOMOStrategyFunction', value='function'),
function(object, value){
slot(object, 'algorithm') <- value
object
}
)