R/PromoterAnnotation-class.R

### PromoterAnnotation Class Definition ###

setClass(
  "PromoterAnnotation",
  slots = c(
    reducedExonRanges = "GRanges",
    annotatedIntronRanges = "GRanges",
    promoterIdMapping = "data.frame",
    promoterCoordinates = "GRanges"
  ),
  prototype = list(
    reducedExonRanges = GRanges(),
    annotatedIntronRanges = GRanges(),
    promoterIdMapping = data.frame(),
    promoterCoordinates = GRanges()
  )
)

PromoterAnnotation <-
  function(reducedExonRanges = GRanges(),
           annotatedIntronRanges = GRanges(),
           promoterIdMapping = data.frame(),
           promoterCoordinates = GRanges()) {
    new(
      "PromoterAnnotation",
      reducedExonRanges = reducedExonRanges,
      annotatedIntronRanges = annotatedIntronRanges,
      promoterIdMapping = promoterIdMapping,
      promoterCoordinates = promoterCoordinates
    )
  }

setValidity("PromoterAnnotation", function(object) {
  check <- TRUE
  if (is(object@reducedExonRanges, 'GRanges') == FALSE) {
    check <- FALSE
  }
  if (is(object@annotatedIntronRanges, 'GRanges') == FALSE) {
    check <- FALSE
  }
  if (is(object@promoterIdMapping, 'data.frame') == FALSE) {
    check <- FALSE
  }
  if (is(object@promoterCoordinates, 'GRanges') == FALSE) {
    check <- FALSE
  }
  return(check)
})

### Getters ###

setGeneric("reducedExonRanges", function(x) standardGeneric("reducedExonRanges"))
setMethod("reducedExonRanges", "PromoterAnnotation", function(x) x@reducedExonRanges)

setGeneric("annotatedIntronRanges", function(x) standardGeneric("annotatedIntronRanges"))
setMethod("annotatedIntronRanges", "PromoterAnnotation", function(x) x@annotatedIntronRanges)

setGeneric("promoterIdMapping", function(x) standardGeneric("promoterIdMapping"))
setMethod("promoterIdMapping", "PromoterAnnotation", function(x) x@promoterIdMapping)

setGeneric("promoterCoordinates", function(x) standardGeneric("promoterCoordinates"))
setMethod("promoterCoordinates", "PromoterAnnotation", function(x) x@promoterCoordinates)

### Setters ###

setGeneric("reducedExonRanges<-", function(x, value) standardGeneric("reducedExonRanges<-"))
setMethod("reducedExonRanges<-", "PromoterAnnotation", function(x, value) {
  x@reducedExonRanges <- value
  validObject(x)
  x
})

setGeneric("annotatedIntronRanges<-", function(x, value) standardGeneric("annotatedIntronRanges<-"))
setMethod("annotatedIntronRanges<-", "PromoterAnnotation", function(x, value) {
  x@annotatedIntronRanges <- value
  validObject(x)
  x
})

setGeneric("promoterIdMapping<-", function(x, value) standardGeneric("promoterIdMapping<-"))
setMethod("promoterIdMapping<-", "PromoterAnnotation", function(x, value) {
  x@promoterIdMapping <- value
  validObject(x)
  x
})

setGeneric("promoterCoordinates<-", function(x, value) standardGeneric("promoterCoordinates<-"))
setMethod("promoterCoordinates<-", "PromoterAnnotation", function(x, value) {
  x@promoterCoordinates <- value
  validObject(x)
  x
})
dnzdmrcgl/proActivTest documentation built on June 9, 2019, 10:50 a.m.