\HeaderA{createCel}{Creates an empty CEL file}{createCel}
\keyword{file}{createCel}
\keyword{IO}{createCel}
\begin{Description}\relax
Creates an empty CEL file.
\end{Description}
\begin{Usage}
\begin{verbatim}createCel(filename, header, nsubgrids=0, overwrite=FALSE, ..., verbose=FALSE)\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{filename}] The filename of the CEL file to be created.
\item[\code{header}] A \code{\LinkA{list}{list}} structure describing the CEL header, similar
to the structure returned by \code{\LinkA{readCelHeader}{readCelHeader}}().
\item[\code{overwrite}] If \code{\LinkA{FALSE}{FALSE}} and the file already exists, an exception
is thrown, otherwise the file is created.
\item[\code{nsubgrids}] The number of subgrids.
\item[\code{...}] Not used.
\item[\code{verbose}] An \code{\LinkA{integer}{integer}} specifying how much verbose details are
outputted.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Currently only binary (v4) CEL files are supported.
The current version of the method does not make use of the Fusion SDK,
but its own code to create the CEL file.
\end{Details}
\begin{Value}
Returns (invisibly) the pathname of the file created.
\end{Value}
\begin{Section}{Redundant fields in the CEL header}
There are a few redundant fields in the CEL header.  To make sure
the CEL header is consistent, redundant fields are cleared and
regenerated.  For instance, the field for the total number of cells
is calculated from the number of cell rows and columns.
\end{Section}
\begin{Author}\relax
Henrik Bengtsson (\url{http://www.braju.com/R/})
\end{Author}
\begin{Examples}
\begin{ExampleCode}
##############################################################
if (require("AffymetrixDataTestFiles")) {            # START #
##############################################################

# Search for first available ASCII CEL file
path <- system.file("rawData", package="AffymetrixDataTestFiles")
files <- findFiles(pattern="[.](cel|CEL)$", path=path, recursive=TRUE, firstOnly=FALSE)
files <- grep("ASCII", files, value=TRUE)
file <- files[1]

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Read the CEL header
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
hdr <- readCelHeader(file)
stopifnot(hdr$version == 3)

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Create a CEL v4 file of the same chip type
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
outFile <- file.path(tempdir(), "zzz.CEL")
if (file.exists(outFile))
  file.remove(outFile)
createCel(outFile, hdr, overwrite=TRUE)
str(readCelHeader(outFile))

# Verify correctness by update and re-read a few cells
intensities <- as.double(1:100)
indices <- seq(along=intensities)
updateCel(outFile, indices=indices, intensities=intensities)
value <- readCel(outFile, indices=indices)$intensities
stopifnot(identical(intensities, value))

##############################################################
}                                                     # STOP #
##############################################################
\end{ExampleCode}
\end{Examples}

