The 'contained' parameter controls whether the alignments must be fully
contained within the range, or need only overlap it.
function isAlignmentInRange(read: SamRead,
                            idxRange: ContigInterval<number>,
                            contained: boolean): boolean {
  // TODO: Use cigar.getReferenceLength() instead of l_seq, like htsjdk. 
  var readRange = new ContigInterval(read.refID, read.pos, read.pos + read.l_seq - 1);
  if (contained) {
    return idxRange.containsInterval(readRange);
  } else {
    return readRange.intersects(idxRange);
  }
}