def sim_otu_table(sample_ids, otu_ids, samples, otu_metadata, tree, num_replicates, dissimilarity):
 sample_dicts = []
 res_sam_names = []
 for (i, sample_info) in enumerate(samples):
  sample_vector = sample_info[0]
  for j in range(num_replicates):
   sample_dict = {}
   for k in range(len(otu_ids)):
    otu_abundance = sample_vector[k]
    if (otu_abundance == 0):
     continue
    new_otu_id = get_new_otu_id(otu_ids[k], tree, dissimilarity)
    if (new_otu_id in sample_dict):
     sample_dict[new_otu_id] += otu_abundance
    else:
     sample_dict[new_otu_id] = otu_abundance
   sample_dicts.append(sample_dict)
   res_sam_names.append(((sample_ids[i] + '.') + str(j)))
 (res_otu_mtx, res_otus) = combine_sample_dicts(sample_dicts)
 res_otu_metadata = []
 if ((otu_metadata is None) or (otu_metadata == [])):
  res_otu_metadata = None
 else:
  for otu_id in res_otus:
   try:
    res_otu_metadata.append(otu_metadata[otu_ids.index(otu_id)])
   except ValueError:
    res_otu_metadata.append(None)
 return (res_sam_names, res_otus, res_otu_mtx, res_otu_metadata)

def sim_otu_table ( sample_ids , otu_ids , samples , otu_metadata , tree , num_replicates , dissimilarity ) : sample_dicts = [ ] res_sam_names = [ ] for ( i , sample_info ) in enumerate ( samples ) : sample_vector = sample_info [ 0 ] for j in range ( num_replicates ) : sample_dict = { } for k in range ( len ( otu_ids ) ) : otu_abundance = sample_vector [ k ] if ( otu_abundance == 0 ) : continue new_otu_id = get_new_otu_id ( otu_ids [ k ] , tree , dissimilarity ) if ( new_otu_id in sample_dict ) : sample_dict [ new_otu_id ] += otu_abundance else : sample_dict [ new_otu_id ] = otu_abundance sample_dicts . append ( sample_dict ) res_sam_names . append ( ( ( sample_ids [ i ] + '.' ) + str ( j ) ) ) ( res_otu_mtx , res_otus ) = combine_sample_dicts ( sample_dicts ) res_otu_metadata = [ ] if ( ( otu_metadata is None ) or ( otu_metadata == [ ] ) ) : res_otu_metadata = None else : for otu_id in res_otus : try : res_otu_metadata . append ( otu_metadata [ otu_ids . index ( otu_id ) ] ) except ValueError : res_otu_metadata . append ( None ) return ( res_sam_names , res_otus , res_otu_mtx , res_otu_metadata )
make n samples related to each sample in an input otu table input: the constituents of an otu table * sample_ids: list * otu_ids: list * samples: iterable .