[ANN] basereader

Maurice LING mauriceling at acm.org
Mon Jul 12 01:33:15 CEST 2004


The following codes had been donated to the BioPython project.

--------------------
"""
A simple script to read BASE (BioArray Software Environment) non-serial 
result output file format.
Outputs five global lists: FileHead, SectionRegister, SpotSectionInfo, 
SpotRegisterInfo and SpotRegisterIntensity.
FileHead contains the first line of the file.
SectionRegister contains the 3rd line of the file to the next blank 
line. It typically contains the file information section.
SpotSectionInfo contains the next section (which is the spot section) 
after the file information section, without the actual spots data.
SpotRegisterInfo contains all the information of the spots in the file.
SpotRegisterIntensity contains only the intensity values of the spots 
(corresponding to each row on the SpotRegisterInfo).

This script is written by Maurice HT LING, The University of Melbourne, 
under the sponsorship of the Cooperative Research Centre for Innovative 
Dairy Products.
Copyright 2004 Maurice HT Ling
"""
import sys
import string

global SectionRegister
global FileHead
global SpotSectionInfo
global SpotRegisterInfo, SpotRegisterIntensity
SectionRegister = []
FileHead = []
SpotSectionInfo = []
SpotRegister = []
SpotRegisterIntensity = []

def BaseReader(file):
"""Reads the entire file and append the data into the specified lists.
	base = open(file)
	
	# reads 1st line of line (supposed to be "BASEfile") and
	# puts it in FileHead as a list
	str = base.readline()
	FileHead.append(str)
	str = base.readline()
	
	# reads 1st section (supposed to be information section),
	# until it hits a blank line
	while (str != '\n'):
		#print str
		str = string.split(str, '\t')
		SectionRegister.append(str)
		str = base.readline()
	
	# gets through the blank line
	str = base.readline()
	
	# reads information portion of 2nd section (supposed to be spots section)
	# until it hit "%"
	str = base.readline()
	while (str != '%\n'):
		str = string.split(str, '\t')
		SpotSectionInfo.append(str)
		str = base.readline()
	
	# reads spots data, puts everything into SpotRegister
	# extracts intensity values into SpotRegisterIntensity
	str = base.readline()
	while (str):
		str = string.split(str, '\t')
		SpotRegister.append(str)
		SpotRegisterIntensity.append(str[-2:])
		str = base.readline()
	
	#close the file
	base.close()

def SpotIntensityToFloat(list):
"""A method to convert the SpotRegisterIntensity list from string into 
float values.
	t = []
	for s in list:
		a = [float(s[0]), float(s[1])]
		t.append(a)
	return t
		

-- 
Maurice Han Tong LING, BSc(Hons), Adv Dip Comp
mobile: +61 4 22781753
	+65 96669233
mailing address: Department of Zoology, The University of Melbourne
		 Royal Parade, Parkville, Victoria 3010, Australia
residential address: 1/44 Gatehouse Street
	   	     Parkville, Victoria 3053, Australia
email: mauriceling at acm.org
resume: http://maurice.vodien.com/maurice_resume.pdf
www: http://www.geocities.com/beldin79/

The information contained in this message, including its attachment(s),
is CONFIDENTIAL and solely intended to its addressee(s) only. The
content of this message, including its attachment(s),  may be subjected
to copyright and privacy laws. If you have received this email in error,
please let me know by returning this email, and then destroy all copies.



More information about the Python-list mailing list