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
18
20 """
21 Stores the information in a cel file
22 """
24 self.intensities = None
25 self.stdevs = None
26 self.npix = None
27 self.nrows = None
28 self.ncols = None
29
30
32 """
33 Read the information in a cel file, and store it in a Record.
34 """
35
36
37 record = Record()
38 section = ""
39 for line in handle:
40 if not line.strip():
41 continue
42 if line[:8] == "[HEADER]":
43 section = "HEADER"
44 elif line[:11] == "[INTENSITY]":
45 section = "INTENSITY"
46 record.intensities = numpy.zeros((record.nrows, record.ncols))
47 record.stdevs = numpy.zeros((record.nrows, record.ncols))
48 record.npix = numpy.zeros((record.nrows, record.ncols), int)
49 elif line[0] == "[":
50 section = ""
51 elif section == "HEADER":
52 keyword, value = line.split("=", 1)
53 if keyword == "Cols":
54 record.ncols = int(value)
55 elif keyword == "Rows":
56 record.nrows = int(value)
57 elif section == "INTENSITY":
58 if "=" in line:
59 continue
60 words = line.split()
61 y, x = map(int, words[:2])
62 record.intensities[x, y] = float(words[2])
63 record.stdevs[x, y] = float(words[3])
64 record.npix[x, y] = int(words[4])
65 return record
66