@Override
  public boolean isDone() {
    for (PerReadGroupInfo info : readGroupInfo.values()) {
      if (info.needsMoreData()) return false;
    }

    return true;
  }
  @Override
  public Integer map(
      ReferenceContext referenceContext,
      GATKSAMRecord read,
      RefMetaDataTracker RefMetaDataTracker) {
    final String rgID = read.getReadGroup().getId();
    final PerReadGroupInfo info = readGroupInfo.get(rgID);

    if (info.needsMoreData()) {
      info.readLength.add(read.getReadLength());
      info.nReadsSeen++;
      if (read.getReadPairedFlag()) {
        info.nReadsPaired++;
        if (read.getInferredInsertSize() != 0) {
          info.insertSize.add(Math.abs(read.getInferredInsertSize()));
        }
      }
    }

    return null;
  }