## FIXME: these functions should probably be deprecated; we no longer
## use the term 'sequence' in the Vector API, and the wrappers are
## trivially simple. With one exception: mseqapply. We would need to
## export the convenient mapply_List, probably with a better
### These would be excluded from the deprecation
### (seqsplit<- renamed to splitAsList<-)
"Length of 'f' must equal the length of 'x'"
"Length of 'value' must equal the length of a split on 'f'"
"Length of 'unlist(value)' must equal length of 'f'"

cl <- names(contab)[contab == length(x)]
pkg <- sapply(do.call(c, unname(contains))[cl], packageSlot)
substring(x, 1, 1) <- toupper(substring(x, 1, 1))
coni <- head(which(mapply(exists, connms, ns)), 1)
mseqapply <- function(FUN, ..., MoreArgs = NULL, USE.NAMES = TRUE) {
.asList(mapply_List(FUN, ..., MoreArgs = MoreArgs, SIMPLIFY = FALSE,
tseqapply <- function(X, INDEX, FUN = NULL, ...) {
.asList(tapply(X, INDEX, FUN, ..., simplify = FALSE))
seqsplit <- function(x, f, drop=FALSE) {
seqby <- function(data, INDICES, FUN, ...) {
.asList(by(data, INDICES, FUN, ..., simplify = FALSE))
`seqsplit<-` <- function(x, f, drop = FALSE, ..., value) {
stop("Length of 'f' must equal the length of 'x'")
ind <- seqsplit(seq_len(length(x)), f, drop = drop)
stop("Length of 'value' must equal the length of a split on 'f'")
x[unlist(ind, use.names=FALSE)] <- unlist(value, use.names = FALSE)
setMethod("unsplit", "List", function(value, f, drop = FALSE) {
value_flat <- unlist(value, use.names = FALSE)
stop("Length of 'unlist(value)' must equal length of 'f'")
seqsplit(value_flat, f, drop = drop) <- value
setReplaceMethod("split", "Vector", function(x, f, drop = FALSE, ..., value) {
seqsplit(x, f, drop = drop, ...) <- value

### I. Vector-wise set operations: union, intersect, setdiff
### All the functions in that group are implemented to behave like
### endomorphisms with respect to their first argument 'x'.
### On IRanges objects, the functions in that group interpret each supplied
### object ('x' or 'y') as a set of integer values. Therefore, if 2 IRanges
### objects 'x1' and 'x2' represent the same set of integers, then each of
### these functions will return the same result when 'x1' is replaced by 'x2'
### in the input. The returned IRanges object is guaranteed to be normal
### (note that if 'x' is an IRanges *instance* then the returned object is
### still an IRanges *instance*, that is, it is *not* promoted to
### II. Element-wise (aka "parallel") set operations: punion, pintersect,
### The functions in that group take 2 *objects* of the same length and
### return an object of the same class and length as the first argument.
## We need to downgrade 'x' to an IRanges instance 'x0' so 'c(x0, y)'
## is guaranteed to work (even e.g. if 'x' is a NormalIRanges object).
## Maybe the call to update() below could be replaced by
## 'as(x, "IRanges") <- x0' but I was not lucky with my first
##   > as(v, "IRanges") <- IRanges(3, 8)
##   Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
"'x' and 'y' are incompatible by subject and query length"
"some pair of ranges have a gap within "
"  Use 'fill.gap=TRUE' to enforce their "
"some intersections produce ambiguous empty ranges.\n"
"  Use argument 'resolve.empty' to resolve them."
"some ranges in 'y' have their end points strictly inside\n"
"  the range in 'x' that they need to be subtracted from.\n"