Package htsjdk.samtools
Class SAMRecordCoordinateComparator
java.lang.Object
htsjdk.samtools.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:
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
SAMRecordCoordinateComparator
public SAMRecordCoordinateComparator()
-
-
Method Details
-
compare
- Specified by:
compare
in interfaceComparator<SAMRecord>
-
fileOrderCompare
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 interfaceSAMRecordComparator
- Returns:
- negative if samRecord1 < samRecord2, 0 if equal, else positive
-