def parse_taxonomy_to_otu_metadata(lines, labels=['taxonomy', 'score'], process_fs=[taxa_split, float]):
 result = {}
 for line in lines:
  line = line.strip()
  fields = line.split(' DCTB ')
  id_ = fields[0].split()[0]
  result[id_] = {}
  for (i, field) in enumerate(fields[1:]):
   try:
    label = labels[i]
   except IndexError:
    continue
   try:
    value = process_fs[i](field)
   except IndexError:
    raise ValueError(('Too few process functions provided (n=%d).' % len(process_fs)))
   result[id_][label] = value
 return result

def parse_taxonomy_to_otu_metadata ( lines , labels = [ 'taxonomy' , 'score' ] , process_fs = [ taxa_split , float ] ) : result = { } for line in lines : line = line . strip ( ) fields = line . split ( ' DCTB ' ) id_ = fields [ 0 ] . split ( ) [ 0 ] result [ id_ ] = { } for ( i , field ) in enumerate ( fields [ 1 : ] ) : try : label = labels [ i ] except IndexError : continue try : value = process_fs [ i ] ( field ) except IndexError : raise ValueError ( ( 'Too few process functions provided (n=%d).' % len ( process_fs ) ) ) result [ id_ ] [ label ] = value return result
return a dict mapping otu identifier to dict of otu metadata lines: file handle or list of lines - format should be: otu_id <tab> metadata entry 1 <tab> metadata entry 2 <tab> .