public final Map<String, IntervalTree<GenomeLoc>> createIntervalTreeByContig(
      final IntervalBinding<Feature> intervals) {
    final Map<String, IntervalTree<GenomeLoc>> byContig =
        new HashMap<String, IntervalTree<GenomeLoc>>();

    final List<GenomeLoc> locs = intervals.getIntervals(getToolkit());

    // set up the map from contig -> interval tree
    for (final String contig : getContigNames())
      byContig.put(contig, new IntervalTree<GenomeLoc>());

    for (final GenomeLoc loc : locs) {
      byContig.get(loc.getContig()).put(loc.getStart(), loc.getStop(), loc);
    }

    return byContig;
  }
  @Override
  public void initialize() {
    super.initialize();

    if (intervalTrack == null)
      throw new UserException("This tool currently only works if you provide an interval track");

    parser =
        new GenomeLocParser(
            getToolkit()
                .getMasterSequenceDictionary()); // Important to initialize the parser before
                                                 // creating the intervals below

    List<GenomeLoc> originalList =
        intervalTrack.getIntervals(
            getToolkit()); // The original list of targets provided by the user that will be
                           // expanded or not depending on the options provided
    intervalList = new TreeSet<GenomeLoc>(new GenomeLocComparator());
    intervalMap = new HashMap<GenomeLoc, IntervalStatistics>(originalList.size() * 2);
    for (GenomeLoc interval : originalList) addAndExpandIntervalToLists(interval);

    intervalListIterator = intervalList.iterator();
  }