Question: How to make a GPos subclass that accept both UnstitchedGPos and StitchedGPos inputs?
0
gravatar for Charles Plessy
4 months ago by
Japan
Charles Plessy110 wrote:

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 • 117 views
ADD COMMENTlink modified 3 months ago by Hervé Pagès ♦♦ 14k • written 4 months ago by Charles Plessy110
Answer: How to make a GPos subclass that accept both UnstitchedGPos and StitchedGPos inp
2
gravatar for Hervé Pagès
3 months ago by
Hervé Pagès ♦♦ 14k
United States
Hervé Pagès ♦♦ 14k wrote:

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 COMMENTlink modified 3 months ago • written 3 months ago by Hervé Pagès ♦♦ 14k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 420 users visited in the last hour