Trees | Indices | Help |
---|
|
1 # Copyright 2001 by Katharine Lindner. All rights reserved. 2 # Copyright 2006 by PeterC. All rights reserved. 3 # Copyright 2007 by Michiel de Hoon. All rights reserved. 4 # This code is part of the Biopython distribution and governed by its 5 # license. Please see the LICENSE file that should have been included 6 # as part of this package. 7 """Parser for files from NCBI's Gene Expression Omnibus (GEO). 8 9 http://www.ncbi.nlm.nih.gov/geo/ 10 """ 11 12 import Record 13 1416 words = line[1:].split("=", 1) 17 try: 18 key, value = words 19 value = value.strip() 20 except ValueError: 21 key = words[0] 22 value = "" 23 key = key.strip() 24 return key, value25 2628 record = None 29 for line in handle: 30 line = line.strip('\n').strip('\r') 31 if not line: continue # Ignore empty lines 32 c = line[0] 33 if c=='^': 34 if record: yield record 35 record = Record.Record() 36 record.entity_type, record.entity_id = _read_key_value(line) 37 elif c=='!': 38 if line in ('!Sample_table_begin', 39 '!Sample_table_end', 40 '!Platform_table_begin', 41 '!Platform_table_end'): 42 continue 43 key, value = _read_key_value(line) 44 if key in record.entity_attributes: 45 if type(record.entity_attributes[key])==list: 46 record.entity_attributes[key].append(value) 47 else: 48 existing = record.entity_attributes[key] 49 record.entity_attributes[key] = [existing, value] 50 else: 51 record.entity_attributes[key] = value 52 elif c=='#': 53 key, value = _read_key_value(line) 54 assert key not in record.col_defs 55 record.col_defs[key] = value 56 else: 57 row = line.split("\t") 58 record.table_rows.append(row) 59 yield record60
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Dec 25 10:43:58 2008 | http://epydoc.sourceforge.net |