/** * Compares two SAMRecords only the basis on alignment start. Note that * comparisons are performed ONLY on the basis of alignment start; any * two SAM records with the same alignment start will be considered equal. * * Unmapped alignments will all be considered equal. */ @Requires({"read1 != null", "read2 != null"}) public static int compareSAMRecords(GATKSAMRecord read1, GATKSAMRecord read2) { AlignmentStartComparator comp = new AlignmentStartComparator(); return comp.compare(read1, read2); }
/** * Removes all reads currently in the cache, and returns them in sorted order (w.r.t. alignmentStart) * * Flushes this cache, so after this call the cache will contain no reads, and we'll be in the same * initial state as the constructor would put us in, with a non-null undownsampledCache and a null * downsampler. * * @return a list of GATKSAMRecords in this cache */ public List<GATKSAMRecord> popCurrentReads() { final List<GATKSAMRecord> poppedReads; if ( downsampler == null ) { poppedReads = undownsampledCache; // avoid making a copy here, since we're going to allocate a new cache } else { // If we triggered the downsampler, we need to sort the reads before returning them, // since the ReservoirDownsampler is not guaranteed to preserve relative ordering of items. // After consuming the downsampled items in this call to popCurrentReads(), we switch back // to using the undownsampledCache until we fill up again. poppedReads = downsampler.consumeFinalizedItems(); // avoid making a copy here Collections.sort(poppedReads, new AlignmentStartComparator()); downsampler = null; } initializeUndownsampledCache(); return poppedReads; } }