code: def _identify_heterogeneity_blocks_hmm(in_file, params, work_dir, somatic_info):
      
      def _segment_by_hmm(chrom, freqs, coords):
          cur_coords = []
          for j, state in enumerate(_predict_states(freqs)):
              if state == 0:  # heterozygote region
                  if len(cur_coords) == 0:
                      num_misses = 0
                  cur_coords.append(coords[j])
              else:
                  num_misses += 1
              if num_misses > params["hetblock"]["allowed_misses"]:
                  if len(cur_coords) >= params["hetblock"]["min_alleles"]:
                      yield min(cur_coords), max(cur_coords)
                  cur_coords = []
          if len(cur_coords) >= params["hetblock"]["min_alleles"]:
              yield min(cur_coords), max(cur_coords)
      return _identify_heterogeneity_blocks_shared(in_file, _segment_by_hmm, params, work_dir, somatic_info)
docs: Use a HMM to identify blocks of heterogeneity to use for calculating allele frequencies.
  
      The goal is to subset the genome to a more reasonable section that contains potential
      loss of heterogeneity or other allele frequency adjustment based on selection.