Class SAMRecordCoordinateComparator

  • All Implemented Interfaces:
    SAMRecordComparator, Serializable, Comparator<SAMRecord>

    public class SAMRecordCoordinateComparator
    extends Object
    implements SAMRecordComparator, Serializable
    Comparator for sorting SAMRecords by coordinate. Note that the header is required because the order of sequences in the header defines the major sort order. Ideally this method would only return 0 for completely equal SAMRecords, so that sort is completely deterministic. This implementation does not achieve this completely, but it comes pretty close, while avoiding decoding the variable length fields, except for read name, which is decoded if coordinate and strand are equal. Extreme care must be taken to ensure the following: if A == B, then B == A if A < B, then B > A if A < B && B < C, then A < C
    See Also:
    Serialized Form
    • Constructor Detail

      • SAMRecordCoordinateComparator

        public SAMRecordCoordinateComparator()
    • Method Detail

      • fileOrderCompare

        public int fileOrderCompare​(SAMRecord samRecord1,
                                    SAMRecord samRecord2)
        Less stringent compare method than the regular compare. If the two records are equal enough that their ordering in a sorted SAM file would be arbitrary, this method returns 0. If read is paired and unmapped, use the mate mapping to sort. Records being compared must have non-null SAMFileHeaders.
        Specified by:
        fileOrderCompare in interface SAMRecordComparator
        Returns:
        negative if samRecord1 < samRecord2, 0 if equal, else positive