\HeaderA{MaskedXString-class}{MaskedXString objects}{MaskedXString.Rdash.class}
\aliasA{as.character,MaskedXString-method}{MaskedXString-class}{as.character,MaskedXString.Rdash.method}
\aliasA{class:MaskedAAString}{MaskedXString-class}{class:MaskedAAString}
\aliasA{class:MaskedBString}{MaskedXString-class}{class:MaskedBString}
\aliasA{class:MaskedDNAString}{MaskedXString-class}{class:MaskedDNAString}
\aliasA{class:MaskedRNAString}{MaskedXString-class}{class:MaskedRNAString}
\aliasA{class:MaskedXString}{MaskedXString-class}{class:MaskedXString}
\aliasA{coerce,AAString,MaskedAAString-method}{MaskedXString-class}{coerce,AAString,MaskedAAString.Rdash.method}
\aliasA{coerce,BString,MaskedBString-method}{MaskedXString-class}{coerce,BString,MaskedBString.Rdash.method}
\aliasA{coerce,DNAString,MaskedDNAString-method}{MaskedXString-class}{coerce,DNAString,MaskedDNAString.Rdash.method}
\aliasA{coerce,MaskedAAString,AAString-method}{MaskedXString-class}{coerce,MaskedAAString,AAString.Rdash.method}
\aliasA{coerce,MaskedBString,BString-method}{MaskedXString-class}{coerce,MaskedBString,BString.Rdash.method}
\aliasA{coerce,MaskedDNAString,DNAString-method}{MaskedXString-class}{coerce,MaskedDNAString,DNAString.Rdash.method}
\aliasA{coerce,MaskedRNAString,RNAString-method}{MaskedXString-class}{coerce,MaskedRNAString,RNAString.Rdash.method}
\aliasA{coerce,MaskedXString,MaskCollection-method}{MaskedXString-class}{coerce,MaskedXString,MaskCollection.Rdash.method}
\aliasA{coerce,MaskedXString,MaskedAAString-method}{MaskedXString-class}{coerce,MaskedXString,MaskedAAString.Rdash.method}
\aliasA{coerce,MaskedXString,MaskedBString-method}{MaskedXString-class}{coerce,MaskedXString,MaskedBString.Rdash.method}
\aliasA{coerce,MaskedXString,MaskedDNAString-method}{MaskedXString-class}{coerce,MaskedXString,MaskedDNAString.Rdash.method}
\aliasA{coerce,MaskedXString,MaskedRNAString-method}{MaskedXString-class}{coerce,MaskedXString,MaskedRNAString.Rdash.method}
\aliasA{coerce,MaskedXString,NormalIRanges-method}{MaskedXString-class}{coerce,MaskedXString,NormalIRanges.Rdash.method}
\aliasA{coerce,MaskedXString,Views-method}{MaskedXString-class}{coerce,MaskedXString,Views.Rdash.method}
\aliasA{coerce,MaskedXString,XStringViews-method}{MaskedXString-class}{coerce,MaskedXString,XStringViews.Rdash.method}
\aliasA{coerce,RNAString,MaskedRNAString-method}{MaskedXString-class}{coerce,RNAString,MaskedRNAString.Rdash.method}
\aliasA{collapse,MaskedXString-method}{MaskedXString-class}{collapse,MaskedXString.Rdash.method}
\aliasA{gaps,MaskedXString-method}{MaskedXString-class}{gaps,MaskedXString.Rdash.method}
\aliasA{length,MaskedXString-method}{MaskedXString-class}{length,MaskedXString.Rdash.method}
\aliasA{MaskedAAString}{MaskedXString-class}{MaskedAAString}
\aliasA{MaskedAAString-class}{MaskedXString-class}{MaskedAAString.Rdash.class}
\aliasA{MaskedBString}{MaskedXString-class}{MaskedBString}
\aliasA{MaskedBString-class}{MaskedXString-class}{MaskedBString.Rdash.class}
\aliasA{MaskedDNAString}{MaskedXString-class}{MaskedDNAString}
\aliasA{MaskedDNAString-class}{MaskedXString-class}{MaskedDNAString.Rdash.class}
\aliasA{maskedratio,MaskedXString-method}{MaskedXString-class}{maskedratio,MaskedXString.Rdash.method}
\aliasA{MaskedRNAString}{MaskedXString-class}{MaskedRNAString}
\aliasA{MaskedRNAString-class}{MaskedXString-class}{MaskedRNAString.Rdash.class}
\aliasA{maskedwidth,MaskedXString-method}{MaskedXString-class}{maskedwidth,MaskedXString.Rdash.method}
\aliasA{MaskedXString}{MaskedXString-class}{MaskedXString}
\aliasA{masks}{MaskedXString-class}{masks}
\aliasA{masks,MaskedXString-method}{MaskedXString-class}{masks,MaskedXString.Rdash.method}
\aliasA{masks,XString-method}{MaskedXString-class}{masks,XString.Rdash.method}
\aliasA{masks<\Rdash}{MaskedXString-class}{masks<.Rdash.}
\aliasA{masks<-,MaskedXString,MaskCollection-method}{MaskedXString-class}{masks<.Rdash.,MaskedXString,MaskCollection.Rdash.method}
\aliasA{masks<-,MaskedXString,NULL-method}{MaskedXString-class}{masks<.Rdash.,MaskedXString,NULL.Rdash.method}
\aliasA{masks<-,XString,ANY-method}{MaskedXString-class}{masks<.Rdash.,XString,ANY.Rdash.method}
\aliasA{masks<-,XString,NULL-method}{MaskedXString-class}{masks<.Rdash.,XString,NULL.Rdash.method}
\aliasA{nchar,MaskedXString-method}{MaskedXString-class}{nchar,MaskedXString.Rdash.method}
\aliasA{show,MaskedXString-method}{MaskedXString-class}{show,MaskedXString.Rdash.method}
\aliasA{subseq,MaskedXString-method}{MaskedXString-class}{subseq,MaskedXString.Rdash.method}
\aliasA{toString,MaskedXString-method}{MaskedXString-class}{toString,MaskedXString.Rdash.method}
\aliasA{unmasked}{MaskedXString-class}{unmasked}
\aliasA{unmasked,MaskedXString-method}{MaskedXString-class}{unmasked,MaskedXString.Rdash.method}
\aliasA{Views,MaskedXString-method}{MaskedXString-class}{Views,MaskedXString.Rdash.method}
\aliasA{xsbasetype,MaskedXString-method}{MaskedXString-class}{xsbasetype,MaskedXString.Rdash.method}
\aliasA{xsbasetype<-,MaskedXString-method}{MaskedXString-class}{xsbasetype<.Rdash.,MaskedXString.Rdash.method}
\keyword{methods}{MaskedXString-class}
\keyword{classes}{MaskedXString-class}
\begin{Description}\relax
The MaskedBString, MaskedDNAString, MaskedRNAString and MaskedAAString
classes are containers for storing masked sequences.

