Permalink
Browse files

Affyio: updated C library module

  • Loading branch information...
pjotrp committed Jan 25, 2010
1 parent f282dd2 commit 0c76931b1ffb6cc9aee789c7fee7899f66c527d4
View
6 src/clibs/affyio/DESCRIPTION 100755 → 100644
@@ -1,11 +1,11 @@
Package: affyio
-Version: 1.8.0
+Version: 1.15.1
Title: Tools for parsing Affymetrix data files
Author: Benjamin Milo Bolstad <bmb@bmbolstad.com>
Maintainer: Benjamin Milo Bolstad <bmb@bmbolstad.com>
Depends: R (>= 2.6.0), methods
Description: Routines for parsing Affymetrix data files based upon file format information. Primary focus is on accessing the CEL and CDF file formats.
-License: LGPL version 2 or newer
+License: LGPL (>= 2)
biocViews: Microarray, DataImport, Infrastructure
LazyLoad: yes
-Packaged: Wed Apr 30 01:48:07 2008; biocbuild
+Packaged: 2009-11-10 20:54:53 UTC; biocbuild
View
0 src/clibs/affyio/HISTORY 100755 → 100644
No changes.
View
0 src/clibs/affyio/LICENSE 100755 → 100644
No changes.
View
0 src/clibs/affyio/NAMESPACE 100755 → 100644
No changes.
View
@@ -1,7 +1,7 @@
###
### File: check.cdf.type.R
###
-### AIM: return a string giving the file format. Either text, xda or unknown
+### Aim: return a string giving the file format. Either text, xda or unknown
### in the case that file format is not known.
###
@@ -15,6 +15,4 @@ check.cdf.type <- function(filename){
} else {
return("unknown")
}
-
-
}
View
@@ -1,14 +1,11 @@
-####
-####
-#### file: read.cdffile.list.R
-####
-#### aim: reads full CDF file into R list structure.
-####
-#### History
-#### Dec 1, 2005 - Initial version
-
-
-
+###
+### File: read.cdffile.list.R
+###
+### Aim: reads full CDF file into R list structure.
+###
+### History
+### Dec 1, 2005 - Initial version
+###
read.cdffile.list <- function (filename, cdf.path = getwd()){
@@ -24,4 +21,3 @@ read.cdffile.list <- function (filename, cdf.path = getwd()){
stop(paste("File format for",filename,"not recognized."))
}
}
-
View
6 src/clibs/affyio/R/read.celfile.R 100755 → 100644
@@ -1,9 +1,9 @@
###
-### file: read.celfile.R
+### File: read.celfile.R
###
-### aim: read entire contents of a single given specified CEL file into
+### Aim: read entire contents of a single given specified CEL file into
### an R data structure.
-
+###
read.celfile <- function(filename,intensity.means.only=FALSE){
View
@@ -1,4 +1,9 @@
-
+###
+### File: read.celfile.header.R
+###
+### Aim: read header contents of a given specified CEL file into
+### an R data structure.
+###
read.celfile.header <- function(filename,info=c("basic","full"),verbose=FALSE){
@@ -11,18 +16,22 @@ read.celfile.header <- function(filename,info=c("basic","full"),verbose=FALSE){
cat("Reading", filename, "to get header information.\n")
headdetails <- .Call("ReadHeader", filename, PACKAGE="affyio")
names(headdetails) <- c("cdfName","CEL dimensions")
-
- return(headdetails)
} else {
if (verbose)
cat("Reading", filename, "to get full header information.\n")
### full returns greater detailed information from the header. Exact details differ depending on the file format.
- headdetails <- .Call("ReadHeaderDetailed", filename, PACKAGE="affyio")
- names(headdetails) <- c("cdfName","CEL dimensions","GridCornerUL","GridCornerUR","GridCornerLR","GridCornerLL","DatHeader","Algorithm","AlgorithmParameters")
-
- return(headdetails)
+ headdetails <- try(.Call("ReadHeaderDetailed", filename, PACKAGE="affyio"))
+ if (is(headdetails, "try-error"))
+ stop("Failed to get full header information for ", filename)
+ names(headdetails) <- c("cdfName","CEL dimensions","GridCornerUL","GridCornerUR","GridCornerLR","GridCornerLL","DatHeader","Algorithm","AlgorithmParameters","ScanDate")
+
+ if (nchar(headdetails$ScanDate) == 0){
+ # try to extract it from the DatHeader
+ DatHeaderSplit <- strsplit(headdetails$DatHeader," ")
+ Which.Date <- grep("[0-9]*/[0-9]*/[0-9]*",DatHeaderSplit[[1]])
+ Which.Time <- grep("[0-9]*:[0-9]*:[0-9]*",DatHeaderSplit[[1]])
+ headdetails$ScanDate <- paste(DatHeaderSplit[[1]][Which.Date],DatHeaderSplit[[1]][Which.Time])
+ }
}
-
-
+ return(headdetails)
}
-
View
No changes.
View
0 src/clibs/affyio/aclocal.m4 100755 → 100644
No changes.
View
@@ -10,12 +10,12 @@
\item{filename}{fullpath to a cdf file}
}
\value{Returns a string which is currently one of:
- \itemize{
+
\item{text}{the cdf file is of the text format}
\item{xda}{the cdf file is of the binary format used in GCOS}
\item{unknown}{the parser can not handle this format or does not
recognize this file as a CDF file}
- }
+
}
\author{B. M. Bolstad <bmb@bmbolstad.com>}
View
No changes.
View
No changes.
View
No changes.
No changes.
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.6)
PROJECT(Biolib_affyio)
SET (M_NAME affyio)
-SET (M_VERSION 1.8)
+# SET (M_VERSION 1.8)
IF(NOT BUILD_LIBS)
SET (MAP_ROOT ../../../..)
View
0 src/clibs/affyio/src/Makevars.in 100755 → 100644
No changes.
View
0 src/clibs/affyio/src/Makevars.win 100755 → 100644
No changes.
View
No changes.
View
No changes.
View
86 src/clibs/affyio/src/read_abatch.c 100755 → 100644
@@ -19,7 +19,7 @@
**
** aim: read in from 1st to nth chips of CEL data
**
- ** Copyright (C) 2003-2007 B. M. Bolstad
+ ** Copyright (C) 2003-2008 B. M. Bolstad
**
** Created on Jun 13, 2003
**
@@ -144,6 +144,11 @@
** Oct 28, 2007 - add pthread based multi-threaded read_probematrix this is based on a submission by Paul Gordon (U Calgary)
** Feb 18, 2008 - R_read_cel_file now can be told to read only the mean intensities (rather than also the SD and npixels)
** Mar 6, 2008 - Add additional CEL file corruption checking.
+ ** Oct 16, 2008 - Fix issue with stack exhaustion
+ ** Oct 28, 2008 - Increase stack space allocated (prevents a crash)
+ ** Jan 15, 2008 - Fix VECTOR_ELT/STRING_ELT issues
+ ** Jun 3, 2009 - CEL corruption not detected in read.probematrix
+ ** Nov 10, 2009 Pthread on solaris fix
**
*************************************************************/
@@ -171,6 +176,9 @@
#if USE_PTHREADS
#include <pthread.h>
+#include <limits.h>
+#include <unistd.h>
+
pthread_mutex_t mutex_R;
int n_probesets;
int *n_probes = NULL;
@@ -198,6 +206,41 @@ struct thread_data{
#define BUF_SIZE 1024
+/******************************************************************
+ **
+ ** A "C" level object designed to hold information for a
+ ** single CEL file
+ **
+ ** These should be created using the function
+ **
+ ** read_cel_file()
+ **
+ **
+ **
+ *****************************************************************/
+
+typedef struct{
+ detailed_header_info header;
+
+ /** these are for storing the intensities, the sds and the number of pixels **/
+ double *intensities;
+ double *stddev;
+ double *npixels;
+
+ /** these are for storing information in the masks and outliers section **/
+
+ int nmasks;
+ int noutliers;
+
+ short *masks_x, *masks_y;
+ short *outliers_x, *outliers_y;
+
+} CEL;
+
+
+
+
+
/****************************************************************
@@ -1235,6 +1278,7 @@ static void get_detailed_header_info(const char *filename, detailed_header_info
fclose(currentFile);
+ header_info->ScanDate = Calloc(2, char);
}
@@ -2023,7 +2067,8 @@ static void gz_get_detailed_header_info(const char *filename, detailed_header_in
strcpy(header_info->AlgorithmParameters,get_token(cur_tokenset,1));
gzclose(currentFile);
-
+
+ header_info->ScanDate = Calloc(2, char);
}
@@ -2685,7 +2730,8 @@ static void binary_get_detailed_header_info(const char *filename, detailed_heade
error("Cel file %s does not seem to be have cdf information",filename);
}
}
-
+
+ header_info->ScanDate = Calloc(2, char);
delete_tokens(my_tokenset);
delete_binary_header(my_header);
@@ -3435,6 +3481,8 @@ static void gzbinary_get_detailed_header_info(const char *filename, detailed_hea
}
+ header_info->ScanDate = Calloc(2, char);
+
delete_tokens(my_tokenset);
delete_binary_header(my_header);
Free(header_copy);
@@ -4107,10 +4155,10 @@ SEXP ReadHeaderDetailed(SEXP filename){
const char *cur_file_name;
detailed_header_info header_info;
- PROTECT(HEADER = allocVector(VECSXP,9)); /* return as a list */
+ PROTECT(HEADER = allocVector(VECSXP,10)); /* return as a list */
- cur_file_name = CHAR(VECTOR_ELT(filename,0));
+ cur_file_name = CHAR(STRING_ELT(filename,0));
if (isTextCelFile(cur_file_name)){
@@ -4189,7 +4237,12 @@ SEXP ReadHeaderDetailed(SEXP filename){
SET_STRING_ELT(tmp_sexp,0,mkChar(header_info.AlgorithmParameters));
SET_VECTOR_ELT(HEADER,8,tmp_sexp);
UNPROTECT(1);
-
+
+ PROTECT(tmp_sexp = allocVector(STRSXP,1));
+ SET_STRING_ELT(tmp_sexp,0,mkChar(header_info.ScanDate));
+ SET_VECTOR_ELT(HEADER,9,tmp_sexp);
+ UNPROTECT(1);
+
Free(header_info.Algorithm);
Free(header_info.AlgorithmParameters);
Free(header_info.DatHeader);
@@ -4229,16 +4282,24 @@ void readfile(SEXP filenames, double *CurintensityMatrix, double *pmMatrix, doub
error("Compress option not supported on your platform\n");
#endif
} else if (isBinaryCelFile(cur_file_name)){
- read_binarycel_file_intensities(cur_file_name,CurintensityMatrix, 0, ref_dim_1*ref_dim_2, n_files,ref_dim_1);
+ if(read_binarycel_file_intensities(cur_file_name,CurintensityMatrix, 0, ref_dim_1*ref_dim_2, n_files,ref_dim_1) !=0){
+ error("The CEL file %s was corrupted. Data not read.\n",cur_file_name);
+ }
storeIntensities(CurintensityMatrix,pmMatrix,mmMatrix,i,ref_dim_1*ref_dim_2, n_files,num_probes,cdfInfo,which_flag);
} else if (isgzBinaryCelFile(cur_file_name)){
- gzread_binarycel_file_intensities(cur_file_name,CurintensityMatrix, 0, ref_dim_1*ref_dim_2, n_files,ref_dim_1);
+ if(gzread_binarycel_file_intensities(cur_file_name,CurintensityMatrix, 0, ref_dim_1*ref_dim_2, n_files,ref_dim_1) !=0){
+ error("The CEL file %s was corrupted. Data not read.\n",cur_file_name);
+ }
storeIntensities(CurintensityMatrix,pmMatrix,mmMatrix,i,ref_dim_1*ref_dim_2, n_files,num_probes,cdfInfo,which_flag);
} else if (isGenericCelFile(cur_file_name)){
- read_genericcel_file_intensities(cur_file_name,CurintensityMatrix, 0, ref_dim_1*ref_dim_2, n_files,ref_dim_1);
+ if(read_genericcel_file_intensities(cur_file_name,CurintensityMatrix, 0, ref_dim_1*ref_dim_2, n_files,ref_dim_1) !=0){
+ error("The CEL file %s was corrupted. Data not read.\n",cur_file_name);
+ }
storeIntensities(CurintensityMatrix,pmMatrix,mmMatrix,i,ref_dim_1*ref_dim_2, n_files,num_probes,cdfInfo,which_flag);
} else if (isgzGenericCelFile(cur_file_name)){
- gzread_genericcel_file_intensities(cur_file_name,CurintensityMatrix, 0, ref_dim_1*ref_dim_2, n_files,ref_dim_1);
+ if(gzread_genericcel_file_intensities(cur_file_name,CurintensityMatrix, 0, ref_dim_1*ref_dim_2, n_files,ref_dim_1)!=0){
+ error("The CEL file %s was corrupted. Data not read.\n",cur_file_name);
+ }
storeIntensities(CurintensityMatrix,pmMatrix,mmMatrix,i,ref_dim_1*ref_dim_2, n_files,num_probes,cdfInfo,which_flag);
} else {
#if defined HAVE_ZLIB
@@ -4384,6 +4445,8 @@ SEXP read_probeintensities(SEXP filenames, SEXP rm_mask, SEXP rm_outliers, SEXP
pthread_attr_t attr;
struct thread_data *args;
void *status;
+ size_t stacksize = PTHREAD_STACK_MIN + 0x40000;
+
#endif
if (strcmp(CHAR(STRING_ELT(which,0)),"pm") == 0){
@@ -4446,6 +4509,7 @@ SEXP read_probeintensities(SEXP filenames, SEXP rm_mask, SEXP rm_outliers, SEXP
/* Initialize and set thread detached attribute */
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+ pthread_attr_setstacksize (&attr, stacksize);
/* this code works out how many threads to use and allocates ranges of files to each thread */
/* The aim is to try to be as fair as possible in dividing up the matrix */
@@ -5255,7 +5319,7 @@ SEXP R_read_cel_file(SEXP filename, SEXP intensities_mean_only){
int read_intensities_only;
- const char *cur_file_name = CHAR(VECTOR_ELT(filename,0));
+ const char *cur_file_name = CHAR(STRING_ELT(filename,0));
read_intensities_only = INTEGER_POINTER(intensities_mean_only)[0];
View
35 src/clibs/affyio/src/read_abatch.h 100755 → 100644
@@ -22,41 +22,8 @@ typedef struct{
char *DatHeader;
char *Algorithm;
char *AlgorithmParameters;
+ char *ScanDate;
} detailed_header_info;
-/******************************************************************
- **
- ** A "C" level object designed to hold information for a
- ** single CEL file
- **
- ** These should be created using the function
- **
- ** read_cel_file()
- **
- **
- **
- *****************************************************************/
-
-typedef struct{
- detailed_header_info header;
-
- /** these are for storing the intensities, the sds and the number of pixels **/
- double *intensities;
- double *stddev;
- double *npixels;
-
- /** these are for storing information in the masks and outliers section **/
-
- int nmasks;
- int noutliers;
-
- short *masks_x, *masks_y;
- short *outliers_x, *outliers_y;
-
-} CEL;
-
-extern CEL *read_cel_file(const char *filename, int read_intensities_only);
-
-
#endif
View
5 src/clibs/affyio/src/read_bpmap.c 100755 → 100644
@@ -15,7 +15,8 @@
** June 12, 2006 - fix naming vector length issue.
** June 12, 2007 - much wailing and grinding of teeth, but finally a fix for reading version number right.
** Aug 25, 2007 - Move file reading functions to centralized location
- ** Mar 14, 2008 - Fix reading of version number for big endian platforms
+ ** Mar 14, 2008 - Fix reading of version number for big endian platforms
+ ** Jan 15, 2008 - Fix VECTOR_ELT/STRING_ELT issues
**
*******************************************************************/
@@ -839,7 +840,7 @@ SEXP ReadBPMAPFileIntoRList(SEXP filename){
const char *cur_file_name;
- cur_file_name = CHAR(VECTOR_ELT(filename,0));
+ cur_file_name = CHAR(STRING_ELT(filename,0));
Oops, something went wrong.

0 comments on commit 0c76931

Please sign in to comment.