code: def _identify_heterogeneity_blocks_seg(in_file, seg_file, params, work_dir, somatic_info):
      
      def _segment_by_cns(target_chrom, freqs, coords):
          with open(seg_file) as in_handle:
              reader = csv.reader(in_handle, dialect="excel-tab")
              next(reader)  # header
              for cur_chrom, start, end in (xs[:3] for xs in reader):
                  if cur_chrom == target_chrom:
                      block_freqs = []
                      for i, (freq, coord) in enumerate(zip(freqs, coords)):
                          if coord >= int(start) and coord < int(end):
                              block_freqs.append(freq)
                          elif coord >= int(end):
                              break
                      coords = coords[max(0, i - 1):]
                      freqs = freqs[max(0, i - 1):]
                      if len(block_freqs) > params["hetblock"]["min_alleles"]:
                          yield start, end
      return _identify_heterogeneity_blocks_shared(in_file, _segment_by_cns, params, work_dir, somatic_info)
docs: Identify heterogeneity blocks corresponding to segmentation from CNV input file.