All those containers derive directly (and with no additional slots)
from the MaskedXString virtual class.
\end{Description}
\begin{Details}\relax
In Biostrings, a pile of masks can be put on top of a sequence.
A pile of masks is represented by a
\LinkA{MaskCollection}{MaskCollection} 
object and the sequence by an \LinkA{XString}{XString} object.
A MaskedXString object is the result of bundling them together in a
single object.

Note that, no matter what masks are put on top of it, the original
sequence is always stored unmodified in a MaskedXString object.
This allows the user to activate/deactivate masks without having to
worry about losing the information stored in the masked/unmasked
regions.
Also this allows efficient memory management since the original
sequence never needs to be copied (modifying it would require to
make a copy of it first - sequences cannot and should never be modified
in place in Biostrings), even when the set of active/inactive masks
changes.
\end{Details}
\begin{Section}{Accessor methods}
In the code snippets below, \code{x} is a MaskedXString object.
For \code{masks(x)} and \code{masks(x) <- y}, it can also be
an \LinkA{XString}{XString} object and \code{y} must be \code{NULL} or
a \LinkA{MaskCollection}{MaskCollection} object.

\describe{
\item[] \code{unmasked(x)}:
Turns \code{x} into an \LinkA{XString}{XString} object by dropping the masks.

\item[] \code{masks(x)}:
Turns \code{x} into a
\LinkA{MaskCollection}{MaskCollection} object by 
dropping the sequence.

\item[] \code{masks(x) <- y}:
If \code{x} is an \LinkA{XString}{XString} object and \code{y} is \code{NULL},
then this doesn't do anything.

If \code{x} is an \LinkA{XString}{XString} object and \code{y} is a
\LinkA{MaskCollection}{MaskCollection} object, then
this turns \code{x} into a MaskedXString object by putting the
masks in \code{y} on top of it.

If \code{x} is a MaskedXString object and \code{y} is \code{NULL},
then this is equivalent to \code{x <- unmasked(x)}.

If \code{x} is a MaskedXString object and \code{y} is a
\LinkA{MaskCollection}{MaskCollection} object, then
this replaces the masks currently on top of \code{x} by the masks
in \code{y}. 

\item[] \code{alphabet(x)}:
Equivalent to \code{alphabet(unmasked(x))}.
See \code{?\LinkA{alphabet}{alphabet}} for more information.

\item[] \code{length(x)}:
Equivalent to \code{length(unmasked(x))}.
See
\code{?`\LinkA{length,XString-method}{length,XString.Rdash.method}`}
for more information.

}
\end{Section}
\begin{Section}{"maskedwidth" and related methods}
In the code snippets below, \code{x} is a MaskedXString object.

