Back to index

python-biopython  1.60
Namespaces | Functions
Bio.Geo Namespace Reference

Namespaces

namespace  Record

Functions

def _read_key_value
def parse

Function Documentation

def Bio.Geo._read_key_value (   line) [private]

Definition at line 15 of file __init__.py.

00015 
00016 def _read_key_value(line):
00017     words = line[1:].split("=", 1)
00018     try:
00019         key, value = words
00020         value = value.strip()
00021     except ValueError:
00022         key = words[0]
00023         value = ""
00024     key = key.strip()
00025     return key, value
00026 

Here is the caller graph for this function:

def Bio.Geo.parse (   handle)

Definition at line 27 of file __init__.py.

00027 
00028 def parse(handle):
00029     record = None
00030     for line in handle:
00031         line = line.strip('\n').strip('\r')
00032         if not line: continue # Ignore empty lines
00033         c = line[0]
00034         if c=='^':
00035             if record: yield record
00036             record = Record.Record()
00037             record.entity_type, record.entity_id = _read_key_value(line)
00038         elif c=='!':
00039             if line in ('!Sample_table_begin',
00040                         '!Sample_table_end',
00041                         '!Platform_table_begin',
00042                         '!Platform_table_end'):
00043                 continue
00044             key, value = _read_key_value(line)
00045             if key in record.entity_attributes:
00046                 if type(record.entity_attributes[key])==list:
00047                     record.entity_attributes[key].append(value)
00048                 else:
00049                     existing = record.entity_attributes[key]
00050                     record.entity_attributes[key] = [existing, value]
00051             else:
00052                 record.entity_attributes[key] = value
00053         elif c=='#':
00054             key, value = _read_key_value(line)
00055             assert key not in record.col_defs
00056             record.col_defs[key] = value
00057         else:
00058             row = line.split("\t")
00059             record.table_rows.append(row)
00060     yield record

Here is the call graph for this function: