Example #1
0
  /**
   * is this base inside the adaptor of the read?
   *
   * <p>There are two cases to treat here:
   *
   * <p>1) Read is in the negative strand => Adaptor boundary is on the left tail 2) Read is in the
   * positive strand => Adaptor boundary is on the right tail
   *
   * <p>Note: We return false to all reads that are UNMAPPED or have an weird big insert size
   * (probably due to mismapping or bigger event)
   *
   * @param read the read to test
   * @param basePos base position in REFERENCE coordinates (not read coordinates)
   * @return whether or not the base is in the adaptor
   */
  public static boolean isBaseInsideAdaptor(final GATKSAMRecord read, long basePos) {
    Integer adaptorBoundary = getAdaptorBoundary(read);
    if (adaptorBoundary == null || read.getInferredInsertSize() > DEFAULT_ADAPTOR_SIZE)
      return false;

    return read.getReadNegativeStrandFlag()
        ? basePos <= adaptorBoundary
        : basePos >= adaptorBoundary;
  }