bio-affy 0.1.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +15 -0
  4. data/Gemfile.lock +32 -0
  5. data/LICENSE.txt +20 -0
  6. data/README.rdoc +33 -0
  7. data/Rakefile +77 -0
  8. data/VERSION +1 -0
  9. data/bin/bio-affy +80 -0
  10. data/bio-affy.gemspec +128 -0
  11. data/ext/DESCRIPTION +11 -0
  12. data/ext/HISTORY +3 -0
  13. data/ext/LICENSE +456 -0
  14. data/ext/NAMESPACE +2 -0
  15. data/ext/R/check.cdf.type.R +18 -0
  16. data/ext/R/read.cdffile.list.R +23 -0
  17. data/ext/R/read.celfile.R +11 -0
  18. data/ext/R/read.celfile.header.R +37 -0
  19. data/ext/R/read.probematrices.R +29 -0
  20. data/ext/README_BIOLIB +36 -0
  21. data/ext/aclocal.m4 +32 -0
  22. data/ext/configure +4898 -0
  23. data/ext/configure.in +51 -0
  24. data/ext/man/check.cdf.type.Rd +22 -0
  25. data/ext/man/read.cdffile.list.Rd +20 -0
  26. data/ext/man/read.celfile.Rd +23 -0
  27. data/ext/man/read.celfile.header.Rd +22 -0
  28. data/ext/man/read.celfile.probeintensity.matrices.Rd +31 -0
  29. data/ext/src/CMakeLists.txt +39 -0
  30. data/ext/src/Makevars.in +3 -0
  31. data/ext/src/Makevars.win +2 -0
  32. data/ext/src/Rakefile +43 -0
  33. data/ext/src/biolib_affyio.c +416 -0
  34. data/ext/src/biolib_affyio.h +132 -0
  35. data/ext/src/biolib_affyio.o +0 -0
  36. data/ext/src/fread_functions.c +871 -0
  37. data/ext/src/fread_functions.h +60 -0
  38. data/ext/src/fread_functions.o +0 -0
  39. data/ext/src/libaffyext.so +0 -0
  40. data/ext/src/mkrf.log +11 -0
  41. data/ext/src/mkrf_conf.rb +6 -0
  42. data/ext/src/read_abatch.c +5484 -0
  43. data/ext/src/read_abatch.h +63 -0
  44. data/ext/src/read_abatch.o +0 -0
  45. data/ext/src/read_bpmap.c +888 -0
  46. data/ext/src/read_bpmap.o +0 -0
  47. data/ext/src/read_cdf.h +347 -0
  48. data/ext/src/read_cdf_xda.c +1342 -0
  49. data/ext/src/read_cdf_xda.o +0 -0
  50. data/ext/src/read_cdffile2.c +1576 -0
  51. data/ext/src/read_cdffile2.o +0 -0
  52. data/ext/src/read_celfile_generic.c +2061 -0
  53. data/ext/src/read_celfile_generic.h +33 -0
  54. data/ext/src/read_celfile_generic.o +0 -0
  55. data/ext/src/read_clf.c +870 -0
  56. data/ext/src/read_clf.o +0 -0
  57. data/ext/src/read_generic.c +1446 -0
  58. data/ext/src/read_generic.h +144 -0
  59. data/ext/src/read_generic.o +0 -0
  60. data/ext/src/read_pgf.c +1337 -0
  61. data/ext/src/read_pgf.o +0 -0
  62. data/lib/bio-affy.rb +5 -0
  63. data/lib/bio/affy.rb +7 -0
  64. data/lib/bio/affyext.rb +23 -0
  65. data/lib/bio/libaffyext.so +0 -0
  66. data/spec/bio-affy_spec.rb +22 -0
  67. data/spec/spec_helper.rb +13 -0
  68. data/test/data/affy/GSM103328.CEL.gz +0 -0
  69. data/test/data/affy/GSM103329.CEL.gz +0 -0
  70. data/test/data/affy/GSM103330.CEL.gz +0 -0
  71. data/test/data/affy/MG_U74Av2.CDF.gz +0 -0
  72. metadata +190 -0
