code: def compare_clades(pw):
      names = sorted(set([i for i in pw]))
      for i in range(0, 4):
          wi, bt = {}, {}
          for a in names:
              for b in pw[a]:
                  if ';' not in a or ';' not in b:
                      continue
                  pident = pw[a][b]
                  cA, cB = a.split(';')[i], b.split(';')[i]
                  if i == 0 and '_' in cA and '_' in cB:
                      cA = cA.rsplit('_', 1)[1]
                      cB = cB.rsplit('_', 1)[1]
                  elif '>' in cA or '>' in cB:
                      cA = cA.split('>')[1]
                      cB = cB.split('>')[1]
                  if cA == cB:
                      if cA not in wi:
                          wi[cA] = []
                      wi[cA].append(pident)
                  else:
                      if cA not in bt:
                          bt[cA] = {}
                      if cB not in bt[cA]:
                          bt[cA][cB] = []
                      bt[cA][cB].append(pident)
          print('\n
          for clade, pidents in list(wi.items()):
              print('\t'.join(['wi:%s' % str(i), clade, str(min(pidents))]))
          comps = []
          print('\n
          for comp in print_pairwise(bt):
              if comp is not None:
                  print('\t'.join(['bt:%s' % str(i)] + [str(j) for j in comp]))
                  if comp[0] != '
                      comps.extend([j for j in comp[1:] if j != '-'])
          print_comps(comps)
          comps = []
          print('\n
          for comp in print_pairwise(bt, median = True):
              if comp is not None:
                  print('\t'.join(['bt:%s' % str(i)] + [str(j) for j in comp]))
                  if comp[0] != '
                      comps.extend([j for j in comp[1:] if j != '-'])
          print_comps(comps)