-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathKINOMOSeed-class.R
64 lines (53 loc) · 1.83 KB
/
KINOMOSeed-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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#' @include registry.R
#' @include KINOMOStrategy-class.R
NULL
#'
setClass('KINOMOSeed'
, representation(
method = 'function' # the method actual definition
)
, contains = 'Strategy'
)
#' Show method for objects of class \code{KINOMOSeed}
setMethod('show', 'KINOMOSeed',
function(object){
cat('<object of class: ', class(object), ">\n")
cat("name:\t", name(object), "\n")
svalue <- algorithm(object)
svalue <- if( is.function(svalue) ) '<function>' else paste("'", svalue,"'", sep='')
cat("method:\t", svalue, "\n")
return(invisible())
}
)
#' Returns the workhorse function of the seeding method described by \code{object}.
setMethod('algorithm', signature(object='KINOMOSeed'),
function(object){
slot(object, 'method')
}
)
#' Sets the workhorse function of the seeding method described by \code{object}.
setReplaceMethod('algorithm', signature(object='KINOMOSeed', value='function'),
function(object, value){
slot(object, 'method') <- value
validObject(object)
object
}
)
setGeneric('KINOMOSeed', function(key, method, ...) standardGeneric('KINOMOSeed') )
#' Default method simply calls \code{\link{new}} with the same arguments.
setMethod('KINOMOSeed', signature(key='character', method='ANY'),
function(key, method, ...){
# wrap function method into a new KINOMOSeed object
new('KINOMOSeed', name=key, method=method, ..., package=topns_name())
}
)
#' Creates an \code{KINOMOSeed} based on a template object (Constructor-Copy),
#' in particular it uses the \strong{same} name.
setMethod('KINOMOSeed', signature(key='KINOMOSeed', method='ANY'),
function(key, method, ...){
# do not change the object if single argument
if( nargs() == 1L ) return(key)
# build an object based on template object
new(class(method), key, method=method, ..., package=topns_name())
}
)