[Bioc-devel] adding a validity method to a class

Steve Lianoglou mailinglist.honeypot at gmail.com
Thu Mar 31 19:54:55 CEST 2011


On Thu, Mar 31, 2011 at 1:42 PM, Paul Shannon
<pshannon at systemsbiology.org> 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.
> Can anyone explain what I am doing wrong?

What if you do:


Or define your class first w/o the `validity` argument, then set it
after like so:

setValidity("CytoscapeWindowClass", validCytoscapeWindow)



Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

More information about the Bioc-devel mailing list