def compare_otu_maps(otu_map1, otu_map2, verbose=False):
 right = 0
 wrong = 0
 otus1 = set(otu_map1.keys())
 otus2 = set(otu_map2.keys())
 shared_otus = otus1.intersection(otus2)
 for otu in shared_otus:
  members1 = set(otu_map1[otu])
  members2 = set(otu_map2[otu])
  right += len((members1 & members2))
  missing_in_2 = (members1 - members2)
  wrong += len(missing_in_2)
  if (verbose and (len(missing_in_2) > 0)):
   print ('OTU id: %s' % otu)
   print list(missing_in_2)
   print
 for otu in (otus1 - shared_otus):
  wrong += len(otu_map1[otu])
  if verbose:
   print ('OTU id: %s' % otu)
   print list(otu_map1[otu])
 return (float(wrong) / (right + wrong))

def compare_otu_maps ( otu_map1 , otu_map2 , verbose = False ) : right = 0 wrong = 0 otus1 = set ( otu_map1 . keys ( ) ) otus2 = set ( otu_map2 . keys ( ) ) shared_otus = otus1 . intersection ( otus2 ) for otu in shared_otus : members1 = set ( otu_map1 [ otu ] ) members2 = set ( otu_map2 [ otu ] ) right += len ( ( members1 & members2 ) ) missing_in_2 = ( members1 - members2 ) wrong += len ( missing_in_2 ) if ( verbose and ( len ( missing_in_2 ) > 0 ) ) : print ( 'OTU id: %s' % otu ) print list ( missing_in_2 ) print for otu in ( otus1 - shared_otus ) : wrong += len ( otu_map1 [ otu ] ) if verbose : print ( 'OTU id: %s' % otu ) print list ( otu_map1 [ otu ] ) return ( float ( wrong ) / ( right + wrong ) )
compare two otu maps and compute fraction of otu_map1 .