docs: def deduplicate(pairs, aa=False, ignore_primer_regions=False):
      '''
      Removes duplicate sequences from a list of Pair objects.
  
      If a Pair has heavy and light chains, both chains must identically match heavy and light chains
      from another Pair to be considered a duplicate. If a Pair has only a single chain,
      identical matches to that chain will cause the single chain Pair to be considered a duplicate,
      even if the comparison Pair has both chains.
  
      Note that identical sequences are identified by simple string comparison, so sequences of
      different length that are identical over the entirety of the shorter sequence are not
      considered duplicates.
  
      By default, comparison is made on the nucleotide sequence. To use the amino acid sequence instead,
      set aa=True.
      '''
      nr_pairs = []
      just_pairs = [p for p in pairs if p.is_pair]
      single_chains = [p for p in pairs if not p.is_pair]
      _pairs = just_pairs + single_chains
      for p in _pairs:
          duplicates = []
          for nr in nr_pairs:
              identical = True
              vdj = 'vdj_aa' if aa else 'vdj_nt'
              offset = 4 if aa else 12
              if p.heavy is not None:
                  if nr.heavy is None:
                      identical = False
                  else:
                      heavy = p.heavy[vdj][offset:-offset] if ignore_primer_regions else p.heavy[vdj]
                      nr_heavy = nr.heavy[vdj][offset:-offset] if ignore_primer_regions else nr.heavy[vdj]
                      if heavy != nr_heavy:
                          identical = False
              if p.light is not None:
                  if nr.light is None:
                      identical = False
                  else:
                      light = p.light[vdj][offset:-offset] if ignore_primer_regions else p.light[vdj]
                      nr_light = nr.light[vdj][offset:-offset] if ignore_primer_regions else nr.light[vdj]
                      if light != nr_light:
                          identical = False
              duplicates.append(identical)
          if any(duplicates):
              continue
          else:
              nr_pairs.append(p)
      return nr_pairs