Package Bio :: Package Affy :: Module CelFile
[hide private]
[frames] | no frames]

Source Code for Module Bio.Affy.CelFile

 1  # Copyright 2004 by Harry Zuzan.  All rights reserved. 
 2  # This code is part of the Biopython distribution and governed by its 
 3  # license.  Please see the LICENSE file that should have been included 
 4  # as part of this package. 
 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 -class Record(object):
19 """ 20 Stores the information in a cel file 21 """
22 - def __init__(self):
23 self.intensities = None 24 self.stdevs = None 25 self.npix = None 26 self.nrows = None 27 self.ncols = None
28 29
30 -def read(handle):
31 """ 32 Read the information in a cel file, and store it in a Record. 33 """ 34 # Needs error handling. 35 # Needs to know the chip design. 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