[Bioc-devel] adding a validity method to a class
Paul Shannon
pshannon at systemsbiology.org
Thu Mar 31 20:07:16 CEST 2011
Hi Steve,
validity=validCytoscapeWindow
rather than
validity=function(obj) validCytoscapeWindow (obj)
does not work, because the function is not defined at the time the class definition is read. By including it in a function body, the evaluation is deferred until all the source has been read. I suspect...
Your second suggestion:
setValidity("CytoscapeWindowClass", validCytoscapeWindow)
*does* work. But where should such an assignment be made? At global scope at the bottom of the class file? That seems a little ragged!
- Paul
On Mar 31, 2011, at 10:54 AM, Steve Lianoglou wrote:
> Hi,
>
> 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:
>
> setClass(...
> validity=validCytoscapeWindow
> )
>
> Or define your class first w/o the `validity` argument, then set it
> after like so:
>
> setValidity("CytoscapeWindowClass", validCytoscapeWindow)
>
> Maybe?
>
> -steve
>
> --
> 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