R/readCdfIsPm.R
f1d6fcf0
 #########################################################################/**
 # @RdocFunction readCdfIsPm
 #
 # @title "Checks if cells in a CDF file are perfect-match probes or not"
 #
8cab2c70
 # @synopsis
 #
f1d6fcf0
 # \description{
 #   @get "title".
 # }
8cab2c70
 #
f1d6fcf0
 # \arguments{
 #  \item{filename}{The filename of the CDF file.}
 #  \item{units}{An @integer @vector of unit indices specifying which units
 #     to be read.  If @NULL, all units are read.}
 #  \item{verbose}{An @integer specifying the verbose level. If 0, the
 #     file is parsed quietly.  The higher numbers, the more details.}
 # }
8cab2c70
 #
f1d6fcf0
 # \value{
 #   A named @list of named @logical vectors.  The name of the list elements
 #   are unit names and the names of the logical vector are group names.
 # }
 #
76cf4b26
 # @author "HB"
8cab2c70
 #
f1d6fcf0
 # @keyword "file"
 # @keyword "IO"
 # @keyword "internal"
 #*/#########################################################################
a5db4cd3
 readCdfIsPm <- function(filename, units=NULL, verbose=0) {
8cab2c70
   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
a5db4cd3
   # Validate arguments
8cab2c70
   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
a5db4cd3
   # Argument 'filename':
   filename <- file.path(dirname(filename), basename(filename));
   if (!file.exists(filename))
     stop("File not found: ", filename);
 
   # Argument 'units':
   if (is.null(units)) {
   } else if (is.numeric(units)) {
     units <- as.integer(units);
ddd48129
     if (any(units < 1))
       stop("Argument 'units' contains non-positive indices.");
a5db4cd3
   } else {
     stop("Argument 'units' must be numeric or NULL: ", class(units)[1]);
   }
 
ddd48129
   # Argument 'verbose':
a5db4cd3
   if (length(verbose) != 1)
2a5f6145
     stop("Argument 'verbose' must be a single integer.");
a5db4cd3
   verbose <- as.integer(verbose);
   if (!is.finite(verbose))
2a5f6145
     stop("Argument 'verbose' must be an integer: ", verbose);
a5db4cd3
 
ddd48129
 
8cab2c70
   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
a5db4cd3
   # Read the CDF file
8cab2c70
   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   # UNSUPPORTED CASE?
   if (!is.null(units) && length(units) == 0L) {
     stop("readCdfIsPm(..., units=integer(0)) is not supported.")
   }
 
4bd60283
   res <- .Call("R_affx_cdf_isPm", filename, units, verbose, PACKAGE="affxparser");
 
   # Sanity check
   if (is.null(res)) {
     stop("Failed to read PM information from CDF file: ", filename);
   }
8cab2c70
 
4bd60283
   res;
a5db4cd3
 }
 
 
 ############################################################################
 # HISTORY:
4bd60283
 # 2011-11-18
 # o ROBUSTNESS: Added sanity check that the native code did not return NULL.
f1d6fcf0
 # 2006-05-12
 # o Added Rdoc comments (converted from Rd).
ddd48129
 # 2006-03-28
 # o Unit indices are now one-based. /HB
a5db4cd3
 # 2006-01-11
 # o Created. /HB
 ############################################################################