Binary file
@@ -0,0 +1,2061 @@
1
+ /*************************************************************
2
+ **
3
+ ** file: read_celfile_generic.c
4
+ **
5
+ ** Written by B. M. Bolstad <bmb@bmbolstad.com>
6
+ **
7
+ ** Aim is to read in Affymetrix CEL files in the
8
+ ** "Command Console Generic Data" File Format
9
+ ** This format is sometimes known as the Calvin format
10
+ **
11
+ ** As with other file format functionality in affyio
12
+ ** gzipped files are accepted.
13
+ **
14
+ ** The implementation here is based upon openly available
15
+ ** file format information. The code here is not dependent or based
16
+ ** in anyway on that in the Fusion SDK.
17
+ **
18
+ **
19
+ ** History
20
+ ** Sept 3, 2007 -Initial version
21
+ ** Sept 9, 2007 - fix compiler warnings
22
+ ** Oct 11, 2007 - fix missing DatHeader problem
23
+ ** Feb 11, 2008 - add #include for inttypes.h in situations that stdint.h might not exist
24
+ ** Feb 13, 2008 - fix problems with generic_get_detailed_header_info(), gzgeneric_get_detailed_header_info()
25
+ ** May 18, 2009 - Add Ability to extract scan date from CEL file header
26
+ **
27
+ *************************************************************/
28
+ #include <R.h>
29
+ #include <Rdefines.h>
30
+ #include <Rmath.h>
31
+ #include <Rinternals.h>
32
+
33
+ #define HAVE_STDINT_H 1
34
+ #ifdef HAVE_STDINT_H
35
+ #include <stdint.h>
36
+ #elif HAVE_INTTYPES_H
37
+ #include <inttypes.h>
38
+ #endif
39
+ #include <wchar.h>
40
+
41
+ #include <stdio.h>
42
+ #include <stdlib.h>
43
+ #include <zlib.h>
44
+
45
+ #include "read_generic.h"
46
+ #include "read_celfile_generic.h"
47
+ #include "read_abatch.h"
48
+
49
+ int isGenericCelFile(const char *filename){
50
+
51
+ FILE *infile;
52
+ generic_file_header file_header;
53
+ generic_data_header data_header;
54
+
55
+ if ((infile = fopen(filename, "rb")) == NULL)
56
+ {
57
+ error("Unable to open the file %s",filename);
58
+ return 0;
59
+ }
60
+
61
+ if (!read_generic_file_header(&file_header,infile)){
62
+ fclose(infile);
63
+ return 0;
64
+ }
65
+
66
+ if (!read_generic_data_header(&data_header,infile)){
67
+ Free_generic_data_header(&data_header);
68
+ fclose(infile);
69
+ return 0;
70
+ }
71
+
72
+ if (strcmp(data_header.data_type_id.value, "affymetrix-calvin-intensity") !=0){
73
+ Free_generic_data_header(&data_header);
74
+
75
+
76
+
77
+ fclose(infile);
78
+ return 0;
79
+ }
80
+ Free_generic_data_header(&data_header);
81
+
82
+ fclose(infile);
83
+ return 1;
84
+ }
85
+
86
+
87
+
88
+ char *generic_get_header_info(const char *filename, int *dim1, int *dim2){
89
+
90
+ FILE *infile;
91
+ generic_file_header file_header;
92
+ generic_data_header data_header;
93
+
94
+ char *cdfName = 0;
95
+
96
+ nvt_triplet *triplet;
97
+ AffyMIMEtypes cur_mime_type;
98
+
99
+ int size;
100
+
101
+ wchar_t *wchartemp=0;
102
+
103
+ if ((infile = fopen(filename, "rb")) == NULL)
104
+ {
105
+ error("Unable to open the file %s",filename);
106
+ return 0;
107
+ }
108
+
109
+ read_generic_file_header(&file_header,infile);
110
+ read_generic_data_header(&data_header,infile);
111
+
112
+ /* affymetrix-array-type text/plainText/plain String is HG-U133_Plus_2
113
+ Now Trying it again. But using exposed function
114
+ Its a Text/plain string value is HG-U133_Plus_2 with size 14
115
+ affymetrix-cel-cols text/x-calvin-integer-32Its a int32_t value is 1164
116
+ Now Trying it again. But using exposed function
117
+ Its a int32_t value is 1164
118
+ affymetrix-cel-rows text/x-calvin-integer-32Its a int32_t value is 1164
119
+ */
120
+
121
+ triplet = find_nvt(&data_header,"affymetrix-array-type");
122
+
123
+ cur_mime_type = determine_MIMETYPE(*triplet);
124
+
125
+ wchartemp = decode_MIME_value(*triplet,cur_mime_type, wchartemp, &size);
126
+ cdfName = Calloc(size + 1, char);
127
+ wcstombs(cdfName, wchartemp, size);
128
+ Free(wchartemp);
129
+
130
+ triplet = find_nvt(&data_header,"affymetrix-cel-cols");
131
+ cur_mime_type = determine_MIMETYPE(*triplet);
132
+ decode_MIME_value(*triplet,cur_mime_type, dim1, &size);
133
+
134
+ triplet = find_nvt(&data_header,"affymetrix-cel-rows");
135
+ cur_mime_type = determine_MIMETYPE(*triplet);
136
+ decode_MIME_value(*triplet,cur_mime_type, dim2, &size);
137
+
138
+ Free_generic_data_header(&data_header);
139
+ fclose(infile);
140
+
141
+ return cdfName;
142
+
143
+ }
144
+
145
+
146
+
147
+
148
+ void generic_get_detailed_header_info(const char *filename, detailed_header_info *header_info){
149
+
150
+ FILE *infile;
151
+ generic_file_header file_header;
152
+ generic_data_header data_header;
153
+ nvt_triplet *triplet;
154
+ AffyMIMEtypes cur_mime_type;
155
+ int size;
156
+
157
+ int algorithm_paramsize = 0;
158
+ float tempfloat;
159
+
160
+ wchar_t *wchartemp=0;
161
+ char *chartemp=0;
162
+
163
+ if ((infile = fopen(filename, "rb")) == NULL)
164
+ {
165
+ error("Unable to open the file %s",filename);
166
+ }
167
+
168
+ read_generic_file_header(&file_header,infile);
169
+ read_generic_data_header(&data_header,infile);
170
+
171
+ triplet = find_nvt(&data_header,"affymetrix-array-type");
172
+
173
+ cur_mime_type = determine_MIMETYPE(*triplet);
174
+
175
+ wchartemp = decode_MIME_value(*triplet,cur_mime_type, wchartemp, &size);
176
+ header_info->cdfName = Calloc(size + 1, char);
177
+ wcstombs(header_info->cdfName, wchartemp, size);
178
+ Free(wchartemp);
179
+
180
+ triplet = find_nvt(&data_header,"affymetrix-cel-cols");
181
+ cur_mime_type = determine_MIMETYPE(*triplet);
182
+ decode_MIME_value(*triplet,cur_mime_type, &(header_info->cols), &size);
183
+
184
+ triplet = find_nvt(&data_header,"affymetrix-cel-rows");
185
+ cur_mime_type = determine_MIMETYPE(*triplet);
186
+ decode_MIME_value(*triplet,cur_mime_type, &(header_info->rows), &size);
187
+
188
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-GridULX");
189
+ cur_mime_type = determine_MIMETYPE(*triplet);
190
+ decode_MIME_value(*triplet,cur_mime_type, &tempfloat, &size);
191
+ header_info->GridCornerULx = (int)(tempfloat +0.5);
192
+
193
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-GridULY");
194
+ cur_mime_type = determine_MIMETYPE(*triplet);
195
+ decode_MIME_value(*triplet,cur_mime_type, &tempfloat, &size);
196
+ header_info->GridCornerULy = (int)(tempfloat +0.5);
197
+
198
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-GridURX");
199
+ cur_mime_type = determine_MIMETYPE(*triplet);
200
+ decode_MIME_value(*triplet,cur_mime_type, &tempfloat, &size);
201
+ header_info->GridCornerURx = (int)(tempfloat +0.5);
202
+
203
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-GridURY");
204
+ cur_mime_type = determine_MIMETYPE(*triplet);
205
+ decode_MIME_value(*triplet,cur_mime_type, &tempfloat, &size);
206
+ header_info->GridCornerURy = (int)(tempfloat +0.5);
207
+
208
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-GridLLX");
209
+ cur_mime_type = determine_MIMETYPE(*triplet);
210
+ decode_MIME_value(*triplet,cur_mime_type, &tempfloat, &size);
211
+ header_info->GridCornerLLx = (int)(tempfloat +0.5);
212
+
213
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-GridLLY");
214
+ cur_mime_type = determine_MIMETYPE(*triplet);
215
+ decode_MIME_value(*triplet,cur_mime_type, &tempfloat, &size);
216
+ header_info->GridCornerLLy = (int)(tempfloat +0.5);
217
+
218
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-GridLRX");
219
+ cur_mime_type = determine_MIMETYPE(*triplet);
220
+ decode_MIME_value(*triplet,cur_mime_type, &tempfloat, &size);
221
+ header_info->GridCornerLRx = (int)(tempfloat +0.5);
222
+
223
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-GridLRY");
224
+ cur_mime_type = determine_MIMETYPE(*triplet);
225
+ decode_MIME_value(*triplet,cur_mime_type, &tempfloat, &size);
226
+ header_info->GridCornerLRy = (int)(tempfloat +0.5);
227
+
228
+
229
+ triplet = find_nvt(&data_header,"affymetrix-dat-header");
230
+
231
+ if (triplet != NULL){
232
+ cur_mime_type = determine_MIMETYPE(*triplet);
233
+
234
+ wchartemp = decode_MIME_value(*triplet,cur_mime_type, wchartemp, &size);
235
+ header_info->DatHeader = Calloc(size + 1, char);
236
+ wcstombs(header_info->DatHeader, wchartemp, size);
237
+ Free(wchartemp);
238
+ } else {
239
+ header_info->DatHeader = Calloc(2, char);
240
+ }
241
+
242
+ triplet = find_nvt(&data_header,"affymetrix-scan-date");
243
+
244
+ if (triplet != NULL){
245
+ cur_mime_type = determine_MIMETYPE(*triplet);
246
+
247
+ wchartemp = decode_MIME_value(*triplet,cur_mime_type, wchartemp, &size);
248
+ header_info->ScanDate = Calloc(size + 1, char);
249
+ wcstombs(header_info->ScanDate, wchartemp, size);
250
+ Free(wchartemp);
251
+ } else {
252
+ header_info->ScanDate = Calloc(2, char);
253
+ }
254
+
255
+
256
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-name");
257
+ cur_mime_type = determine_MIMETYPE(*triplet);
258
+
259
+ wchartemp = decode_MIME_value(*triplet,cur_mime_type, wchartemp, &size);
260
+ header_info->Algorithm = Calloc(size + 1, char);
261
+ wcstombs(header_info->Algorithm, wchartemp, size);
262
+ Free(wchartemp);
263
+
264
+
265
+
266
+ // "Percentile:75;CellMargin:2;OutlierHigh:1.500;OutlierLow:1.004;AlgVersion:6.0;FixedCellSize:TRUE;FullFeatureWidth:7;FullFeatureHeight:7;IgnoreOutliersInShiftRows:FALSE;FeatureExtraction:TRUE;PoolWidthExtenstion:2;PoolHeightExtension:2;UseSubgrids:FALSE;RandomizePixels:FALSE;ErrorBasis:StdvMean;StdMult:1.00000"
267
+
268
+ algorithm_paramsize = 0;
269
+
270
+ header_info->AlgorithmParameters = Calloc(11, char);
271
+ strncpy(header_info->AlgorithmParameters,"Percentile:",11);
272
+ algorithm_paramsize+=11;
273
+
274
+
275
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-Percentile");
276
+ if (triplet != NULL){
277
+ cur_mime_type = determine_MIMETYPE(*triplet);
278
+
279
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
280
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
281
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
282
+ algorithm_paramsize+= size +1;
283
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
284
+ Free(chartemp);
285
+ } else {
286
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
287
+ algorithm_paramsize+= 1;
288
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
289
+ }
290
+
291
+
292
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 11, char);
293
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"CellMargin:",11);
294
+ algorithm_paramsize+=11;
295
+
296
+
297
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-CellMargin");
298
+ if (triplet != NULL){
299
+ cur_mime_type = determine_MIMETYPE(*triplet);
300
+
301
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
302
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
303
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
304
+ algorithm_paramsize+= size +1;
305
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
306
+ Free(chartemp);
307
+ } else {
308
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
309
+ algorithm_paramsize+= 1;
310
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
311
+ }
312
+
313
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 12, char);
314
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"OutlierHigh:",12);
315
+ algorithm_paramsize+=12;
316
+
317
+
318
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-OutlierHigh");
319
+ if (triplet != NULL){
320
+ cur_mime_type = determine_MIMETYPE(*triplet);
321
+
322
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
323
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
324
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
325
+ algorithm_paramsize+= size +1;
326
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
327
+ Free(chartemp);
328
+ } else {
329
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
330
+ algorithm_paramsize+= 1;
331
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
332
+ }
333
+
334
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 11, char);
335
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"OutlierLow:",11);
336
+ algorithm_paramsize+=11;
337
+
338
+
339
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-OutlierLow");
340
+ if (triplet != NULL){
341
+ cur_mime_type = determine_MIMETYPE(*triplet);
342
+
343
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
344
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
345
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
346
+ algorithm_paramsize+= size +1;
347
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
348
+ Free(chartemp);
349
+ } else {
350
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
351
+ algorithm_paramsize+= 1;
352
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
353
+ }
354
+
355
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 11, char);
356
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"AlgVersion:",11);
357
+ algorithm_paramsize+=11;
358
+
359
+
360
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-AlgVersion");
361
+ if (triplet != NULL){
362
+ cur_mime_type = determine_MIMETYPE(*triplet);
363
+
364
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
365
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
366
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
367
+ algorithm_paramsize+= size +1;
368
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
369
+ Free(chartemp);
370
+ } else {
371
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
372
+ algorithm_paramsize+= 1;
373
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
374
+ }
375
+
376
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 14, char);
377
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"FixedCellSize:",14);
378
+ algorithm_paramsize+=14;
379
+
380
+
381
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-FixedCellSize");
382
+ if (triplet != NULL){
383
+ cur_mime_type = determine_MIMETYPE(*triplet);
384
+
385
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
386
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
387
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
388
+ algorithm_paramsize+= size +1;
389
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
390
+ Free(chartemp);
391
+ } else {
392
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
393
+ algorithm_paramsize+= 1;
394
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
395
+ }
396
+
397
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 17, char);
398
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"FullFeatureWidth:",17);
399
+ algorithm_paramsize+=17;
400
+
401
+
402
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-FullFeatureWidth");
403
+ if (triplet != NULL){
404
+ cur_mime_type = determine_MIMETYPE(*triplet);
405
+
406
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
407
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
408
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
409
+ algorithm_paramsize+= size +1;
410
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
411
+ Free(chartemp);
412
+ } else {
413
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
414
+ algorithm_paramsize+= 1;
415
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
416
+ }
417
+
418
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 18, char);
419
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"FullFeatureHeight:",18);
420
+ algorithm_paramsize+=18;
421
+
422
+
423
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-FullFeatureHeight");
424
+ if (triplet != NULL){
425
+ cur_mime_type = determine_MIMETYPE(*triplet);
426
+
427
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
428
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
429
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
430
+ algorithm_paramsize+= size +1;
431
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
432
+ Free(chartemp);
433
+ } else {
434
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
435
+ algorithm_paramsize+= 1;
436
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
437
+ }
438
+
439
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 26, char);
440
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"IgnoreOutliersInShiftRows:",26);
441
+ algorithm_paramsize+=26;
442
+
443
+
444
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-IgnoreOutliersInShiftRows");
445
+ if (triplet != NULL){
446
+ cur_mime_type = determine_MIMETYPE(*triplet);
447
+
448
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
449
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
450
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
451
+ algorithm_paramsize+= size +1;
452
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
453
+ Free(chartemp);
454
+ } else {
455
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
456
+ algorithm_paramsize+= 1;
457
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
458
+ }
459
+
460
+
461
+
462
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 18, char);
463
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"FeatureExtraction:",18);
464
+ algorithm_paramsize+=18;
465
+
466
+
467
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-FeatureExtraction");
468
+ if (triplet != NULL){
469
+ cur_mime_type = determine_MIMETYPE(*triplet);
470
+
471
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
472
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
473
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
474
+ algorithm_paramsize+= size +1;
475
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
476
+ Free(chartemp);
477
+ } else {
478
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
479
+ algorithm_paramsize+= 1;
480
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
481
+ }
482
+
483
+
484
+
485
+
486
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 20, char);
487
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"PoolWidthExtenstion:",20);
488
+ algorithm_paramsize+=20;
489
+
490
+
491
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-PoolWidthExtenstion");
492
+ if (triplet != NULL){
493
+ cur_mime_type = determine_MIMETYPE(*triplet);
494
+
495
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
496
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
497
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
498
+ algorithm_paramsize+= size +1;
499
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
500
+ Free(chartemp);
501
+ } else {
502
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
503
+ algorithm_paramsize+= 1;
504
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
505
+ }
506
+
507
+
508
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 20, char);
509
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"PoolHeightExtension:",20);
510
+ algorithm_paramsize+=20;
511
+
512
+
513
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-PoolHeightExtension");
514
+ if (triplet != NULL){
515
+ cur_mime_type = determine_MIMETYPE(*triplet);
516
+
517
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
518
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
519
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
520
+ algorithm_paramsize+= size +1;
521
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
522
+ Free(chartemp);
523
+ } else {
524
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
525
+ algorithm_paramsize+= 1;
526
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
527
+ }
528
+
529
+
530
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 12, char);
531
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"UseSubgrids:",12);
532
+ algorithm_paramsize+=12;
533
+
534
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-UseSubgrids");
535
+ if (triplet != NULL){
536
+ cur_mime_type = determine_MIMETYPE(*triplet);
537
+
538
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
539
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
540
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
541
+ algorithm_paramsize+= size +1;
542
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
543
+ Free(chartemp);
544
+ } else {
545
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
546
+ algorithm_paramsize+= 1;
547
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
548
+ }
549
+
550
+
551
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 16, char);
552
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"RandomizePixels:",16);
553
+ algorithm_paramsize+=16;
554
+
555
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-RandomizePixels");
556
+ if (triplet != NULL){
557
+ cur_mime_type = determine_MIMETYPE(*triplet);
558
+
559
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
560
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
561
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
562
+ algorithm_paramsize+= size +1;
563
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
564
+ Free(chartemp);
565
+ } else {
566
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
567
+ algorithm_paramsize+= 1;
568
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
569
+ }
570
+
571
+
572
+
573
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 11, char);
574
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"ErrorBasis:",11);
575
+ algorithm_paramsize+=11;
576
+
577
+
578
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-ErrorBasis");
579
+ if (triplet != NULL){
580
+ cur_mime_type = determine_MIMETYPE(*triplet);
581
+
582
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
583
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
584
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
585
+ algorithm_paramsize+= size +1;
586
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
587
+ Free(chartemp);
588
+ } else {
589
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
590
+ algorithm_paramsize+= 1;
591
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
592
+ }
593
+
594
+
595
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 8, char);
596
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"StdMult:",8);
597
+ algorithm_paramsize+=8;
598
+
599
+
600
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-StdMult");
601
+ if (triplet != NULL){
602
+ cur_mime_type = determine_MIMETYPE(*triplet);
603
+
604
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
605
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
606
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
607
+ algorithm_paramsize+= size +1;
608
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
609
+ Free(chartemp);
610
+ } else {
611
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
612
+ algorithm_paramsize+= 1;
613
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
614
+ }
615
+
616
+
617
+
618
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
619
+ header_info->AlgorithmParameters[algorithm_paramsize] ='\0';
620
+
621
+
622
+ Free_generic_data_header(&data_header);
623
+ fclose(infile);
624
+
625
+
626
+
627
+ }
628
+
629
+
630
+
631
+
632
+ int check_generic_cel_file(const char *filename, const char *ref_cdfName, int ref_dim_1, int ref_dim_2){
633
+
634
+ char *cdfName =0;
635
+ int dim1, dim2;
636
+
637
+
638
+ FILE *infile;
639
+ generic_file_header file_header;
640
+ generic_data_header data_header;
641
+
642
+ nvt_triplet *triplet;
643
+ AffyMIMEtypes cur_mime_type;
644
+
645
+ int size;
646
+
647
+ wchar_t *wchartemp=0;
648
+
649
+
650
+ if ((infile = fopen(filename, "rb")) == NULL)
651
+ {
652
+ error("Unable to open the file %s",filename);
653
+ return 0;
654
+ }
655
+
656
+ read_generic_file_header(&file_header,infile);
657
+ read_generic_data_header(&data_header,infile);
658
+
659
+
660
+ triplet = find_nvt(&data_header,"affymetrix-array-type");
661
+
662
+ cur_mime_type = determine_MIMETYPE(*triplet);
663
+
664
+ wchartemp = decode_MIME_value(*triplet,cur_mime_type, wchartemp, &size);
665
+ cdfName = Calloc(size + 1, char);
666
+ wcstombs(cdfName, wchartemp, size);
667
+ Free(wchartemp);
668
+
669
+ triplet = find_nvt(&data_header,"affymetrix-cel-cols");
670
+ cur_mime_type = determine_MIMETYPE(*triplet);
671
+ decode_MIME_value(*triplet,cur_mime_type, &dim1, &size);
672
+
673
+ triplet = find_nvt(&data_header,"affymetrix-cel-rows");
674
+ cur_mime_type = determine_MIMETYPE(*triplet);
675
+ decode_MIME_value(*triplet,cur_mime_type, &dim2, &size);
676
+
677
+ Free_generic_data_header(&data_header);
678
+
679
+ if ((dim1 != ref_dim_1) || (dim2 != ref_dim_2)){
680
+ error("Cel file %s does not seem to have the correct dimensions",filename);
681
+ }
682
+
683
+ if (strncasecmp(cdfName,ref_cdfName,strlen(ref_cdfName)) != 0){
684
+ error("Cel file %s does not seem to be of %s type",filename,ref_cdfName);
685
+ }
686
+
687
+ Free(cdfName);
688
+
689
+
690
+ fclose(infile);
691
+ return 0;
692
+ }
693
+
694
+
695
+
696
+
697
+ /***************************************************************
698
+ **
699
+ ** static int read_binarycel_file_intensities(const char *filename, double *intensity, int chip_num, int rows, int cols,int chip_dim_rows)
700
+ **
701
+ **
702
+ ** This function reads binary cel file intensities into the data matrix
703
+ **
704
+ **************************************************************/
705
+
706
+ int read_genericcel_file_intensities(const char *filename, double *intensity, int chip_num, int rows, int cols,int chip_dim_rows){
707
+
708
+ int i=0, j=0;
709
+ int cur_index;
710
+
711
+ int fread_err=0;
712
+
713
+ FILE *infile;
714
+
715
+ generic_file_header my_header;
716
+ generic_data_header my_data_header;
717
+ generic_data_group my_data_group;
718
+
719
+ generic_data_set my_data_set;
720
+
721
+
722
+ if ((infile = fopen(filename, "rb")) == NULL)
723
+ {
724
+ error("Unable to open the file %s\n",filename);
725
+ return 0;
726
+ }
727
+
728
+
729
+
730
+ read_generic_file_header(&my_header, infile);
731
+ read_generic_data_header(&my_data_header, infile);
732
+ read_generic_data_group(&my_data_group,infile);
733
+
734
+ read_generic_data_set(&my_data_set,infile);
735
+ read_generic_data_set_rows(&my_data_set,infile);
736
+
737
+ for (i =0; i < my_data_set.nrows; i++){
738
+ intensity[chip_num*my_data_set.nrows + i] = (double)(((float *)my_data_set.Data[0])[i]);
739
+ }
740
+
741
+ fclose(infile);
742
+ Free_generic_data_set(&my_data_set);
743
+ Free_generic_data_header(&my_data_header);
744
+ Free_generic_data_group(&my_data_group);
745
+
746
+
747
+
748
+
749
+ return(0);
750
+ }
751
+
752
+
753
+
754
+
755
+
756
+ int read_genericcel_file_stddev(const char *filename, double *intensity, int chip_num, int rows, int cols,int chip_dim_rows){
757
+
758
+ int i=0, j=0;
759
+ int cur_index;
760
+
761
+ int fread_err=0;
762
+
763
+ FILE *infile;
764
+
765
+ generic_file_header my_header;
766
+ generic_data_header my_data_header;
767
+ generic_data_group my_data_group;
768
+
769
+ generic_data_set my_data_set;
770
+
771
+
772
+ if ((infile = fopen(filename, "rb")) == NULL)
773
+ {
774
+ error("Unable to open the file %s\n",filename);
775
+ return 0;
776
+ }
777
+
778
+
779
+
780
+ read_generic_file_header(&my_header, infile);
781
+ read_generic_data_header(&my_data_header, infile);
782
+ read_generic_data_group(&my_data_group,infile);
783
+
784
+ read_generic_data_set(&my_data_set,infile);
785
+ fseek(infile, my_data_set.file_pos_last, SEEK_SET);
786
+ Free_generic_data_set(&my_data_set);
787
+
788
+ read_generic_data_set(&my_data_set,infile);
789
+ read_generic_data_set_rows(&my_data_set,infile);
790
+ for (i =0; i < my_data_set.nrows; i++){
791
+ intensity[chip_num*my_data_set.nrows + i] = (double)(((float *)my_data_set.Data[0])[i]);
792
+ }
793
+ Free_generic_data_set(&my_data_set);
794
+ Free_generic_data_header(&my_data_header);
795
+ Free_generic_data_group(&my_data_group);
796
+
797
+ fclose(infile);
798
+
799
+
800
+ return(0);
801
+
802
+
803
+
804
+
805
+
806
+ }
807
+
808
+
809
+
810
+ int read_genericcel_file_npixels(const char *filename, double *intensity, int chip_num, int rows, int cols,int chip_dim_rows){
811
+
812
+ int i=0, j=0;
813
+ int cur_index;
814
+
815
+ int fread_err=0;
816
+
817
+ FILE *infile;
818
+
819
+ generic_file_header my_header;
820
+ generic_data_header my_data_header;
821
+ generic_data_group my_data_group;
822
+
823
+ generic_data_set my_data_set;
824
+
825
+
826
+ if ((infile = fopen(filename, "rb")) == NULL)
827
+ {
828
+ error("Unable to open the file %s\n",filename);
829
+ return 0;
830
+ }
831
+
832
+
833
+
834
+ read_generic_file_header(&my_header, infile);
835
+ read_generic_data_header(&my_data_header, infile);
836
+ read_generic_data_group(&my_data_group,infile);
837
+
838
+ read_generic_data_set(&my_data_set,infile);
839
+ fseek(infile, my_data_set.file_pos_last, SEEK_SET);
840
+ Free_generic_data_set(&my_data_set);
841
+
842
+ read_generic_data_set(&my_data_set,infile);
843
+ fseek(infile, my_data_set.file_pos_last, SEEK_SET);
844
+ Free_generic_data_set(&my_data_set);
845
+
846
+
847
+ read_generic_data_set(&my_data_set,infile);
848
+ read_generic_data_set_rows(&my_data_set,infile);
849
+ for (i =0; i < my_data_set.nrows; i++){
850
+ intensity[chip_num*my_data_set.nrows + i] = (double)(((short *)my_data_set.Data[0])[i]);
851
+ }
852
+ Free_generic_data_set(&my_data_set);
853
+ Free_generic_data_header(&my_data_header);
854
+ Free_generic_data_group(&my_data_group);
855
+
856
+ fclose(infile);
857
+
858
+
859
+ return(0);
860
+
861
+
862
+
863
+
864
+ }
865
+
866
+
867
+
868
+
869
+ void generic_get_masks_outliers(const char *filename, int *nmasks, short **masks_x, short **masks_y, int *noutliers, short **outliers_x, short **outliers_y){
870
+
871
+
872
+
873
+
874
+ int i=0, j=0;
875
+ int cur_index;
876
+
877
+ int fread_err=0;
878
+
879
+ FILE *infile;
880
+
881
+ generic_file_header my_header;
882
+ generic_data_header my_data_header;
883
+ generic_data_group my_data_group;
884
+
885
+ generic_data_set my_data_set;
886
+
887
+
888
+ if ((infile = fopen(filename, "rb")) == NULL)
889
+ {
890
+ error("Unable to open the file %s\n",filename);
891
+
892
+ }
893
+
894
+
895
+
896
+ read_generic_file_header(&my_header, infile);
897
+ read_generic_data_header(&my_data_header, infile);
898
+ read_generic_data_group(&my_data_group,infile);
899
+
900
+ /* passing the intensities */
901
+ read_generic_data_set(&my_data_set,infile);
902
+ fseek(infile, my_data_set.file_pos_last, SEEK_SET);
903
+ Free_generic_data_set(&my_data_set);
904
+
905
+ /* passing by the stddev */
906
+ read_generic_data_set(&my_data_set,infile);
907
+ fseek(infile, my_data_set.file_pos_last, SEEK_SET);
908
+ Free_generic_data_set(&my_data_set);
909
+
910
+ /* passing by the npixels */
911
+ read_generic_data_set(&my_data_set,infile);
912
+ fseek(infile, my_data_set.file_pos_last, SEEK_SET);
913
+ Free_generic_data_set(&my_data_set);
914
+
915
+ /* Now lets go for the "Outlier" */
916
+ read_generic_data_set(&my_data_set,infile);
917
+
918
+
919
+ *noutliers = my_data_set.nrows;
920
+
921
+ *outliers_x = Calloc(my_data_set.nrows,short);
922
+ *outliers_y = Calloc(my_data_set.nrows,short);
923
+
924
+ read_generic_data_set_rows(&my_data_set,infile);
925
+
926
+ for (i=0; i < my_data_set.nrows; i++){
927
+ (*outliers_x)[i] = ((short *)my_data_set.Data[0])[i];
928
+ (*outliers_y)[i] = ((short *)my_data_set.Data[1])[i];
929
+ }
930
+
931
+ fseek(infile, my_data_set.file_pos_last, SEEK_SET);
932
+ Free_generic_data_set(&my_data_set);
933
+
934
+ /* Now lets go for the "Mask" */
935
+ read_generic_data_set(&my_data_set,infile);
936
+
937
+ *nmasks = my_data_set.nrows;
938
+
939
+ *masks_x = Calloc(my_data_set.nrows,short);
940
+ *masks_y = Calloc(my_data_set.nrows,short);
941
+
942
+
943
+ read_generic_data_set_rows(&my_data_set,infile);
944
+ for (i=0; i < my_data_set.nrows; i++){
945
+ (*outliers_x)[i] = ((short *)my_data_set.Data[0])[i];
946
+ (*outliers_y)[i] = ((short *)my_data_set.Data[1])[i];
947
+ }
948
+ Free_generic_data_set(&my_data_set);
949
+ Free_generic_data_header(&my_data_header);
950
+ Free_generic_data_group(&my_data_group);
951
+
952
+ fclose(infile);
953
+
954
+ }
955
+
956
+
957
+
958
+
959
+
960
+ void generic_apply_masks(const char *filename, double *intensity, int chip_num, int rows, int cols,int chip_dim_rows, int rm_mask, int rm_outliers){
961
+
962
+
963
+ int i=0, j=0;
964
+ int cur_index;
965
+
966
+ short cur_x, cur_y;
967
+
968
+
969
+ int fread_err=0;
970
+ int nrows;
971
+ int size;
972
+
973
+ FILE *infile;
974
+
975
+ generic_file_header my_header;
976
+ generic_data_header my_data_header;
977
+ generic_data_group my_data_group;
978
+
979
+ generic_data_set my_data_set;
980
+ nvt_triplet *triplet;
981
+ AffyMIMEtypes cur_mime_type;
982
+
983
+ if ((infile = fopen(filename, "rb")) == NULL)
984
+ {
985
+ error("Unable to open the file %s\n",filename);
986
+
987
+ }
988
+
989
+
990
+
991
+ read_generic_file_header(&my_header, infile);
992
+ read_generic_data_header(&my_data_header, infile);
993
+ read_generic_data_group(&my_data_group,infile);
994
+
995
+
996
+ triplet = find_nvt(&my_data_header,"affymetrix-cel-rows");
997
+ cur_mime_type = determine_MIMETYPE(*triplet);
998
+ decode_MIME_value(*triplet,cur_mime_type, &nrows, &size);
999
+
1000
+
1001
+
1002
+ /* passing the intensities */
1003
+ read_generic_data_set(&my_data_set,infile);
1004
+ fseek(infile, my_data_set.file_pos_last, SEEK_SET);
1005
+ Free_generic_data_set(&my_data_set);
1006
+
1007
+ /* passing by the stddev */
1008
+ read_generic_data_set(&my_data_set,infile);
1009
+ fseek(infile, my_data_set.file_pos_last, SEEK_SET);
1010
+ Free_generic_data_set(&my_data_set);
1011
+
1012
+ /* passing by the npixels */
1013
+ read_generic_data_set(&my_data_set,infile);
1014
+ fseek(infile, my_data_set.file_pos_last, SEEK_SET);
1015
+ Free_generic_data_set(&my_data_set);
1016
+
1017
+ /* Now lets go for the "Outlier" */
1018
+ read_generic_data_set(&my_data_set,infile);
1019
+
1020
+ if (rm_outliers){
1021
+ read_generic_data_set_rows(&my_data_set,infile);
1022
+ for (i=0; i < my_data_set.nrows; i++){
1023
+ cur_x = ((short *)my_data_set.Data[0])[i];
1024
+ cur_y = ((short *)my_data_set.Data[1])[i];
1025
+ cur_index = (int)cur_x + nrows*(int)cur_y;
1026
+ intensity[chip_num*rows + cur_index] = R_NaN;
1027
+ }
1028
+ }
1029
+
1030
+ fseek(infile, my_data_set.file_pos_last, SEEK_SET);
1031
+ Free_generic_data_set(&my_data_set);
1032
+
1033
+ /* Now lets go for the "Mask" */
1034
+ read_generic_data_set(&my_data_set,infile);
1035
+ if (rm_mask){
1036
+ read_generic_data_set_rows(&my_data_set,infile);
1037
+ for (i=0; i < my_data_set.nrows; i++){
1038
+ cur_x = ((short *)my_data_set.Data[0])[i];
1039
+ cur_y = ((short *)my_data_set.Data[1])[i];
1040
+ cur_index = (int)cur_x + nrows*(int)cur_y;
1041
+ intensity[chip_num*rows + cur_index] = R_NaN;
1042
+ }
1043
+ }
1044
+ Free_generic_data_set(&my_data_set);
1045
+ Free_generic_data_header(&my_data_header);
1046
+ Free_generic_data_group(&my_data_group);
1047
+
1048
+ fclose(infile);
1049
+
1050
+ }
1051
+
1052
+ /*******************************************************************************************************
1053
+ *******************************************************************************************************
1054
+ **
1055
+ ** Code below supports gzipped command console format CEL files
1056
+ **
1057
+ *******************************************************************************************************
1058
+ *******************************************************************************************************/
1059
+
1060
+
1061
+ int isgzGenericCelFile(const char *filename){
1062
+
1063
+ gzFile *infile;
1064
+ generic_file_header file_header;
1065
+ generic_data_header data_header;
1066
+
1067
+ if ((infile = gzopen(filename, "rb")) == NULL)
1068
+ {
1069
+ error("Unable to open the file %s",filename);
1070
+ return 0;
1071
+ }
1072
+
1073
+ if (!gzread_generic_file_header(&file_header,infile)){
1074
+ gzclose(infile);
1075
+ return 0;
1076
+ }
1077
+
1078
+ if (!gzread_generic_data_header(&data_header,infile)){
1079
+ Free_generic_data_header(&data_header);
1080
+ gzclose(infile);
1081
+ return 0;
1082
+ }
1083
+
1084
+ if (strcmp(data_header.data_type_id.value, "affymetrix-calvin-intensity") !=0){
1085
+ Free_generic_data_header(&data_header);
1086
+
1087
+
1088
+
1089
+ gzclose(infile);
1090
+ return 0;
1091
+ }
1092
+ Free_generic_data_header(&data_header);
1093
+
1094
+ gzclose(infile);
1095
+ return 1;
1096
+ }
1097
+
1098
+
1099
+
1100
+ char *gzgeneric_get_header_info(const char *filename, int *dim1, int *dim2){
1101
+
1102
+ gzFile *infile;
1103
+ generic_file_header file_header;
1104
+ generic_data_header data_header;
1105
+
1106
+ char *cdfName = 0;
1107
+
1108
+ nvt_triplet *triplet;
1109
+ AffyMIMEtypes cur_mime_type;
1110
+
1111
+ int size;
1112
+
1113
+ wchar_t *wchartemp=0;
1114
+
1115
+ if ((infile = gzopen(filename, "rb")) == NULL)
1116
+ {
1117
+ error("Unable to open the file %s",filename);
1118
+ return 0;
1119
+ }
1120
+
1121
+ gzread_generic_file_header(&file_header,infile);
1122
+ gzread_generic_data_header(&data_header,infile);
1123
+
1124
+ /* affymetrix-array-type text/plainText/plain String is HG-U133_Plus_2
1125
+ Now Trying it again. But using exposed function
1126
+ Its a Text/plain string value is HG-U133_Plus_2 with size 14
1127
+ affymetrix-cel-cols text/x-calvin-integer-32Its a int32_t value is 1164
1128
+ Now Trying it again. But using exposed function
1129
+ Its a int32_t value is 1164
1130
+ affymetrix-cel-rows text/x-calvin-integer-32Its a int32_t value is 1164
1131
+ */
1132
+
1133
+ triplet = find_nvt(&data_header,"affymetrix-array-type");
1134
+
1135
+ cur_mime_type = determine_MIMETYPE(*triplet);
1136
+
1137
+ wchartemp = decode_MIME_value(*triplet,cur_mime_type, wchartemp, &size);
1138
+ cdfName = Calloc(size + 1, char);
1139
+ wcstombs(cdfName, wchartemp, size);
1140
+ Free(wchartemp);
1141
+
1142
+ triplet = find_nvt(&data_header,"affymetrix-cel-cols");
1143
+ cur_mime_type = determine_MIMETYPE(*triplet);
1144
+ decode_MIME_value(*triplet,cur_mime_type, dim1, &size);
1145
+
1146
+ triplet = find_nvt(&data_header,"affymetrix-cel-rows");
1147
+ cur_mime_type = determine_MIMETYPE(*triplet);
1148
+ decode_MIME_value(*triplet,cur_mime_type, dim2, &size);
1149
+
1150
+ Free_generic_data_header(&data_header);
1151
+ gzclose(infile);
1152
+
1153
+ return cdfName;
1154
+
1155
+ }
1156
+
1157
+
1158
+
1159
+
1160
+ void gzgeneric_get_detailed_header_info(const char *filename, detailed_header_info *header_info){
1161
+
1162
+ gzFile *infile;
1163
+ generic_file_header file_header;
1164
+ generic_data_header data_header;
1165
+ nvt_triplet *triplet;
1166
+ AffyMIMEtypes cur_mime_type;
1167
+ int size;
1168
+
1169
+ int algorithm_paramsize = 0;
1170
+ float tempfloat;
1171
+
1172
+ wchar_t *wchartemp = 0;
1173
+ char *chartemp = 0;
1174
+
1175
+ if ((infile = gzopen(filename, "rb")) == NULL)
1176
+ {
1177
+ error("Unable to open the file %s",filename);
1178
+ }
1179
+
1180
+ gzread_generic_file_header(&file_header,infile);
1181
+ gzread_generic_data_header(&data_header,infile);
1182
+
1183
+ triplet = find_nvt(&data_header,"affymetrix-array-type");
1184
+
1185
+ cur_mime_type = determine_MIMETYPE(*triplet);
1186
+
1187
+ wchartemp = decode_MIME_value(*triplet,cur_mime_type, wchartemp, &size);
1188
+ header_info->cdfName = Calloc(size + 1, char);
1189
+ wcstombs(header_info->cdfName, wchartemp, size);
1190
+ Free(wchartemp);
1191
+
1192
+ triplet = find_nvt(&data_header,"affymetrix-cel-cols");
1193
+ cur_mime_type = determine_MIMETYPE(*triplet);
1194
+ decode_MIME_value(*triplet,cur_mime_type, &(header_info->cols), &size);
1195
+
1196
+ triplet = find_nvt(&data_header,"affymetrix-cel-rows");
1197
+ cur_mime_type = determine_MIMETYPE(*triplet);
1198
+ decode_MIME_value(*triplet,cur_mime_type, &(header_info->rows), &size);
1199
+
1200
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-GridULX");
1201
+ cur_mime_type = determine_MIMETYPE(*triplet);
1202
+ decode_MIME_value(*triplet,cur_mime_type, &tempfloat, &size);
1203
+ header_info->GridCornerULx = (int)(tempfloat +0.5);
1204
+
1205
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-GridULY");
1206
+ cur_mime_type = determine_MIMETYPE(*triplet);
1207
+ decode_MIME_value(*triplet,cur_mime_type, &tempfloat, &size);
1208
+ header_info->GridCornerULy = (int)(tempfloat +0.5);
1209
+
1210
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-GridURX");
1211
+ cur_mime_type = determine_MIMETYPE(*triplet);
1212
+ decode_MIME_value(*triplet,cur_mime_type, &tempfloat, &size);
1213
+ header_info->GridCornerURx = (int)(tempfloat +0.5);
1214
+
1215
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-GridURY");
1216
+ cur_mime_type = determine_MIMETYPE(*triplet);
1217
+ decode_MIME_value(*triplet,cur_mime_type, &tempfloat, &size);
1218
+ header_info->GridCornerURy = (int)(tempfloat +0.5);
1219
+
1220
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-GridLLX");
1221
+ cur_mime_type = determine_MIMETYPE(*triplet);
1222
+ decode_MIME_value(*triplet,cur_mime_type, &tempfloat, &size);
1223
+ header_info->GridCornerLLx = (int)(tempfloat +0.5);
1224
+
1225
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-GridLLY");
1226
+ cur_mime_type = determine_MIMETYPE(*triplet);
1227
+ decode_MIME_value(*triplet,cur_mime_type, &tempfloat, &size);
1228
+ header_info->GridCornerLLy = (int)(tempfloat +0.5);
1229
+
1230
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-GridLRX");
1231
+ cur_mime_type = determine_MIMETYPE(*triplet);
1232
+ decode_MIME_value(*triplet,cur_mime_type, &tempfloat, &size);
1233
+ header_info->GridCornerLRx = (int)(tempfloat +0.5);
1234
+
1235
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-GridLRY");
1236
+ cur_mime_type = determine_MIMETYPE(*triplet);
1237
+ decode_MIME_value(*triplet,cur_mime_type, &tempfloat, &size);
1238
+ header_info->GridCornerLRy = (int)(tempfloat +0.5);
1239
+
1240
+
1241
+ triplet = find_nvt(&data_header,"affymetrix-dat-header");
1242
+ if (triplet != NULL){
1243
+ cur_mime_type = determine_MIMETYPE(*triplet);
1244
+
1245
+ wchartemp = decode_MIME_value(*triplet,cur_mime_type, wchartemp, &size);
1246
+ header_info->DatHeader = Calloc(size + 1, char);
1247
+ wcstombs(header_info->DatHeader, wchartemp, size);
1248
+ Free(wchartemp);
1249
+ } else {
1250
+ header_info->DatHeader = Calloc(2, char);
1251
+ }
1252
+
1253
+ triplet = find_nvt(&data_header,"affymetrix-scan-date");
1254
+
1255
+ if (triplet != NULL){
1256
+ cur_mime_type = determine_MIMETYPE(*triplet);
1257
+
1258
+ wchartemp = decode_MIME_value(*triplet,cur_mime_type, wchartemp, &size);
1259
+ header_info->ScanDate = Calloc(size + 1, char);
1260
+ wcstombs(header_info->ScanDate, wchartemp, size);
1261
+ Free(wchartemp);
1262
+ } else {
1263
+ header_info->ScanDate = Calloc(2, char);
1264
+ }
1265
+
1266
+
1267
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-name");
1268
+ cur_mime_type = determine_MIMETYPE(*triplet);
1269
+
1270
+ wchartemp = decode_MIME_value(*triplet,cur_mime_type, wchartemp, &size);
1271
+ header_info->Algorithm = Calloc(size + 1, char);
1272
+ wcstombs(header_info->Algorithm, wchartemp, size);
1273
+ Free(wchartemp);
1274
+
1275
+
1276
+
1277
+ // "Percentile:75;CellMargin:2;OutlierHigh:1.500;OutlierLow:1.004;AlgVersion:6.0;FixedCellSize:TRUE;FullFeatureWidth:7;FullFeatureHeight:7;IgnoreOutliersInShiftRows:FALSE;FeatureExtraction:TRUE;PoolWidthExtenstion:2;PoolHeightExtension:2;UseSubgrids:FALSE;RandomizePixels:FALSE;ErrorBasis:StdvMean;StdMult:1.00000"
1278
+
1279
+ algorithm_paramsize = 0;
1280
+
1281
+ header_info->AlgorithmParameters = Calloc(11, char);
1282
+ strncpy(header_info->AlgorithmParameters,"Percentile:",11);
1283
+ algorithm_paramsize+=11;
1284
+
1285
+
1286
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-Percentile");
1287
+ if (triplet != NULL){
1288
+ cur_mime_type = determine_MIMETYPE(*triplet);
1289
+
1290
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
1291
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
1292
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
1293
+ algorithm_paramsize+= size +1;
1294
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1295
+ Free(chartemp);
1296
+ } else {
1297
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1298
+ algorithm_paramsize+= 1;
1299
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1300
+ }
1301
+
1302
+
1303
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 11, char);
1304
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"CellMargin:",11);
1305
+ algorithm_paramsize+=11;
1306
+
1307
+
1308
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-CellMargin");
1309
+ if (triplet != NULL){
1310
+ cur_mime_type = determine_MIMETYPE(*triplet);
1311
+
1312
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
1313
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
1314
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
1315
+ algorithm_paramsize+= size +1;
1316
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1317
+ Free(chartemp);
1318
+ } else {
1319
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1320
+ algorithm_paramsize+= 1;
1321
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1322
+ }
1323
+
1324
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 12, char);
1325
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"OutlierHigh:",12);
1326
+ algorithm_paramsize+=12;
1327
+
1328
+
1329
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-OutlierHigh");
1330
+ if (triplet != NULL){
1331
+ cur_mime_type = determine_MIMETYPE(*triplet);
1332
+
1333
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
1334
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
1335
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
1336
+ algorithm_paramsize+= size +1;
1337
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1338
+ Free(chartemp);
1339
+ } else {
1340
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1341
+ algorithm_paramsize+= 1;
1342
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1343
+ }
1344
+
1345
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 11, char);
1346
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"OutlierLow:",11);
1347
+ algorithm_paramsize+=11;
1348
+
1349
+
1350
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-OutlierLow");
1351
+ if (triplet != NULL){
1352
+ cur_mime_type = determine_MIMETYPE(*triplet);
1353
+
1354
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
1355
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
1356
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
1357
+ algorithm_paramsize+= size +1;
1358
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1359
+ Free(chartemp);
1360
+ } else {
1361
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1362
+ algorithm_paramsize+= 1;
1363
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1364
+ }
1365
+
1366
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 11, char);
1367
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"AlgVersion:",11);
1368
+ algorithm_paramsize+=11;
1369
+
1370
+
1371
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-AlgVersion");
1372
+ if (triplet != NULL){
1373
+ cur_mime_type = determine_MIMETYPE(*triplet);
1374
+
1375
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
1376
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
1377
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
1378
+ algorithm_paramsize+= size +1;
1379
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1380
+ Free(chartemp);
1381
+ } else {
1382
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1383
+ algorithm_paramsize+= 1;
1384
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1385
+ }
1386
+
1387
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 14, char);
1388
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"FixedCellSize:",14);
1389
+ algorithm_paramsize+=14;
1390
+
1391
+
1392
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-FixedCellSize");
1393
+ if (triplet != NULL){
1394
+ cur_mime_type = determine_MIMETYPE(*triplet);
1395
+
1396
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
1397
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
1398
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
1399
+ algorithm_paramsize+= size +1;
1400
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1401
+ Free(chartemp);
1402
+ } else {
1403
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1404
+ algorithm_paramsize+= 1;
1405
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1406
+ }
1407
+
1408
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 17, char);
1409
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"FullFeatureWidth:",17);
1410
+ algorithm_paramsize+=17;
1411
+
1412
+
1413
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-FullFeatureWidth");
1414
+ if (triplet != NULL){
1415
+ cur_mime_type = determine_MIMETYPE(*triplet);
1416
+
1417
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
1418
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
1419
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
1420
+ algorithm_paramsize+= size +1;
1421
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1422
+ Free(chartemp);
1423
+ } else {
1424
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1425
+ algorithm_paramsize+= 1;
1426
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1427
+ }
1428
+
1429
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 18, char);
1430
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"FullFeatureHeight:",18);
1431
+ algorithm_paramsize+=18;
1432
+
1433
+
1434
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-FullFeatureHeight");
1435
+ if (triplet != NULL){
1436
+ cur_mime_type = determine_MIMETYPE(*triplet);
1437
+
1438
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
1439
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
1440
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
1441
+ algorithm_paramsize+= size +1;
1442
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1443
+ Free(chartemp);
1444
+ } else {
1445
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1446
+ algorithm_paramsize+= 1;
1447
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1448
+ }
1449
+
1450
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 26, char);
1451
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"IgnoreOutliersInShiftRows:",26);
1452
+ algorithm_paramsize+=26;
1453
+
1454
+
1455
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-IgnoreOutliersInShiftRows");
1456
+ if (triplet != NULL){
1457
+ cur_mime_type = determine_MIMETYPE(*triplet);
1458
+
1459
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
1460
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
1461
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
1462
+ algorithm_paramsize+= size +1;
1463
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1464
+ Free(chartemp);
1465
+ } else {
1466
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1467
+ algorithm_paramsize+= 1;
1468
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1469
+ }
1470
+
1471
+
1472
+
1473
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 18, char);
1474
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"FeatureExtraction:",18);
1475
+ algorithm_paramsize+=18;
1476
+
1477
+
1478
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-FeatureExtraction");
1479
+ if (triplet != NULL){
1480
+ cur_mime_type = determine_MIMETYPE(*triplet);
1481
+
1482
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
1483
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
1484
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
1485
+ algorithm_paramsize+= size +1;
1486
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1487
+ Free(chartemp);
1488
+ } else {
1489
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1490
+ algorithm_paramsize+= 1;
1491
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1492
+ }
1493
+
1494
+
1495
+
1496
+
1497
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 20, char);
1498
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"PoolWidthExtenstion:",20);
1499
+ algorithm_paramsize+=20;
1500
+
1501
+
1502
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-PoolWidthExtenstion");
1503
+ if (triplet != NULL){
1504
+ cur_mime_type = determine_MIMETYPE(*triplet);
1505
+
1506
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
1507
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
1508
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
1509
+ algorithm_paramsize+= size +1;
1510
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1511
+ Free(chartemp);
1512
+ } else {
1513
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1514
+ algorithm_paramsize+= 1;
1515
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1516
+ }
1517
+
1518
+
1519
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 20, char);
1520
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"PoolHeightExtension:",20);
1521
+ algorithm_paramsize+=20;
1522
+
1523
+
1524
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-PoolHeightExtension");
1525
+ if (triplet != NULL){
1526
+ cur_mime_type = determine_MIMETYPE(*triplet);
1527
+
1528
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
1529
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
1530
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
1531
+ algorithm_paramsize+= size +1;
1532
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1533
+ Free(chartemp);
1534
+ } else {
1535
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1536
+ algorithm_paramsize+= 1;
1537
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1538
+ }
1539
+
1540
+
1541
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 12, char);
1542
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"UseSubgrids:",12);
1543
+ algorithm_paramsize+=12;
1544
+
1545
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-UseSubgrids");
1546
+ if (triplet != NULL){
1547
+ cur_mime_type = determine_MIMETYPE(*triplet);
1548
+
1549
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
1550
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
1551
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
1552
+ algorithm_paramsize+= size +1;
1553
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1554
+ Free(chartemp);
1555
+ } else {
1556
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1557
+ algorithm_paramsize+= 1;
1558
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1559
+ }
1560
+
1561
+
1562
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 16, char);
1563
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"RandomizePixels:",16);
1564
+ algorithm_paramsize+=16;
1565
+
1566
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-RandomizePixels");
1567
+ if (triplet != NULL){
1568
+ cur_mime_type = determine_MIMETYPE(*triplet);
1569
+
1570
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
1571
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
1572
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
1573
+ algorithm_paramsize+= size +1;
1574
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1575
+ Free(chartemp);
1576
+ } else {
1577
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1578
+ algorithm_paramsize+= 1;
1579
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1580
+ }
1581
+
1582
+
1583
+
1584
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 11, char);
1585
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"ErrorBasis:",11);
1586
+ algorithm_paramsize+=11;
1587
+
1588
+
1589
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-ErrorBasis");
1590
+ if (triplet != NULL){
1591
+ cur_mime_type = determine_MIMETYPE(*triplet);
1592
+
1593
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
1594
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
1595
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
1596
+ algorithm_paramsize+= size +1;
1597
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1598
+ Free(chartemp);
1599
+ } else {
1600
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1601
+ algorithm_paramsize+= 1;
1602
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1603
+ }
1604
+
1605
+
1606
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 8, char);
1607
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize],"StdMult:",8);
1608
+ algorithm_paramsize+=8;
1609
+
1610
+
1611
+ triplet = find_nvt(&data_header,"affymetrix-algorithm-param-StdMult");
1612
+ if (triplet != NULL){
1613
+ cur_mime_type = determine_MIMETYPE(*triplet);
1614
+
1615
+ chartemp = decode_MIME_value_toASCII(*triplet,cur_mime_type, chartemp, &size);
1616
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + size +1, char);
1617
+ strncpy(&header_info->AlgorithmParameters[algorithm_paramsize], chartemp, size);
1618
+ algorithm_paramsize+= size +1;
1619
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1620
+ Free(chartemp);
1621
+ } else {
1622
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1623
+ algorithm_paramsize+= 1;
1624
+ header_info->AlgorithmParameters[algorithm_paramsize-1]=';';
1625
+ }
1626
+
1627
+
1628
+
1629
+ header_info->AlgorithmParameters = Realloc(header_info->AlgorithmParameters, algorithm_paramsize + 1, char);
1630
+ header_info->AlgorithmParameters[algorithm_paramsize] ='\0';
1631
+
1632
+ Free_generic_data_header(&data_header);
1633
+ gzclose(infile);
1634
+ }
1635
+
1636
+
1637
+
1638
+
1639
+
1640
+
1641
+
1642
+
1643
+ int check_gzgeneric_cel_file(const char *filename, const char *ref_cdfName, int ref_dim_1, int ref_dim_2){
1644
+
1645
+ char *cdfName =0;
1646
+ int dim1, dim2;
1647
+
1648
+
1649
+ gzFile *infile;
1650
+ generic_file_header file_header;
1651
+ generic_data_header data_header;
1652
+
1653
+ nvt_triplet *triplet;
1654
+ AffyMIMEtypes cur_mime_type;
1655
+
1656
+ int size;
1657
+
1658
+ wchar_t *wchartemp=0;
1659
+
1660
+
1661
+ if ((infile = gzopen(filename, "rb")) == NULL)
1662
+ {
1663
+ error("Unable to open the file %s",filename);
1664
+ return 0;
1665
+ }
1666
+
1667
+ gzread_generic_file_header(&file_header,infile);
1668
+ gzread_generic_data_header(&data_header,infile);
1669
+
1670
+
1671
+ triplet = find_nvt(&data_header,"affymetrix-array-type");
1672
+
1673
+ cur_mime_type = determine_MIMETYPE(*triplet);
1674
+
1675
+ wchartemp = decode_MIME_value(*triplet,cur_mime_type, wchartemp, &size);
1676
+ cdfName = Calloc(size + 1, char);
1677
+ wcstombs(cdfName, wchartemp, size);
1678
+ Free(wchartemp);
1679
+
1680
+ triplet = find_nvt(&data_header,"affymetrix-cel-cols");
1681
+ cur_mime_type = determine_MIMETYPE(*triplet);
1682
+ decode_MIME_value(*triplet,cur_mime_type, &dim1, &size);
1683
+
1684
+ triplet = find_nvt(&data_header,"affymetrix-cel-rows");
1685
+ cur_mime_type = determine_MIMETYPE(*triplet);
1686
+ decode_MIME_value(*triplet,cur_mime_type, &dim2, &size);
1687
+
1688
+ Free_generic_data_header(&data_header);
1689
+
1690
+ if ((dim1 != ref_dim_1) || (dim2 != ref_dim_2)){
1691
+ error("Cel file %s does not seem to have the correct dimensions",filename);
1692
+ }
1693
+
1694
+ if (strncasecmp(cdfName,ref_cdfName,strlen(ref_cdfName)) != 0){
1695
+ error("Cel file %s does not seem to be of %s type",filename,ref_cdfName);
1696
+ }
1697
+
1698
+ Free(cdfName);
1699
+
1700
+
1701
+ gzclose(infile);
1702
+ return 0;
1703
+ }
1704
+
1705
+
1706
+
1707
+
1708
+
1709
+
1710
+ int gzread_genericcel_file_intensities(const char *filename, double *intensity, int chip_num, int rows, int cols,int chip_dim_rows){
1711
+
1712
+ int i=0, j=0;
1713
+ int cur_index;
1714
+
1715
+ int fread_err=0;
1716
+
1717
+ gzFile *infile;
1718
+
1719
+ generic_file_header my_header;
1720
+ generic_data_header my_data_header;
1721
+ generic_data_group my_data_group;
1722
+
1723
+ generic_data_set my_data_set;
1724
+
1725
+
1726
+ if ((infile = gzopen(filename, "rb")) == NULL)
1727
+ {
1728
+ error("Unable to open the file %s\n",filename);
1729
+ return 0;
1730
+ }
1731
+
1732
+
1733
+
1734
+ gzread_generic_file_header(&my_header, infile);
1735
+ gzread_generic_data_header(&my_data_header, infile);
1736
+ gzread_generic_data_group(&my_data_group,infile);
1737
+
1738
+ gzread_generic_data_set(&my_data_set,infile);
1739
+ gzread_generic_data_set_rows(&my_data_set,infile);
1740
+
1741
+ for (i =0; i < my_data_set.nrows; i++){
1742
+ intensity[chip_num*my_data_set.nrows + i] = (double)(((float *)my_data_set.Data[0])[i]);
1743
+ }
1744
+
1745
+ gzclose(infile);
1746
+ Free_generic_data_set(&my_data_set);
1747
+ Free_generic_data_header(&my_data_header);
1748
+ Free_generic_data_group(&my_data_group);
1749
+
1750
+
1751
+
1752
+
1753
+ return(0);
1754
+ }
1755
+
1756
+
1757
+
1758
+
1759
+
1760
+
1761
+ int gzread_genericcel_file_stddev(const char *filename, double *intensity, int chip_num, int rows, int cols,int chip_dim_rows){
1762
+
1763
+ int i=0, j=0;
1764
+ int cur_index;
1765
+
1766
+ int fread_err=0;
1767
+
1768
+ gzFile *infile;
1769
+
1770
+ generic_file_header my_header;
1771
+ generic_data_header my_data_header;
1772
+ generic_data_group my_data_group;
1773
+
1774
+ generic_data_set my_data_set;
1775
+
1776
+
1777
+ if ((infile = gzopen(filename, "rb")) == NULL)
1778
+ {
1779
+ error("Unable to open the file %s\n",filename);
1780
+ return 0;
1781
+ }
1782
+
1783
+
1784
+
1785
+ gzread_generic_file_header(&my_header, infile);
1786
+ gzread_generic_data_header(&my_data_header, infile);
1787
+ gzread_generic_data_group(&my_data_group,infile);
1788
+
1789
+ gzread_generic_data_set(&my_data_set,infile);
1790
+ gzseek(infile, my_data_set.file_pos_last, SEEK_SET);
1791
+ Free_generic_data_set(&my_data_set);
1792
+
1793
+ gzread_generic_data_set(&my_data_set,infile);
1794
+ gzread_generic_data_set_rows(&my_data_set,infile);
1795
+ for (i =0; i < my_data_set.nrows; i++){
1796
+ intensity[chip_num*my_data_set.nrows + i] = (double)(((float *)my_data_set.Data[0])[i]);
1797
+ }
1798
+ Free_generic_data_set(&my_data_set);
1799
+ Free_generic_data_header(&my_data_header);
1800
+ Free_generic_data_group(&my_data_group);
1801
+
1802
+ gzclose(infile);
1803
+
1804
+
1805
+ return(0);
1806
+
1807
+
1808
+
1809
+
1810
+
1811
+ }
1812
+
1813
+
1814
+
1815
+ int gzread_genericcel_file_npixels(const char *filename, double *intensity, int chip_num, int rows, int cols,int chip_dim_rows){
1816
+
1817
+ int i=0, j=0;
1818
+ int cur_index;
1819
+
1820
+ int fread_err=0;
1821
+
1822
+ gzFile *infile;
1823
+
1824
+ generic_file_header my_header;
1825
+ generic_data_header my_data_header;
1826
+ generic_data_group my_data_group;
1827
+
1828
+ generic_data_set my_data_set;
1829
+
1830
+
1831
+ if ((infile = gzopen(filename, "rb")) == NULL)
1832
+ {
1833
+ error("Unable to open the file %s\n",filename);
1834
+ return 0;
1835
+ }
1836
+
1837
+
1838
+
1839
+ gzread_generic_file_header(&my_header, infile);
1840
+ gzread_generic_data_header(&my_data_header, infile);
1841
+ gzread_generic_data_group(&my_data_group,infile);
1842
+
1843
+ gzread_generic_data_set(&my_data_set,infile);
1844
+ gzseek(infile, my_data_set.file_pos_last, SEEK_SET);
1845
+ Free_generic_data_set(&my_data_set);
1846
+
1847
+ gzread_generic_data_set(&my_data_set,infile);
1848
+ gzseek(infile, my_data_set.file_pos_last, SEEK_SET);
1849
+ Free_generic_data_set(&my_data_set);
1850
+
1851
+
1852
+ gzread_generic_data_set(&my_data_set,infile);
1853
+ gzread_generic_data_set_rows(&my_data_set,infile);
1854
+ for (i =0; i < my_data_set.nrows; i++){
1855
+ intensity[chip_num*my_data_set.nrows + i] = (double)(((short *)my_data_set.Data[0])[i]);
1856
+ }
1857
+ Free_generic_data_set(&my_data_set);
1858
+ Free_generic_data_header(&my_data_header);
1859
+ Free_generic_data_group(&my_data_group);
1860
+
1861
+ gzclose(infile);
1862
+
1863
+
1864
+ return(0);
1865
+
1866
+
1867
+
1868
+
1869
+ }
1870
+
1871
+
1872
+
1873
+
1874
+
1875
+
1876
+
1877
+ void gzgeneric_get_masks_outliers(const char *filename, int *nmasks, short **masks_x, short **masks_y, int *noutliers, short **outliers_x, short **outliers_y){
1878
+
1879
+
1880
+
1881
+
1882
+ int i=0, j=0;
1883
+ int cur_index;
1884
+
1885
+ int fread_err=0;
1886
+
1887
+ gzFile *infile;
1888
+
1889
+ generic_file_header my_header;
1890
+ generic_data_header my_data_header;
1891
+ generic_data_group my_data_group;
1892
+
1893
+ generic_data_set my_data_set;
1894
+
1895
+
1896
+ if ((infile = gzopen(filename, "rb")) == NULL)
1897
+ {
1898
+ error("Unable to open the file %s\n",filename);
1899
+
1900
+ }
1901
+
1902
+
1903
+
1904
+ gzread_generic_file_header(&my_header, infile);
1905
+ gzread_generic_data_header(&my_data_header, infile);
1906
+ gzread_generic_data_group(&my_data_group,infile);
1907
+
1908
+ /* passing the intensities */
1909
+ gzread_generic_data_set(&my_data_set,infile);
1910
+ gzseek(infile, my_data_set.file_pos_last, SEEK_SET);
1911
+ Free_generic_data_set(&my_data_set);
1912
+
1913
+ /* passing by the stddev */
1914
+ gzread_generic_data_set(&my_data_set,infile);
1915
+ gzseek(infile, my_data_set.file_pos_last, SEEK_SET);
1916
+ Free_generic_data_set(&my_data_set);
1917
+
1918
+ /* passing by the npixels */
1919
+ gzread_generic_data_set(&my_data_set,infile);
1920
+ gzseek(infile, my_data_set.file_pos_last, SEEK_SET);
1921
+ Free_generic_data_set(&my_data_set);
1922
+
1923
+ /* Now lets go for the "Outlier" */
1924
+ gzread_generic_data_set(&my_data_set,infile);
1925
+
1926
+
1927
+ *noutliers = my_data_set.nrows;
1928
+
1929
+ *outliers_x = Calloc(my_data_set.nrows,short);
1930
+ *outliers_y = Calloc(my_data_set.nrows,short);
1931
+
1932
+ gzread_generic_data_set_rows(&my_data_set,infile);
1933
+
1934
+ for (i=0; i < my_data_set.nrows; i++){
1935
+ (*outliers_x)[i] = ((short *)my_data_set.Data[0])[i];
1936
+ (*outliers_y)[i] = ((short *)my_data_set.Data[1])[i];
1937
+ }
1938
+
1939
+ gzseek(infile, my_data_set.file_pos_last, SEEK_SET);
1940
+ Free_generic_data_set(&my_data_set);
1941
+
1942
+ /* Now lets go for the "Mask" */
1943
+ gzread_generic_data_set(&my_data_set,infile);
1944
+
1945
+ *nmasks = my_data_set.nrows;
1946
+
1947
+ *masks_x = Calloc(my_data_set.nrows,short);
1948
+ *masks_y = Calloc(my_data_set.nrows,short);
1949
+
1950
+
1951
+ gzread_generic_data_set_rows(&my_data_set,infile);
1952
+ for (i=0; i < my_data_set.nrows; i++){
1953
+ (*outliers_x)[i] = ((short *)my_data_set.Data[0])[i];
1954
+ (*outliers_y)[i] = ((short *)my_data_set.Data[1])[i];
1955
+ }
1956
+ Free_generic_data_set(&my_data_set);
1957
+ Free_generic_data_header(&my_data_header);
1958
+ Free_generic_data_group(&my_data_group);
1959
+
1960
+ gzclose(infile);
1961
+
1962
+ }
1963
+
1964
+
1965
+
1966
+
1967
+
1968
+ void gzgeneric_apply_masks(const char *filename, double *intensity, int chip_num, int rows, int cols,int chip_dim_rows, int rm_mask, int rm_outliers){
1969
+
1970
+
1971
+ int i=0, j=0;
1972
+ int cur_index;
1973
+
1974
+ short cur_x, cur_y;
1975
+
1976
+
1977
+ int fread_err=0;
1978
+ int nrows;
1979
+ int size;
1980
+
1981
+ gzFile *infile;
1982
+
1983
+ generic_file_header my_header;
1984
+ generic_data_header my_data_header;
1985
+ generic_data_group my_data_group;
1986
+
1987
+ generic_data_set my_data_set;
1988
+ nvt_triplet *triplet;
1989
+ AffyMIMEtypes cur_mime_type;
1990
+
1991
+ if ((infile = gzopen(filename, "rb")) == NULL)
1992
+ {
1993
+ error("Unable to open the file %s\n",filename);
1994
+
1995
+ }
1996
+
1997
+
1998
+
1999
+ gzread_generic_file_header(&my_header, infile);
2000
+ gzread_generic_data_header(&my_data_header, infile);
2001
+ gzread_generic_data_group(&my_data_group,infile);
2002
+
2003
+
2004
+ triplet = find_nvt(&my_data_header,"affymetrix-cel-rows");
2005
+ cur_mime_type = determine_MIMETYPE(*triplet);
2006
+ decode_MIME_value(*triplet,cur_mime_type, &nrows, &size);
2007
+
2008
+
2009
+
2010
+ /* passing the intensities */
2011
+ gzread_generic_data_set(&my_data_set,infile);
2012
+ gzseek(infile, my_data_set.file_pos_last, SEEK_SET);
2013
+ Free_generic_data_set(&my_data_set);
2014
+
2015
+ /* passing by the stddev */
2016
+ gzread_generic_data_set(&my_data_set,infile);
2017
+ gzseek(infile, my_data_set.file_pos_last, SEEK_SET);
2018
+ Free_generic_data_set(&my_data_set);
2019
+
2020
+ /* passing by the npixels */
2021
+ gzread_generic_data_set(&my_data_set,infile);
2022
+ gzseek(infile, my_data_set.file_pos_last, SEEK_SET);
2023
+ Free_generic_data_set(&my_data_set);
2024
+
2025
+ /* Now lets go for the "Outlier" */
2026
+ gzread_generic_data_set(&my_data_set,infile);
2027
+
2028
+ if (rm_outliers){
2029
+ gzread_generic_data_set_rows(&my_data_set,infile);
2030
+ for (i=0; i < my_data_set.nrows; i++){
2031
+ cur_x = ((short *)my_data_set.Data[0])[i];
2032
+ cur_y = ((short *)my_data_set.Data[1])[i];
2033
+ cur_index = (int)cur_x + nrows*(int)cur_y;
2034
+ intensity[chip_num*rows + cur_index] = R_NaN;
2035
+ }
2036
+ }
2037
+
2038
+ gzseek(infile, my_data_set.file_pos_last, SEEK_SET);
2039
+ Free_generic_data_set(&my_data_set);
2040
+
2041
+ /* Now lets go for the "Mask" */
2042
+ gzread_generic_data_set(&my_data_set,infile);
2043
+ if (rm_mask){
2044
+ gzread_generic_data_set_rows(&my_data_set,infile);
2045
+ for (i=0; i < my_data_set.nrows; i++){
2046
+ cur_x = ((short *)my_data_set.Data[0])[i];
2047
+ cur_y = ((short *)my_data_set.Data[1])[i];
2048
+ cur_index = (int)cur_x + nrows*(int)cur_y;
2049
+ intensity[chip_num*rows + cur_index] = R_NaN;
2050
+ }
2051
+ }
2052
+ Free_generic_data_set(&my_data_set);
2053
+ Free_generic_data_header(&my_data_header);
2054
+ Free_generic_data_group(&my_data_group);
2055
+
2056
+ gzclose(infile);
2057
+
2058
+ }
2059
+
2060
+
2061
+