.fold_and_truncate_coverage <- function(cvg, circle.length, width)
} else if (!isSingleNumberOrNA(width)) {
stop("'width' must be NULL or a single integer")
stop("'circle.length' must be a single integer")
.check_arg_names <- function(arg, arg.label, x_names, x_names.label)
if (!(is.null(arg_names) || identical(arg_names, x_names)))
stop("when '", arg.label, "' has names, ",
"they must be identical to ", x_names.label)
.unlist_width <- function(width, x_names, x_names.label)
stop("when 'width' is a list-like object, it must be named ",
"and its names must be identical to ", x_names.label)
stop("when 'width' is a list-like object, each list element ",
"should contain at most 1 element or be NULL")
width[width_eltlens == 0L] <- NA_integer_
stop("'x' must be a CompressedIRangesList object")
if (!(is.numeric(shift) || is(shift, "List")))
stop("'shift' must be a numeric vector or list-like object")
} else if (is.list(width) || is(width, "List")) {
width <- .unlist_width(width, x_names, x_names.label)
stop("'width' must be NULL or an integer vector")
if (!(is.numeric(weight) || is(weight, "List")))
stop("'weight' must be a numeric vector or list-like object")
} else if (!is.numeric(circle.length)) {
stop("'circle.length' must be an integer vector")
} else if (!is.integer(circle.length)) {
function(x, shift=0L, width=NULL, weight=1L, ...)
|| sum(colnames(x_mcols) == weight) != 1L)
stop("'mcols(x)' has 0 or more than 1 \"",
stop("the string supplied for 'shift' (\"", shift, "\")",
"is not a valid metadata column name of 'x'")
stop("the string supplied for 'width' (\"", width, "\")",
stop("the string supplied for 'weight' (\"", weight, "\")",
if (isSingleString(shift) && (shift %in% varnames))
if (isSingleString(weight) && (weight %in% varnames))

## A data.frame-like interface for S4 objects that implement length() and `[`
## NOTE: Normal data.frames always have rownames (sometimes as integers),
## but we allow the rownames to be NULL for efficiency. This means that we
## need to store the number of rows (nrows).
"DataFrame object with NULL colnames, please fix it "
"missing values not allowed in rownames"
"number of row names and number of rows differ"
## DataFrames with no columns can have NULL column name
"number of columns and number of column names differ"
## build up listData, with names from arguments
"different row counts implied by arguments"
"attempt to select less than one element"
"attempt to select more than one element"
## We do list-style subsetting when [ was called with no ','.
## NOTE: matrix-style subsetting by logical matrix not supported.
"'drop' argument ignored by list-style subsetting"
# drop by default if only one column left
## come up with some default row and col names
## attempt to derive new row and col names from value
## update row and col names, making them unique
## Break DataFrame into a normal R data.frame
### S3/S4 combo for as.data.frame.DataFrame
# matrices and tables just go through data.frame
## colnames on matrix with 0 columns are 'NULL'
## overriding the default inheritance-based coercion from methods package
## note that any element named 'row.names' will be interpreted differently
### FIXME: only exists due to annoying S4 warning due to its caching of