def make_otu_labels(otu_ids, lineages, n_levels=1):
 if (len(lineages[0]) > 0):
  otu_labels = []
  for (i, lineage) in enumerate(lineages):
   if (n_levels > len(lineage)):
    otu_label = ('%s (%s)' % (';'.join(lineage), otu_ids[i]))
   else:
    otu_label = ('%s (%s)' % (';'.join(lineage[(- n_levels):]), otu_ids[i]))
   otu_labels.append(otu_label)
  otu_labels = [lab.replace('"', '') for lab in otu_labels]
 else:
  otu_labels = otu_ids
 return otu_labels

def make_otu_labels ( otu_ids , lineages , n_levels = 1 ) : if ( len ( lineages [ 0 ] ) > 0 ) : otu_labels = [ ] for ( i , lineage ) in enumerate ( lineages ) : if ( n_levels > len ( lineage ) ) : otu_label = ( '%s (%s)' % ( ';' . join ( lineage ) , otu_ids [ i ] ) ) else : otu_label = ( '%s (%s)' % ( ';' . join ( lineage [ ( - n_levels ) : ] ) , otu_ids [ i ] ) ) otu_labels . append ( otu_label ) otu_labels = [ lab . replace ( '"' , '' ) for lab in otu_labels ] else : otu_labels = otu_ids return otu_labels
returns pretty otu labels: lineage substring lineage substring includes the last n_levels lineage levels .