Пример #1
0
  /**
   * 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;
  }
Пример #2
0
  private int addBlock(
      ObjectArrayList<AlignmentBlock> blocks,
      int start,
      ByteArrayList bases,
      ByteArrayList scores) {

    blocks.add(
        AlignmentBlock.getInstance(
            start,
            bases.toByteArray(new byte[bases.size()]),
            scores.toByteArray(new byte[scores.size()]),
            this));
    start += bases.size();
    bases.clear();
    scores.clear();
    return start;
  }
Пример #3
0
  private void addSoftClipBlock(
      ObjectArrayList<AlignmentBlock> blocks,
      int position,
      String softClippedBasesLeft,
      byte[] readQualScores,
      boolean hasSoftClippedQuality,
      byte[] softClippedQuality,
      int j) {
    final int length = softClippedBasesLeft.length();
    byte[] bases = new byte[length];
    byte[] scores = new byte[length];

    for (int i = 0; i < length; i++) {
      bases[i] = (byte) softClippedBasesLeft.charAt(i);
      scores[i] = hasSoftClippedQuality ? softClippedQuality[i] : readQualScores[j++];
    }
    final AlignmentBlock alignmentBlock = AlignmentBlock.getInstance(position, bases, scores, this);
    alignmentBlock.setSoftClipped(true);
    blocks.add(alignmentBlock);
  }