Class SamPairUtil

java.lang.Object
htsjdk.samtools.SamPairUtil

public class SamPairUtil extends Object
Utility methods for pairs of SAMRecords
  • Constructor Details

    • SamPairUtil

      public SamPairUtil()
  • Method Details

    • getPairOrientation

      public static SamPairUtil.PairOrientation getPairOrientation(SAMRecord r)
      Computes the pair orientation of the given SAMRecord.
      Parameters:
      r -
      Returns:
      PairOrientation of the given SAMRecord.
      Throws:
      IllegalArgumentException - If the record is not a paired read, or one or both reads are unmapped.
    • isProperPair

      public static boolean isProperPair(SAMRecord firstEnd, SAMRecord secondEnd, List<SamPairUtil.PairOrientation> expectedOrientations)
    • assertMate

      public static void assertMate(SAMRecord firstOfPair, SAMRecord secondOfPair)
    • obtainAssertedMate

      public static SAMRecord obtainAssertedMate(Iterator<SAMRecord> samRecordIterator, SAMRecord firstOfPair)
      Obtain the secondOfPair mate belonging to the firstOfPair SAMRecord (assumed to be in the next element of the specified samRecordIterator)
      Parameters:
      samRecordIterator - the iterator assumed to contain the secondOfPair SAMRecord in the next element in the iteration
      firstOfPair - the firstOfPair SAMRecord
      Returns:
      the secondOfPair SAMRecord
      Throws:
      SAMException - when the secondOfPair mate cannot be obtained due to assertion failures
    • computeInsertSize

      public static int computeInsertSize(SAMRecord firstEnd, SAMRecord secondEnd)
      Compute SAMRecord insert size
      Parameters:
      firstEnd -
      secondEnd -
      Returns:
      note that when storing insert size on the secondEnd, the return value must be negated.
    • setMateInfo

      public static void setMateInfo(SAMRecord rec1, SAMRecord rec2)
      Write the mate info for two SAMRecords. This will always clear/remove any mate cigar tag that is present.
      Parameters:
      rec1 - the first SAM record
      rec2 - the second SAM record
    • setMateInfo

      public static void setMateInfo(SAMRecord rec1, SAMRecord rec2, boolean setMateCigar)
      Write the mate info for two SAMRecords
      Parameters:
      rec1 - the first SAM record. Must have a non-null SAMFileHeader.
      rec2 - the second SAM record. Must have a non-null SAMFileHeader.
      setMateCigar - true if we are to update/create the Mate CIGAR (MC) optional tag, false if we are to clear any mate cigar tag that is present.
    • setMateInfo

      @Deprecated public static void setMateInfo(SAMRecord rec1, SAMRecord rec2, SAMFileHeader header, boolean setMateCigar)
      Write the mate info for two SAMRecords
      Parameters:
      rec1 - the first SAM record
      rec2 - the second SAM record
      header - the SAM file header
      setMateCigar - true if we are to update/create the Mate CIGAR (MC) optional tag, false if we are to clear any mate cigar tag that is present.
    • setMateInfo

      @Deprecated public static void setMateInfo(SAMRecord rec1, SAMRecord rec2, SAMFileHeader header)
      Deprecated.
      Write the mate info for two SAMRecords. This will always clear/remove any mate cigar tag that is present.
      Parameters:
      rec1 - the first SAM record
      rec2 - the second SAM record
      header - the SAM file header
    • setMateInformationOnSupplementalAlignment

      public static void setMateInformationOnSupplementalAlignment(SAMRecord supplemental, SAMRecord matePrimary, boolean setMateCigar)
      Sets mate pair information appropriately on a supplemental SAMRecord (e.g. from a split alignment) using the primary alignment of the read's mate.
      Parameters:
      supplemental - a supplemental alignment for the mate pair of the primary supplied
      matePrimary - the primary alignment of the the mate pair of the supplemental
      setMateCigar - true if we are to update/create the Mate CIGAR (MC) optional tag, false if we are to clear any mate cigar tag that is present.
    • setMateInformationOnSupplementalAlignment

      public static void setMateInformationOnSupplementalAlignment(SAMRecord supplemental, SAMRecord matePrimary)
      Sets mate pair information appropriately on a supplemental SAMRecord (e.g. from a split alignment) using the primary alignment of the read's mate.
      Parameters:
      supplemental - a supplemental alignment for the mate pair of the primary supplied
      matePrimary - the primary alignment of the the mate pair of the supplemental
    • setProperPairAndMateInfo

      @Deprecated public static void setProperPairAndMateInfo(SAMRecord rec1, SAMRecord rec2, SAMFileHeader header, List<SamPairUtil.PairOrientation> expectedOrientations)
      This method will clear any mate cigar already present.
    • setProperPairAndMateInfo

      @Deprecated public static void setProperPairAndMateInfo(SAMRecord rec1, SAMRecord rec2, SAMFileHeader header, List<SamPairUtil.PairOrientation> expectedOrientations, boolean addMateCigar)
      Parameters:
      addMateCigar - true if we are to update/create the Mate CIGAR (MC) optional tag, false if we are to clear any mate cigar tag that is present.
    • setProperPairAndMateInfo

      public static void setProperPairAndMateInfo(SAMRecord rec1, SAMRecord rec2, List<SamPairUtil.PairOrientation> expectedOrientations)
      This method will clear any mate cigar already present.
    • setProperPairAndMateInfo

      public static void setProperPairAndMateInfo(SAMRecord rec1, SAMRecord rec2, List<SamPairUtil.PairOrientation> expectedOrientations, boolean addMateCigar)
      Parameters:
      addMateCigar - true if we are to update/create the Mate CIGAR (MC) optional tag, false if we are to clear any mate cigar tag that is present.
    • setProperPairFlags

      public static void setProperPairFlags(SAMRecord rec1, SAMRecord rec2, List<SamPairUtil.PairOrientation> expectedOrientations)