Package htsjdk.samtools
Class SamPairUtil
- java.lang.Object
-
- htsjdk.samtools.SamPairUtil
-
public class SamPairUtil extends Object
Utility methods for pairs of SAMRecords
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSamPairUtil.PairOrientationThe possible orientations of paired reads.static classSamPairUtil.SetMateInfoIteratorA 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 Constructor Description SamPairUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidassertMate(SAMRecord firstOfPair, SAMRecord secondOfPair)static intcomputeInsertSize(SAMRecord firstEnd, SAMRecord secondEnd)Compute SAMRecord insert sizestatic SamPairUtil.PairOrientationgetPairOrientation(SAMRecord r)Computes 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.usesetMateInfo(SAMRecord, SAMRecord)insteadstatic 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)
-
-
-
Method Detail
-
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)
-
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
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 recordrec2- 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)
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 public static void setMateInfo(SAMRecord rec1, SAMRecord rec2, SAMFileHeader header)
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)
-
-