def get_num_con_cat(con_by_sample, cat_by_sample):
 num_con_cat = defaultdict(float)
 num_con = 0
 for (sample, connects) in con_by_sample.items():
  sample_categories = cat_by_sample[sample]
  for s_con in connects:
   if (s_con not in cat_by_sample.keys()):
    continue
   for (s_cat, con_cat) in zip(sample_categories, cat_by_sample[s_con]):
    if (s_cat == con_cat):
     num_con_cat[s_cat[0]] += 0.5
   num_con += 0.5
 return (num_con_cat, num_con)

def get_num_con_cat ( con_by_sample , cat_by_sample ) : num_con_cat = defaultdict ( float ) num_con = 0 for ( sample , connects ) in con_by_sample . items ( ) : sample_categories = cat_by_sample [ sample ] for s_con in connects : if ( s_con not in cat_by_sample . keys ( ) ) : continue for ( s_cat , con_cat ) in zip ( sample_categories , cat_by_sample [ s_con ] ) : if ( s_cat == con_cat ) : num_con_cat [ s_cat [ 0 ] ] += 0.5 num_con += 0.5 return ( num_con_cat , num_con )
finds the number of samples connected to the same otu split by metadata .