\HeaderA{GappedRanges-class}{GappedRanges objects}{GappedRanges.Rdash.class}
\aliasA{as.data.frame,GappedRanges-method}{GappedRanges-class}{as.data.frame,GappedRanges.Rdash.method}
\aliasA{c,GappedRanges-method}{GappedRanges-class}{c,GappedRanges.Rdash.method}
\aliasA{class:GappedRanges}{GappedRanges-class}{class:GappedRanges}
\aliasA{coerce,CompressedIRangesList,GappedRanges-method}{GappedRanges-class}{coerce,CompressedIRangesList,GappedRanges.Rdash.method}
\aliasA{coerce,CompressedNormalIRangesList,GappedRanges-method}{GappedRanges-class}{coerce,CompressedNormalIRangesList,GappedRanges.Rdash.method}
\aliasA{coerce,GappedRanges,CompressedIRangesList-method}{GappedRanges-class}{coerce,GappedRanges,CompressedIRangesList.Rdash.method}
\aliasA{coerce,GappedRanges,CompressedNormalIRangesList-method}{GappedRanges-class}{coerce,GappedRanges,CompressedNormalIRangesList.Rdash.method}
\aliasA{coerce,GappedRanges,IRangesList-method}{GappedRanges-class}{coerce,GappedRanges,IRangesList.Rdash.method}
\aliasA{coerce,GappedRanges,NormalIRangesList-method}{GappedRanges-class}{coerce,GappedRanges,NormalIRangesList.Rdash.method}
\aliasA{coerce,GappedRanges,RangesList-method}{GappedRanges-class}{coerce,GappedRanges,RangesList.Rdash.method}
\aliasA{elementLengths,GappedRanges-method}{GappedRanges-class}{elementLengths,GappedRanges.Rdash.method}
\aliasA{end,GappedRanges-method}{GappedRanges-class}{end,GappedRanges.Rdash.method}
\aliasA{GappedRanges}{GappedRanges-class}{GappedRanges}
\aliasA{length,GappedRanges-method}{GappedRanges-class}{length,GappedRanges.Rdash.method}
\aliasA{names,GappedRanges-method}{GappedRanges-class}{names,GappedRanges.Rdash.method}
\aliasA{names<-,GappedRanges-method}{GappedRanges-class}{names<.Rdash.,GappedRanges.Rdash.method}
\aliasA{ngap}{GappedRanges-class}{ngap}
\aliasA{ngap,GappedRanges-method}{GappedRanges-class}{ngap,GappedRanges.Rdash.method}
\aliasA{seqselect,GappedRanges-method}{GappedRanges-class}{seqselect,GappedRanges.Rdash.method}
\aliasA{show,GappedRanges-method}{GappedRanges-class}{show,GappedRanges.Rdash.method}
\aliasA{start,GappedRanges-method}{GappedRanges-class}{start,GappedRanges.Rdash.method}
\aliasA{window,GappedRanges-method}{GappedRanges-class}{window,GappedRanges.Rdash.method}
\aliasA{[,GappedRanges-method}{GappedRanges-class}{[,GappedRanges.Rdash.method}
\aliasA{[[,GappedRanges-method}{GappedRanges-class}{[[,GappedRanges.Rdash.method}
\keyword{methods}{GappedRanges-class}
\keyword{classes}{GappedRanges-class}
\begin{Description}\relax
The GappedRanges class is a vector-like container for storing a set
of "gapped ranges".
\end{Description}
\begin{Details}\relax
A "gapped range" is conceptually the union of 1 or more non-overlapping
(and non-empty) ranges ordered from left to right.
More precisely, a "gapped range" can be represented by a normal IRanges
object of length >= 1. In particular normality here ensures that the
individual ranges are non-empty and are separated by non-empty gaps.
The start of a "gapped range" is the start of its first range.
The end of a "gapped range" is the end of its last range.
If we ignore the gaps, then a GappedRanges object can be seen as a
\LinkA{Ranges}{Ranges} object.
\end{Details}
\begin{Section}{Constructor}
No constructor function is provided for GappedRanges objects.
The coercion methods described below can be used to create GappedRanges
objects.
\end{Section}
\begin{Section}{Coercion}
\describe{
\item[] \code{as(from, "GappedRanges")}:
Turns a \LinkA{CompressedNormalIRangesList}{CompressedNormalIRangesList} or \LinkA{CompressedIRangesList}{CompressedIRangesList}
object into a GappedRanges object.

\item[] \code{as(from, "RangesList")}:
Turns a GappedRanges object into a \LinkA{RangesList}{RangesList} object (more precisely
the result will be a \LinkA{CompressedNormalIRangesList}{CompressedNormalIRangesList} object).

}
\end{Section}
\begin{Section}{Accessor methods}
In the code snippets below, \code{x} is a GappedRanges object.

\describe{
\item[] \code{length(x)}:
Returns the number of "gapped ranges" in \code{x}.

\item[] \code{start(x), end(x)}:
Returns an integer vector of length \code{length(x)}
containing the start and end (respectively) of each
"gapped range" in \code{x}. See Details section above for
the exact definitions of the start and end of a "gapped range".

\item[] \code{width(x)}:
Defined as \code{end(x) - start(x) + 1L}.

\item[] \code{ngap(x)}:
Returns an integer vector of length \code{length(x)}
containing the number of gaps for each "gapped range"
in \code{x}.
Equivalent to \code{elementLengths(x) - 1L}.

\item[] \code{names(x)}:
\code{NULL} or a character vector of length \code{length(x)}.

}
\end{Section}
\begin{Section}{Subsetting and related operations}
In the code snippets below, \code{x} is a GappedRanges object.

\describe{
\item[] \code{x[i]}:
Returns a new GappedRanges object made of the selected "gapped ranges".
\code{i} can be a numeric, character or logical vector,
or any of the types supported by the \code{[} method for
\LinkA{CompressedNormalIRangesList}{CompressedNormalIRangesList} objects.

\item[] \code{x[[i]]}:
Returns the \LinkA{NormalIRanges}{NormalIRanges} object representing the i-th
element in \code{x}.
Equivalent to \code{as(from, "RangesList")[[i]]}.
\code{i} can be a single numeric value or a single character string.

\item[] \code{elemenType(x)}:
Returns the type of \code{x[[i]]} as a single string (always
\code{"NormalIRanges"}).
Note that the semantic of the \code{[[} method for GappedRanges
objects is different from the semantic of the method for
\LinkA{Ranges}{Ranges} objects (the latter returns an integer vector).

\item[] \code{elementLengths(x)}:
Semantically equivalent to
\begin{alltt}sapply(seq\_len(length(x)), function(i) length(x[[i]]))\end{alltt}
but much faster.
Note that the semantic of the \code{elementLengths} method for
GappedRanges objects is different from the semantic of the method
for \LinkA{Ranges}{Ranges} objects (the latter returns the \code{width} of
the \LinkA{Ranges}{Ranges} object).

}
\end{Section}
\begin{Section}{Combining and related operations}
In the code snippets below, \code{x} is a GappedRanges object.

\describe{
\item[] \code{c(x, ...)}:
Combine \code{x} and the GappedRanges objects in \code{...} together.
The result is an object of the same class as \code{x}.

}
\end{Section}
\begin{Author}\relax
H. Pages
\end{Author}
\begin{SeeAlso}\relax
\LinkA{Ranges-class}{Ranges.Rdash.class},
\LinkA{CompressedNormalIRangesList-class}{CompressedNormalIRangesList.Rdash.class}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  ## The 3 following IRanges objects are normal. Each of them will be
  ## stored as a "gapped range" in the GappedRanges object 'gr'.
  ir1 <- IRanges(start=c(11, 21, 23), end=c(15, 21, 30))
  ir2 <- IRanges(start=-2, end=15)
  ir3 <- IRanges(start=c(-2, 21), end=c(10, 22))
  irl <- IRangesList(ir1, ir2, ir3)

  gr <- as(irl, "GappedRanges")
  gr

  length(gr)
  start(gr)
  end(gr)
  width(gr)
  ngap(gr)
  gr[-1]
  gr[ngap(gr) >= 1]
  gr[[1]]
  as.integer(gr[[1]])
  gr[[2]]
  as.integer(gr[[2]])
  as(gr, "RangesList")
  start(as(gr, "RangesList"))  # not the same as 'start(gr)'
\end{ExampleCode}
\end{Examples}

