[Bioc-devel] How to use initializing functions correctly ?

Charles Plessy ch@r|e@@p|e@@y @end|ng |rom o|@t@jp
Wed May 13 15:49:10 CEST 2020

Le Tue, May 12, 2020 at 10:18:24AM -0700, Hervé Pagès a écrit :
> Note that the GPos() constructor is NOT the generator function returned by
> the setClass() statement that defines the GPos class. It's a constructor
> function defined in the GenomicRanges package and it implements a
> sophisticated logic.
> HOWEVER, please note that trying to support the 'stitch' argument does not
> make sense in a context where the newGPos class extends the UnstitchedGPos
> class. So you might want to do something like this instead:
> ## newGPos() has the same arguments as the GPos() constructor **except**
> ## the 'stitch' argument.
> newGPos <- function (seqnames=NULL, pos=NULL, strand=NULL,
>                      ..., seqinfo=NULL, seqlengths=NULL)
> {
>     gpos <- GPos(seqnames=seqnames, pos=pos, strand=strand,
>                  ..., seqinfo=seqinfo, seqlengths=seqlengths,
>                  stitch=FALSE)
>     new("newGPos", gpos)
> }

Thank you very much Hervé.  I think that I understand much better.  I
reformed my class to that it has a constructor that mimicks the
GPos(stitched = FALSE) one, plus an inializing function so that new()
can promote an UnstitchedGPos to the class, and finally a coerce method
so that GRanges can be converted.  The result is here:


Not sure if you have time to have a look, but anybody's comments would
be appreciated if I am still doing things wrong.

Have a nice day,


Charles Plessy
Akano, Uruma, Okinawa, Japan

More information about the Bioc-devel mailing list