code: def _sim(self, xg, ancs1, ancs2, pfx1, pfx2):
          
          xancs1 = set()
          for a in ancs1:
              if a in xg:
                  # TODO: restrict this to neighbors in single ontology
                  for n in xg.neighbors(a):
                      pfx = self._id_to_ontology(n)
                      if pfx == pfx2:
                          xancs1.add(n)
          logging.debug('SIM={}/{} ## {}'.format(len(xancs1.intersection(ancs2)), len(xancs1), xancs1.intersection(ancs2), xancs1))
          n_shared = len(xancs1.intersection(ancs2))
          n_total = len(xancs1)
          return (1+n_shared) / (1+n_total), n_shared, n_total
docs: Compare two lineages