private AlignmentBlock[] keepSoftClips(AlignmentBlock[] blocks) {
   int numSoftCLippedBlocks = 0;
   for (AlignmentBlock block : blocks) {
     if (block.isSoftClipped()) numSoftCLippedBlocks++;
   }
   AlignmentBlock[] tmp = new AlignmentBlock[numSoftCLippedBlocks];
   int j = 0;
   for (int i = 0; i < numSoftCLippedBlocks; i++) {
     AlignmentBlock block = blocks[j++];
     if (block.isSoftClipped()) {
       tmp[i] = block;
     }
   }
   return tmp;
 }
  /**
   * 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;
  }