/**
   * Try to fix the given read using the given split
   *
   * @param read the read to fix
   * @param splice the split (bad region to clip out)
   */
  private void fixSplit(final SplitRead read, final Splice splice) {
    // if the read doesn't even overlap the split position then we can just exit
    if (read.loc == null || !splice.loc.overlapsP(read.loc)) return;

    if (isLeftOverhang(read.loc, splice.loc)) {
      final int overhang = splice.loc.getStop() - read.loc.getStart() + 1;
      if (overhangingBasesMismatch(
          read.read.getBases(),
          0,
          splice.reference,
          splice.reference.length - overhang,
          overhang)) {
        final GATKRead clippedRead =
            ReadClipper.hardClipByReadCoordinates(read.read, 0, overhang - 1);
        read.setRead(clippedRead);
      }
    } else if (isRightOverhang(read.loc, splice.loc)) {
      final int overhang = read.loc.getStop() - splice.loc.getStart() + 1;
      if (overhangingBasesMismatch(
          read.read.getBases(), read.read.getLength() - overhang, splice.reference, 0, overhang)) {
        final GATKRead clippedRead =
            ReadClipper.hardClipByReadCoordinates(
                read.read, read.read.getLength() - overhang, read.read.getLength() - 1);
        read.setRead(clippedRead);
      }
    }
  }
示例#2
0
  /**
   * Given a read, clips low quality ends (by overwriting with N) and returns the underlying bases,
   * after reverse-complementing for negative-strand reads.
   *
   * @param read the read
   * @param lowQTail every base quality lower than or equal to this in the tail of the read will be
   *     replaced with N.
   * @return bases of the read.
   */
  public static byte[] getStrandedBytes(final SAMRecord read, final byte lowQTail) {

    // Write N's over the low quality tail of the reads to avoid adding them into the context
    final SAMRecord clippedRead =
        ReadClipper.clipLowQualEnds(read, lowQTail, ClippingRepresentation.WRITE_NS);

    final byte[] bases = clippedRead.getReadBases();
    if (read.getReadNegativeStrandFlag()) {
      return BaseUtils.simpleReverseComplement(bases);
    } else {
      return bases;
    }
  }