[Bioc-devel] How to use initializing functions correctly ?
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: https://github.com/charles-plessy/CAGEr/blob/fix-CTSS-GPos/R/CTSS.R 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
Charles Plessy Akano, Uruma, Okinawa, Japan