Esempio n. 1
0
 /**
  * If a read ends in INSERTION, returns the last element length.
  *
  * <p>Warning: If the read has Hard or Soft clips after the insertion this function will return 0.
  *
  * @param read
  * @return the length of the last insertion, or 0 if there is none (see warning).
  */
 public static int getLastInsertionOffset(final GATKRead read) {
   final CigarElement e = read.getCigar().getCigarElement(read.getCigar().numCigarElements() - 1);
   if (e.getOperator() == CigarOperator.I) {
     return e.getLength();
   } else {
     return 0;
   }
 }
Esempio n. 2
0
 /**
  * Pre-processes the results of {@link #getReadCoordinateForReferenceCoordinate(int, Cigar, int,
  * boolean)} to take care of two corner cases:
  *
  * <p>1. If clipping the right tail (end of the read) getReadCoordinateForReferenceCoordinate and
  * fall inside a deletion return the base after the deletion. If clipping the left tail (beginning
  * of the read) it doesn't matter because it already returns the previous base by default.
  *
  * <p>2. If clipping the left tail (beginning of the read) getReadCoordinateForReferenceCoordinate
  * and the read starts with an insertion, and you're requesting the first read based coordinate,
  * it will skip the leading insertion (because it has the same reference coordinate as the
  * following base).
  *
  * @return the read coordinate corresponding to the requested reference coordinate for clipping.
  */
 public static int getReadCoordinateForReferenceCoordinate(
     final GATKRead read, final int refCoord, final ClippingTail tail) {
   return getReadCoordinateForReferenceCoordinate(
       getSoftStart(read), read.getCigar(), refCoord, tail, false);
 }
Esempio n. 3
0
 public static int getReadCoordinateForReferenceCoordinateUpToEndOfRead(
     final GATKRead read, final int refCoord, final ClippingTail tail) {
   final int leftmostSafeVariantPosition = Math.max(getSoftStart(read), refCoord);
   return getReadCoordinateForReferenceCoordinate(
       getSoftStart(read), read.getCigar(), leftmostSafeVariantPosition, tail, false);
 }
Esempio n. 4
0
 /**
  * Calculates the reference coordinate for the end of the read taking into account soft clips but
  * not hard clips.
  *
  * <p>Note: getUnclippedEnd() adds soft and hard clips, this function only adds soft clips.
  *
  * @return the unclipped end of the read taking soft clips (but not hard clips) into account
  */
 public static int getSoftEnd(final GATKRead read) {
   return getSoftEnd(read, read.getCigar());
 }
Esempio n. 5
0
 /**
  * Calculates the reference coordinate for the beginning of the read taking into account soft
  * clips but not hard clips.
  *
  * <p>Note: getUnclippedStart() adds soft and hard clips, this function only adds soft clips.
  *
  * @return the unclipped start of the read taking soft clips (but not hard clips) into account
  */
 public static int getSoftStart(final GATKRead read) {
   Utils.nonNull(read);
   return getSoftStart(read, read.getCigar());
 }