public void setRead(final GATKRead read) {
   if (!read.isEmpty()) {
     this.read = read;
     if (!read.isUnmapped())
       loc =
           genomeLocParser.createGenomeLoc(
               read.getContig(), ReadUtils.getSoftStart(read), ReadUtils.getSoftEnd(read));
   }
 }
  /**
   * Add a read to the manager
   *
   * @param read the read to add
   */
  public void addRead(final GATKRead read) {
    if (read == null)
      throw new IllegalArgumentException("read added to manager is null, which is not allowed");

    // if the new read is on a different contig or we have too many reads, then we need to flush the
    // queue and clear the map
    final boolean tooManyReads = getNReadsInQueue() >= MAX_RECORDS_IN_MEMORY;
    final boolean encounteredNewContig =
        getNReadsInQueue() > 0 && !waitingReads.peek().read.getContig().equals(read.getContig());

    if (tooManyReads || encounteredNewContig) {
      if (DEBUG)
        logger.warn(
            "Flushing queue on "
                + (tooManyReads
                    ? "too many reads"
                    : ("move to new contig: "
                        + read.getContig()
                        + " from "
                        + waitingReads.peek().read.getContig()))
                + " at "
                + read.getStart());

      final int targetQueueSize = encounteredNewContig ? 0 : MAX_RECORDS_IN_MEMORY / 2;

      // write the required number of waiting reads to disk
      while (getNReadsInQueue() > targetQueueSize) writer.addRead(waitingReads.poll().read);
    }

    final SplitRead splitRead = new SplitRead(read);

    // fix overhangs, as needed
    for (final Splice splice : splices) fixSplit(splitRead, splice);

    // add the new read to the queue
    waitingReads.add(splitRead);
  }