def calc_shared_phylotypes(otu_table, reference_sample=None):
 if reference_sample:
  ref_idx = reference_sample
 sample_ids = otu_table.ids()
 num_samples = len(sample_ids)
 result_array = zeros((num_samples, num_samples), dtype=int)
 for (i, samp1_id) in enumerate(sample_ids):
  for (j, samp2_id) in enumerate(sample_ids[:(i + 1)]):
   if reference_sample:
    result_array[(i, j)] = result_array[(j, i)] = _calc_shared_phylotypes_multiple(otu_table, [samp1_id, samp2_id, ref_idx])
   else:
    result_array[(i, j)] = result_array[(j, i)] = _calc_shared_phylotypes_pairwise(otu_table, samp1_id, samp2_id)
 return (format_distance_matrix(sample_ids, result_array) + '\n')

def calc_shared_phylotypes ( otu_table , reference_sample = None ) : if reference_sample : ref_idx = reference_sample sample_ids = otu_table . ids ( ) num_samples = len ( sample_ids ) result_array = zeros ( ( num_samples , num_samples ) , dtype = int ) for ( i , samp1_id ) in enumerate ( sample_ids ) : for ( j , samp2_id ) in enumerate ( sample_ids [ : ( i + 1 ) ] ) : if reference_sample : result_array [ ( i , j ) ] = result_array [ ( j , i ) ] = _calc_shared_phylotypes_multiple ( otu_table , [ samp1_id , samp2_id , ref_idx ] ) else : result_array [ ( i , j ) ] = result_array [ ( j , i ) ] = _calc_shared_phylotypes_pairwise ( otu_table , samp1_id , samp2_id ) return ( format_distance_matrix ( sample_ids , result_array ) + '\n' )
calculates number of shared phylotypes for each pair of sample .