Source:
public void test() throws IOException { final File cramFile = new File("src/test/resources/htsjdk/samtools/cram/SM-74NEG-v1-chr20-downsampled.deduplicated.cram"); CramHeader expectedHeader; List<Container> fullContainers; try (SeekableFileStream seekableFileStream = new SeekableFileStream(cramFile)) { CramContainerIterator iterator = new CramContainerIterator(seekableFileStream); expectedHeader = iterator.getCramHeader(); fullContainers = Iterables.slurp(iterator); } CramHeader actualHeader; List<Container> headerOnlyContainers; try (SeekableFileStream seekableFileStream = new SeekableFileStream(cramFile)) { CramContainerHeaderIterator iterator = new CramContainerHeaderIterator(seekableFileStream); actualHeader = iterator.getCramHeader(); headerOnlyContainers = Iterables.slurp(iterator); } Assert.assertEquals(actualHeader, expectedHeader); Assert.assertEquals(fullContainers.size(), headerOnlyContainers.size()); for (int i = 0; i < fullContainers.size(); i++) { Container fullContainer = fullContainers.get(i); Container headerOnlyContainer = headerOnlyContainers.get(i); Assert.assertEquals(headerOnlyContainer.containerByteSize, fullContainer.containerByteSize); Assert.assertEquals(headerOnlyContainer.sequenceId, fullContainer.sequenceId); Assert.assertEquals(headerOnlyContainer.alignmentStart, fullContainer.alignmentStart); Assert.assertEquals(headerOnlyContainer.alignmentSpan, fullContainer.alignmentSpan); Assert.assertEquals(headerOnlyContainer.nofRecords, fullContainer.nofRecords); Assert.assertEquals(headerOnlyContainer.globalRecordCounter, fullContainer.globalRecordCounter); Assert.assertEquals(headerOnlyContainer.bases, fullContainer.bases); Assert.assertEquals(headerOnlyContainer.blockCount, fullContainer.blockCount); Assert.assertEquals(headerOnlyContainer.landmarks, fullContainer.landmarks); Assert.assertEquals(headerOnlyContainer.checksum, fullContainer.checksum); Assert.assertNull(headerOnlyContainer.blocks); Assert.assertNull(headerOnlyContainer.header); Assert.assertNull(headerOnlyContainer.slices); } }

Target:
public void test() throws IOException { final File cramFile = new File("src/test/resources/htsjdk/samtools/cram/NA12878.20.21.1-100.100-SeqsPerSlice.0-unMapped.cram"); CramHeader expectedHeader; List<Container> fullContainers; try (SeekableFileStream seekableFileStream = new SeekableFileStream(cramFile)) { CramContainerIterator iterator = new CramContainerIterator(seekableFileStream); expectedHeader = iterator.getCramHeader(); fullContainers = Iterables.slurp(iterator); } CramHeader actualHeader; List<Container> headerOnlyContainers; try (SeekableFileStream seekableFileStream = new SeekableFileStream(cramFile)) { CramContainerHeaderIterator iterator = new CramContainerHeaderIterator(seekableFileStream); actualHeader = iterator.getCramHeader(); headerOnlyContainers = Iterables.slurp(iterator); } Assert.assertEquals(actualHeader, expectedHeader); Assert.assertEquals(fullContainers.size(), headerOnlyContainers.size()); for (int i = 0; i < fullContainers.size(); i++) { Container fullContainer = fullContainers.get(i); Container headerOnlyContainer = headerOnlyContainers.get(i); Assert.assertEquals(headerOnlyContainer.containerByteSize, fullContainer.containerByteSize); Assert.assertEquals(headerOnlyContainer.sequenceId, fullContainer.sequenceId); Assert.assertEquals(headerOnlyContainer.alignmentStart, fullContainer.alignmentStart); Assert.assertEquals(headerOnlyContainer.alignmentSpan, fullContainer.alignmentSpan); Assert.assertEquals(headerOnlyContainer.nofRecords, fullContainer.nofRecords); Assert.assertEquals(headerOnlyContainer.globalRecordCounter, fullContainer.globalRecordCounter); Assert.assertEquals(headerOnlyContainer.bases, fullContainer.bases); Assert.assertEquals(headerOnlyContainer.blockCount, fullContainer.blockCount); Assert.assertEquals(headerOnlyContainer.landmarks, fullContainer.landmarks); Assert.assertEquals(headerOnlyContainer.checksum, fullContainer.checksum); Assert.assertEquals(headerOnlyContainer.offset, fullContainer.offset); Assert.assertNull(headerOnlyContainer.blocks); Assert.assertNull(headerOnlyContainer.header); Assert.assertNull(headerOnlyContainer.slices); } }