/**
   * This method splits blocks whose boundaries contain a read deletion.
   *
   * @param blocks
   * @param alignmentEntry
   * @return
   */
  private ObjectArrayList<AlignmentBlock> introduceDeletions(
      ObjectArrayList<AlignmentBlock> blocks, Alignments.AlignmentEntry alignmentEntry) {

    ObjectArrayList<AlignmentBlock> newBlocks = new ObjectArrayList<AlignmentBlock>();

    for (Alignments.SequenceVariation var : alignmentEntry.getSequenceVariationsList()) {

      for (AlignmentBlock block : blocks) {
        if (!block.isSoftClipped()) {

          final int vrPos = var.getPosition() + entry.getPosition();
          if (hasReadDeletion(var) && vrPos >= block.getStart() && vrPos <= block.getEnd()) {

            ByteList leftBases = new ByteArrayList(block.getBases());
            ByteList leftScores = new ByteArrayList(block.getQualities());
            ByteList rightBases = new ByteArrayList(block.getBases());
            ByteList rightScores = new ByteArrayList(block.getQualities());
            int deletionPosition = var.getPosition() - 1;
            leftBases = leftBases.subList(0, deletionPosition);
            rightBases = rightBases.subList(deletionPosition, rightBases.size());

            leftScores = leftScores.subList(0, deletionPosition);
            rightScores = rightScores.subList(deletionPosition, rightScores.size());

            AlignmentBlock left =
                AlignmentBlock.getInstance(
                    block.getStart(),
                    leftBases.toByteArray(new byte[leftBases.size()]),
                    leftScores.toByteArray(new byte[leftScores.size()]),
                    this);

            AlignmentBlock right =
                AlignmentBlock.getInstance(
                    block.getStart() + leftBases.size() + var.getFrom().length(),
                    rightBases.toByteArray(new byte[rightBases.size()]),
                    rightScores.toByteArray(new byte[rightScores.size()]),
                    this);

            blocks.remove(block);
            newBlocks.add(left);
            newBlocks.add(right);
          }
        }
      }
    }

    newBlocks.addAll(blocks);
    return newBlocks;
  }
 public byte getBase(double position) {
   int basePosition = (int) position;
   for (AlignmentBlock block : getAlignmentBlocks()) {
     if (block.contains(basePosition)) {
       int offset = basePosition - block.getStart();
       byte base = block.getBases()[offset];
       return base;
     }
   }
   return 0;
 }