def add_summary_mapping(otu_table, mapping, level, md_as_string=False, md_identifier='taxonomy'):
 (counts_by_consensus, sample_map) = sum_counts_by_consensus(otu_table, level, 'Other', md_as_string, md_identifier)
 summary = defaultdict(list)
 for row in mapping:
  sample_id = row[0]
  if (sample_id not in sample_map):
   continue
  otu_idx = sample_map[sample_id]
  for (consensus, counts) in sorted(counts_by_consensus.items()):
   summary[sample_id].append(counts[otu_idx])
 taxon_order = sorted(counts_by_consensus.keys())
 return (summary, taxon_order)

def add_summary_mapping ( otu_table , mapping , level , md_as_string = False , md_identifier = 'taxonomy' ) : ( counts_by_consensus , sample_map ) = sum_counts_by_consensus ( otu_table , level , 'Other' , md_as_string , md_identifier ) summary = defaultdict ( list ) for row in mapping : sample_id = row [ 0 ] if ( sample_id not in sample_map ) : continue otu_idx = sample_map [ sample_id ] for ( consensus , counts ) in sorted ( counts_by_consensus . items ( ) ) : summary [ sample_id ] . append ( counts [ otu_idx ] ) taxon_order = sorted ( counts_by_consensus . keys ( ) ) return ( summary , taxon_order )
returns sample summary of sample counts by taxon summary is keyed by sample_id .