\describe{
\item[] \code{maskedwidth(x)}:
Get the number of masked letters in \code{x}. A letter is considered
masked iff it's masked by at least one active mask.

\item[] \code{maskedratio(x)}:
Equivalent to \code{maskedwidth(x) / length(x)}.

\item[] \code{nchar(x)}:
Equivalent to \code{length(x) - maskedwidth(x)}.

}
\end{Section}
\begin{Section}{Coercion}
In the code snippets below, \code{x} is a MaskedXString object.

\describe{
\item[] \code{as(x, "XStringViews")}:
Turns \code{x} into an \LinkA{XStringViews}{XStringViews} object where the
views are the unmasked regions of the original sequence
("unmasked" means not masked by at least one active mask).

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

\describe{
\item[] \code{collapse(x)}:
Collapses the set of masks in \code{x} into a single mask made of
all active masks.

\item[] \code{gaps(x)}:
Reverses all the masks i.e. each mask is replaced by a mask
where previously unmasked regions are now masked and
previously masked regions are now unmasked.

}
\end{Section}
\begin{Author}\relax
H. Pages
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{maskMotif}{maskMotif}},
\code{\LinkA{injectHardMask}{injectHardMask}},
\code{\LinkA{alphabetFrequency}{alphabetFrequency}},
\code{\LinkA{reverse,MaskedXString-method}{reverse,MaskedXString.Rdash.method}},
\LinkA{XString-class}{XString.Rdash.class},
\LinkA{MaskCollection-class}{MaskCollection.Rdash.class},
\LinkA{XStringViews-class}{XStringViews.Rdash.class},
\LinkA{Ranges-utils}{Ranges.Rdash.utils}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  ## ---------------------------------------------------------------------
  ## A. MASKING BY POSITION
  ## ---------------------------------------------------------------------
  mask0 <- Mask(mask.width=29, start=c(3, 10, 25), width=c(6, 8, 5))
  x <- DNAString("ACACAACTAGATAGNACTNNGAGAGACGC")
  length(x)  # same as width(mask0)
  nchar(x)   # same as length(x)
  masks(x) <- mask0
  x
  length(x)  # has not changed
  nchar(x)   # has changed
  gaps(x)

  ## Prepare a MaskCollection object of 3 masks ('mymasks') by running the
  ## examples in the man page for these objects:
  example(MaskCollection, package="IRanges")

  ## Put it on 'x':
  masks(x) <- mymasks
  x
  alphabetFrequency(x)

  ## Deactivate all masks:
  active(masks(x)) <- FALSE
  x

  ## Activate mask "C":
  active(masks(x))["C"] <- TRUE
  x

  ## Turn MaskedXString object into an XStringViews object:
  as(x, "XStringViews")

  ## Drop the masks:
  masks(x) <- NULL
  x
  alphabetFrequency(x)

  ## ---------------------------------------------------------------------
  ## B. MASKING BY CONTENT
  ## ---------------------------------------------------------------------
  ## See ?maskMotif for masking by content
\end{ExampleCode}
\end{Examples}

