[Bioc-devel] Importing generic functions from other pkgs and defining methods on them?

Wolfgang Huber huber at ebi.ac.uk
Fri Mar 9 12:34:10 CET 2007


Dear Seth,

thanks! That solves the problem. I had never understood what the
   if (!isGeneric("someFunc"))
idiom was good for, but I am pretty sure that at the time when I 
initially wrote the package it was necessary. Good thing it's gone now.

I followed all your recommendation, exported plotPenLL and added more 
vignettes.

Best wishes
   Wolfgang

------------------------------------------------------------------
Wolfgang Huber  EBI/EMBL  Cambridge UK  http://www.ebi.ac.uk/huber

> Hello again,
> 
> I think I have a solution for you.  You need to remove the conditional
> definition of the generics.
> 
> I know that at some point in the past one needed to do things like
> this:
> 
>    if (!isGeneric("someFunc"))
>        setGeneric("someFunc", ...)
> 
> But this is no longer required and it seems to cause problems if it is
> there.  I simply removed the if's in your AllGenerics.R and then the
> package built and checked for me.
> 
> I don't completely understand what was going on, but some parts of
> your code were not getting the generic when it was needed.
> 
> The if (!isGeneric) idiom is rather odd if you think about it.  The
> only sensible way to define a method on a generic is if you know a
> fair bit about that generic (e.g., what its formal arguments are).
> When you optionally don't define your own generic and then set a
> method, who knows what the generic will be....
> 
> So.  Remove the if(!isGeneric) and things should improve.
> 
> Also, since I spent some time looking at the code:
> 
>  * You should add a .onLoad function that does require("methods") as
>    per Writing R Extensions and use of S4 + NAMESPACE
> 
>  * If you call plotPenLL in the vignette, perhaps you should export it
>    instead of using ':::'.
> 
>  * You should add a Collate field to the DESCRIPTION file.  You are
>    getting a reasonable order at present, but since you have a lot of
>    R files, that luck is going to run out sooner or later.
>  
>  * It is probably also worth adding import(method) to the NAMESPACE
>    file.  The rule, it seems, with the methods package, is that if
>    there is a place where you could possible ask to use it, then you
>    should (DESCRIPTION, .onLoad, NAMESPACE).
> 
> 
> Best Wishes,
> 
> + seth
>



More information about the Bioc-devel mailing list