1
2
3
4
5
6 """
7 Classes for accessing the information in Affymetrix cel files.
8
9 Functions:
10 read Read a cel file and store its contents in a Record
11
12 Classes:
13 Record Contains the information from a cel file
14 """
15
16 import numpy
17
19 """
20 Stores the information in a cel file
21 """
23 self.intensities = None
24 self.stdevs = None
25 self.npix = None
26 self.nrows = None
27 self.ncols = None
28
29
31 """
32 Read the information in a cel file, and store it in a Record.
33 """
34
35
36 record = Record()
37 section = ""
38 for line in handle:
39 if not line.strip():
40 continue
41 if line[:8]=="[HEADER]":
42 section = "HEADER"
43 elif line[:11]=="[INTENSITY]":
44 section = "INTENSITY"
45 record.intensities = numpy.zeros((record.nrows, record.ncols))
46 record.stdevs = numpy.zeros((record.nrows, record.ncols))
47 record.npix = numpy.zeros((record.nrows, record.ncols), int)
48 elif line[0]=="[":
49 section = ""
50 elif section=="HEADER":
51 keyword, value = line.split("=", 1)
52 if keyword=="Cols":
53 record.ncols = int(value)
54 elif keyword=="Rows":
55 record.nrows = int(value)
56 elif section=="INTENSITY":
57 if "=" in line:
58 continue
59 words = line.split()
60 y, x = map(int, words[:2])
61 record.intensities[x,y] = float(words[2])
62 record.stdevs[x,y] = float(words[3])
63 record.npix[x,y] = int(words[4])
64 return record
65