Package htsjdk.samtools
Class SamPairUtil
java.lang.Object
htsjdk.samtools.SamPairUtil
Utility methods for pairs of SAMRecords
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe possible orientations of paired reads.static classA class to iterate through SAMRecords and set mate information on the given records, and optionally set the mate cigar tag (true by default). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertMate(SAMRecord firstOfPair, SAMRecord secondOfPair) static intcomputeInsertSize(SAMRecord firstEnd, SAMRecord secondEnd) Compute SAMRecord insert sizestatic SamPairUtil.PairOrientationComputes the pair orientation of the given SAMRecord.static booleanisProperPair(SAMRecord firstEnd, SAMRecord secondEnd, List<SamPairUtil.PairOrientation> expectedOrientations) static SAMRecordobtainAssertedMate(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)static voidsetMateInfo(SAMRecord rec1, SAMRecord rec2) Write the mate info for two SAMRecords.static voidsetMateInfo(SAMRecord rec1, SAMRecord rec2, boolean setMateCigar) Write the mate info for two SAMRecordsstatic voidsetMateInfo(SAMRecord rec1, SAMRecord rec2, SAMFileHeader header) Deprecated.static voidsetMateInfo(SAMRecord rec1, SAMRecord rec2, SAMFileHeader header, boolean setMateCigar) Deprecated.usesetMateInfo(SAMRecord, SAMRecord, boolean)insteadstatic voidsetMateInformationOnSupplementalAlignment(SAMRecord supplemental, SAMRecord matePrimary) Sets mate pair information appropriately on a supplemental SAMRecord (e.g.static voidsetMateInformationOnSupplementalAlignment(SAMRecord supplemental, SAMRecord matePrimary, boolean setMateCigar) Sets mate pair information appropriately on a supplemental SAMRecord (e.g.static voidsetProperPairAndMateInfo(SAMRecord rec1, SAMRecord rec2, SAMFileHeader header, List<SamPairUtil.PairOrientation> expectedOrientations) Deprecated.static voidsetProperPairAndMateInfo(SAMRecord rec1, SAMRecord rec2, SAMFileHeader header, List<SamPairUtil.PairOrientation> expectedOrientations, boolean addMateCigar) Deprecated.static voidsetProperPairAndMateInfo(SAMRecord rec1, SAMRecord rec2, List<SamPairUtil.PairOrientation> expectedOrientations) This method will clear any mate cigar already present.static voidsetProperPairAndMateInfo(SAMRecord rec1, SAMRecord rec2, List<SamPairUtil.PairOrientation> expectedOrientations, boolean addMateCigar) static voidsetProperPairFlags(SAMRecord rec1, SAMRecord rec2, List<SamPairUtil.PairOrientation> expectedOrientations)
-
Constructor Details
-
SamPairUtil
public SamPairUtil()
-
-
Method Details
-
getPairOrientation
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
-
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 iterationfirstOfPair- the firstOfPair SAMRecord- Returns:
- the secondOfPair SAMRecord
- Throws:
SAMException- when the secondOfPair mate cannot be obtained due to assertion failures
-
computeInsertSize
Compute SAMRecord insert size- Parameters:
firstEnd-secondEnd-- Returns:
- note that when storing insert size on the secondEnd, the return value must be negated.
-
setMateInfo
Write the mate info for two SAMRecords. This will always clear/remove any mate cigar tag that is present.- Parameters:
rec1- the first SAM recordrec2- the second SAM record
-
setMateInfo
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) Deprecated.usesetMateInfo(SAMRecord, SAMRecord, boolean)insteadWrite the mate info for two SAMRecords- Parameters:
rec1- the first SAM recordrec2- the second SAM recordheader- the SAM file headersetMateCigar- 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.usesetMateInfo(SAMRecord, SAMRecord)insteadWrite the mate info for two SAMRecords. This will always clear/remove any mate cigar tag that is present.- Parameters:
rec1- the first SAM recordrec2- the second SAM recordheader- 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 suppliedmatePrimary- the primary alignment of the the mate pair of the supplementalsetMateCigar- 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 suppliedmatePrimary- 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) Deprecated.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) Deprecated.- 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)
-
setMateInfo(SAMRecord, SAMRecord)instead