024399a3 |
readCdfUnitNames <- function(filename, units=NULL, verbose=0) {
|
8cab2c70 |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
024399a3 |
# Validate arguments
|
8cab2c70 |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
024399a3 |
# 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.");
|
024399a3 |
} else {
stop("Argument 'units' must be numeric or NULL: ", class(units)[1]);
}
|
ddd48129 |
# Argument 'verbose':
|
024399a3 |
if (length(verbose) != 1)
stop("Argument 'units' must be a single integer.");
verbose <- as.integer(verbose);
if (!is.finite(verbose))
stop("Argument 'units' must be an integer: ", verbose);
|
ddd48129 |
|
8cab2c70 |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
024399a3 |
# Read the CDF file
|
8cab2c70 |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# UNSUPPORTED CASE?
if (!is.null(units) && length(units) == 0L) {
stop("readCdfUnitNames(..., units=integer(0)) is not supported.")
}
|
4bd60283 |
res <- .Call("R_affx_get_cdf_unit_names", filename, units, verbose,
|
ad0b7500 |
PACKAGE="affxparser");
|
4bd60283 |
# Sanity check
if (is.null(res)) {
stop("Failed to read unit names from CDF file: ", filename);
}
|
8cab2c70 |
|
4bd60283 |
res;
} # readCdfUnitNames()
|
024399a3 |
|
ddd48129 |
############################################################################
# HISTORY:
|
4bd60283 |
# 2011-11-18
# o ROBUSTNESS: Added sanity check that the native code did not return NULL.
|
ddd48129 |
# 2006-03-28
# o Unit indices are now one-based. /HB
############################################################################
|