[Bioc-devel] adding a validity method to a class
Hi Paul,
On 03/31/2011 10:42 AM, Paul Shannon wrote:
I have defined a rather lengthy validity function for CytoscapeWindowClass. In my testing, I create incomplete or broken instances of the class. I get the results I want when I call the validity function like this, for example:
> RCytoscape:::validCytoscapeWindow (cw.broken)
You must provide an 'edgeType' edge attribute, which will be mapped to Cytoscape's 'interaction' edge attribute.
[1] FALSE
But when, following the example in the graphNEL source code, I try to assign this function to the 'validity' slot of the class, the function is not found.
The class definition:
setClass ("CytoscapeWindowClass",
representation = representation (title="character",
window.id='character',
graph="graph"),
contains='CytoscapeConnectionClass',
prototype = prototype (title="R graph",
graph=new ("graphNEL", edgemode='directed'),
uri="http://localhost:9000"),
validity=function(obj) validCytoscapeWindow (obj)
#validity=function(obj) RCytoscape:::validCytoscapeWindow (obj) # I also tried this
)
Calling 'validObject (cw)' should invoke 'validCytoscapeWindow' but does not.
^^
Are you calling validObject() on 'cw' or on 'cw.broken'?
It should work:
setClass("A", representation(blob="raw"),
validity=function(object) cat("Hi!\n"))
Then:
> a <- new("A")
> validObject(a)
Hi!
[1] TRUE
Cheers,
H.
Can anyone explain what I am doing wrong? Thanks! - Paul
_______________________________________________ Bioc-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel
Herv? Pag?s Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M2-B876 P.O. Box 19024 Seattle, WA 98109-1024 E-mail: hpages at fhcrc.org Phone: (206) 667-5791 Fax: (206) 667-1319