How to make a GPos subclass that accept both UnstitchedGPos and StitchedGPos inputs?
1
0
Entering edit mode
@charles-plessy-7857
Last seen 15 months ago
Japan

Hello,

in the CAGEr package, I defined a CTSS (CAGE Transcription Start Site) subclass of GPos as follows:

.CTSS <- setClass("CTSS", contains = "GPos")

My goal is to add some type safety to my functions, to prevent myself to run them on GPos objects that are not transcription start sites. Unfortunately, this breaks in the Bioc devel, with the following error:

Error in initialize(value, ...) : 
  'initialize' method returned an object of class “StitchedGPos” instead of the required class “CTSS”

How can I make a class that accepts both UnstitchedGPos and StitchedGPos inputs?

GenomicRanges • 717 views
ADD COMMENT
2
Entering edit mode
@herve-pages-1542
Last seen 4 days ago
Seattle, WA, United States

Hi Charles,

Note that this is a question about package development so should be asked on the bioc-devel mailing list.

Do you really need to support both internal representations (i.e. unstitched and stitched positions) for your CTSS objects? It sounds unlikely that you'll have long runs of adjacent Transcription Start Sites in your objects so situations where stitching them in order to reduce memory footprint might be quite rare.

If you only want to support the unstitched internal representations, things are as simple as doing:

setClass("CTSS", contains="UnstitchedGPos")

CTSS <- function(...) new("CTSS", GPos(..., stitch=FALSE))

CTSS("chr1", 10*(10:15))
# CTSS object with 6 positions and 0 metadata columns:
#       seqnames       pos strand
#          <Rle> <integer>  <Rle>
#   [1]     chr1       100      *
#   [2]     chr1       110      *
#   [3]     chr1       120      *
#   [4]     chr1       130      *
#   [5]     chr1       140      *
#   [6]     chr1       150      *
#   -------
#   seqinfo: 1 sequence from an unspecified genome; no seqlengths

But if you really want to support both internal representations, things are going to be more complicated. Please ask on the bioc-devel mailing list if that's what you want to do.

Best,

H.

ADD COMMENT

Login before adding your answer.

Traffic: 552 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6