55import htsjdk .samtools .SAMRecordQueryNameComparator ;
66import htsjdk .samtools .cram .ref .ReferenceContext ;
77import htsjdk .samtools .cram .structure .*;
8+ import htsjdk .samtools .util .QuietTestWrapper ;
89import org .testng .Assert ;
910import org .testng .annotations .DataProvider ;
1011import org .testng .annotations .Test ;
1819
1920public class ContainerFactoryTest extends HtsjdkTest {
2021
21- // wrapper class to suppress expansion/serialization of lists of records during test execution
22- private static class RecordSupplier implements Supplier <List <SAMRecord >> {
23- final List <SAMRecord > samRecords ;
24- public RecordSupplier (final List <SAMRecord > samRecords ) { this .samRecords = samRecords ; }
25- @ Override public List <SAMRecord > get () { return samRecords ; }
26- }
27-
2822 @ DataProvider (name ="singleContainerSliceDistribution" )
2923 private Object [][] getSingleContainerSliceDistribution () {
3024 final int RECORDS_PER_SLICE = 100 ;
@@ -33,59 +27,59 @@ private Object[][] getSingleContainerSliceDistribution() {
3327 // expected record count/slice, expected slice refContexts,
3428 {
3529 // 1 full single-ref slice with 1 rec
36- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsMapped (1 , 0 )),
30+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsMapped (1 , 0 )),
3731 RECORDS_PER_SLICE , 1 ,
3832 new ReferenceContext (0 ),
3933 1 , Arrays .asList (1 ), Arrays .asList (new ReferenceContext (0 ))
4034 },
4135 {
4236 // 1 full single-ref slice with 1 rec, but allow > 1 slices/container
43- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsMapped (1 , 0 )),
37+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsMapped (1 , 0 )),
4438 RECORDS_PER_SLICE , 2 ,
4539 new ReferenceContext (0 ),
4640 1 , Arrays .asList (1 ), Arrays .asList (new ReferenceContext (0 ))
4741 },
4842 {
4943 // 1 full single-ref slice with RECORDS_PER_SLICE - 1 records
50- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE - 1 , 0 )),
44+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE - 1 , 0 )),
5145 RECORDS_PER_SLICE , 1 ,
5246 new ReferenceContext (0 ),
5347 1 , Arrays .asList (RECORDS_PER_SLICE - 1 ), Arrays .asList (new ReferenceContext (0 ))
5448 },
5549 {
5650 // 1 full single-ref slice with RECORDS_PER_SLICE records
57- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE , 0 )),
51+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE , 0 )),
5852 RECORDS_PER_SLICE , 1 ,
5953 new ReferenceContext (0 ),
6054 1 , Arrays .asList (RECORDS_PER_SLICE ), Arrays .asList (new ReferenceContext (0 ))
6155 },
6256 {
6357 // 2 single-ref slices, one with RECORDS_PER_SLICE records, one with 1 record
64- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE + 1 , 0 )),
58+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE + 1 , 0 )),
6559 RECORDS_PER_SLICE , 2 ,
6660 new ReferenceContext (0 ),
6761 2 , Arrays .asList (RECORDS_PER_SLICE , 1 ),
6862 Arrays .asList (new ReferenceContext (0 ), new ReferenceContext (0 ))
6963 },
7064 {
7165 // 2 single-ref slices, one with RECORDS_PER_SLICE records, one with RECORDS_PER_SLICE - 1
72- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsMapped ((RECORDS_PER_SLICE * 2 ) - 1 , 0 )),
66+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsMapped ((RECORDS_PER_SLICE * 2 ) - 1 , 0 )),
7367 RECORDS_PER_SLICE , 2 ,
7468 new ReferenceContext (0 ),
7569 2 , Arrays .asList (RECORDS_PER_SLICE , RECORDS_PER_SLICE - 1 ),
7670 Arrays .asList (new ReferenceContext (0 ), new ReferenceContext (0 ))
7771 },
7872 {
7973 // 2 full single-ref slices, each with RECORDS_PER_SLICE records
80- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE * 2 , 0 )),
74+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE * 2 , 0 )),
8175 RECORDS_PER_SLICE , 2 ,
8276 new ReferenceContext (0 ),
8377 2 , Arrays .asList (RECORDS_PER_SLICE , RECORDS_PER_SLICE ),
8478 Arrays .asList (new ReferenceContext (0 ), new ReferenceContext (0 ))
8579 },
8680 {
8781 // 3 single-ref slices, two with RECORDS_PER_SLICE records, one with 1 record
88- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsMapped ((RECORDS_PER_SLICE * 2 ) + 1 , 0 )),
82+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsMapped ((RECORDS_PER_SLICE * 2 ) + 1 , 0 )),
8983 RECORDS_PER_SLICE , 3 ,
9084 new ReferenceContext (0 ),
9185 3 , Arrays .asList (RECORDS_PER_SLICE , RECORDS_PER_SLICE , 1 ),
@@ -96,7 +90,7 @@ private Object[][] getSingleContainerSliceDistribution() {
9690 },
9791 {
9892 // 3 full single-ref slices, each with RECORDS_PER_SLICE records
99- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE * 3 , 0 )),
93+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE * 3 , 0 )),
10094 RECORDS_PER_SLICE , 3 ,
10195 new ReferenceContext (0 ),
10296 3 , Arrays .asList (RECORDS_PER_SLICE , RECORDS_PER_SLICE , RECORDS_PER_SLICE ),
@@ -106,51 +100,51 @@ private Object[][] getSingleContainerSliceDistribution() {
106100 // now repeat the tests, but using unmapped records
107101 {
108102 // 1 full single-ref (unmapped) slice with 1 rec
109- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsUnmapped (1 )),
103+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsUnmapped (1 )),
110104 RECORDS_PER_SLICE , 1 ,
111105 ReferenceContext .UNMAPPED_UNPLACED_CONTEXT ,
112106 1 , Arrays .asList (1 ), Arrays .asList (ReferenceContext .UNMAPPED_UNPLACED_CONTEXT )
113107 },
114108 {
115109 // 1 full single-ref (unmapped) slice with 1 rec, but allow > 1 slices/container
116- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsUnmapped (1 )),
110+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsUnmapped (1 )),
117111 RECORDS_PER_SLICE , 2 ,
118112 ReferenceContext .UNMAPPED_UNPLACED_CONTEXT ,
119113 1 , Arrays .asList (1 ), Arrays .asList (ReferenceContext .UNMAPPED_UNPLACED_CONTEXT )
120114 },
121115 {
122116 // 1 full single-ref (unmapped) slice with RECORDS_PER_SLICE - 1 records
123- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsUnmapped (RECORDS_PER_SLICE - 1 )),
117+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsUnmapped (RECORDS_PER_SLICE - 1 )),
124118 RECORDS_PER_SLICE , 1 ,
125119 ReferenceContext .UNMAPPED_UNPLACED_CONTEXT ,
126120 1 , Arrays .asList (RECORDS_PER_SLICE - 1 ), Arrays .asList (ReferenceContext .UNMAPPED_UNPLACED_CONTEXT )
127121 },
128122 {
129123 // 1 full single-ref (unmapped) slice with RECORDS_PER_SLICE records
130- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsUnmapped (RECORDS_PER_SLICE )),
124+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsUnmapped (RECORDS_PER_SLICE )),
131125 RECORDS_PER_SLICE , 1 ,
132126 ReferenceContext .UNMAPPED_UNPLACED_CONTEXT ,
133127 1 , Arrays .asList (RECORDS_PER_SLICE ), Arrays .asList (ReferenceContext .UNMAPPED_UNPLACED_CONTEXT )
134128 },
135129 {
136130 // 2 single-ref (unmapped) slices, one with RECORDS_PER_SLICE records, one with 1 record
137- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsUnmapped (RECORDS_PER_SLICE + 1 )),
131+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsUnmapped (RECORDS_PER_SLICE + 1 )),
138132 RECORDS_PER_SLICE , 2 ,
139133 ReferenceContext .UNMAPPED_UNPLACED_CONTEXT ,
140134 2 , Arrays .asList (RECORDS_PER_SLICE , 1 ),
141135 Arrays .asList (ReferenceContext .UNMAPPED_UNPLACED_CONTEXT , ReferenceContext .UNMAPPED_UNPLACED_CONTEXT )
142136 },
143137 {
144138 // 2 full single-ref (unmapped) slices, each with RECORDS_PER_SLICE records
145- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsUnmapped (RECORDS_PER_SLICE * 2 )),
139+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsUnmapped (RECORDS_PER_SLICE * 2 )),
146140 RECORDS_PER_SLICE , 2 ,
147141 ReferenceContext .UNMAPPED_UNPLACED_CONTEXT ,
148142 2 , Arrays .asList (RECORDS_PER_SLICE , RECORDS_PER_SLICE ),
149143 Arrays .asList (ReferenceContext .UNMAPPED_UNPLACED_CONTEXT , ReferenceContext .UNMAPPED_UNPLACED_CONTEXT )
150144 },
151145 {
152146 // 3 full single-ref (unmapped) slices, each with RECORDS_PER_SLICE records
153- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsUnmapped (RECORDS_PER_SLICE * 3 )),
147+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsUnmapped (RECORDS_PER_SLICE * 3 )),
154148 RECORDS_PER_SLICE , 3 ,
155149 ReferenceContext .UNMAPPED_UNPLACED_CONTEXT ,
156150 3 , Arrays .asList (RECORDS_PER_SLICE , RECORDS_PER_SLICE , RECORDS_PER_SLICE ),
@@ -165,7 +159,7 @@ private Object[][] getSingleContainerSliceDistribution() {
165159 // reference context would be more correctly called a "placed" reference context
166160 {
167161 // 1 full single-ref mapped slice with RECORDS_PER_SLICE records
168- new RecordSupplier (Stream .of (
162+ new QuietTestWrapper <> (Stream .of (
169163 Collections .singletonList (CRAMStructureTestHelper .createSAMRecordUnmappedPlaced (0 , 1 )),
170164 CRAMStructureTestHelper .createSAMRecordsMapped ((RECORDS_PER_SLICE / 2 ) - 2 , 0 ),
171165 Collections .singletonList (CRAMStructureTestHelper .createSAMRecordUnmappedPlaced (0 , 1 )))
@@ -179,15 +173,15 @@ private Object[][] getSingleContainerSliceDistribution() {
179173 // now queryname sorted
180174 {
181175 // 1 full single-ref slice with RECORDS_PER_SLICE-1 records
182- new RecordSupplier (CRAMStructureTestHelper .createQueryNameSortedSAMRecords (RECORDS_PER_SLICE - 1 ,0 )),
176+ new QuietTestWrapper <> (CRAMStructureTestHelper .createQueryNameSortedSAMRecords (RECORDS_PER_SLICE - 1 ,0 )),
183177 RECORDS_PER_SLICE , 1 ,
184178 new ReferenceContext (0 ),
185179 1 , Arrays .asList (RECORDS_PER_SLICE - 1 ),
186180 Arrays .asList (new ReferenceContext (0 ))
187181 },
188182 {
189183 // 2 full single-ref slices, one with with RECORDS_PER_SLICE records and one record
190- new RecordSupplier (CRAMStructureTestHelper .createQueryNameSortedSAMRecords (RECORDS_PER_SLICE + 1 ,0 )),
184+ new QuietTestWrapper <> (CRAMStructureTestHelper .createQueryNameSortedSAMRecords (RECORDS_PER_SLICE + 1 ,0 )),
191185 RECORDS_PER_SLICE , 2 ,
192186 new ReferenceContext (0 ),
193187 2 , Arrays .asList (RECORDS_PER_SLICE , 1 ),
@@ -196,7 +190,7 @@ private Object[][] getSingleContainerSliceDistribution() {
196190 {
197191 // use a small number of records from multiple (not coordinate-ordered) reference contexts to
198192 // force creation of a multi-ref container
199- new RecordSupplier (Stream .of (
193+ new QuietTestWrapper <> (Stream .of (
200194 CRAMStructureTestHelper .createQueryNameSortedSAMRecords (2 ,1 ),
201195 CRAMStructureTestHelper .createQueryNameSortedSAMRecords (2 ,0 ),
202196 CRAMStructureTestHelper .createQueryNameSortedSAMRecords (2 ,1 ))
@@ -214,7 +208,7 @@ private Object[][] getSingleContainerSliceDistribution() {
214208
215209 @ Test (dataProvider = "singleContainerSliceDistribution" )
216210 public void testSingleContainerSliceDistribution (
217- final Supplier <List <SAMRecord >> samRecordSupplier ,
211+ final QuietTestWrapper <List <SAMRecord >> samRecordSupplier ,
218212 final int readsPerSlice ,
219213 final int slicesPerContainer ,
220214 final ReferenceContext expectedContainerReferenceContext ,
@@ -257,21 +251,21 @@ private Object[][] getMultipleContainerSliceDistribution() {
257251 // expected slices per container
258252 {
259253 // this generates two containers since it has two containers worth of records mapped to a single ref
260- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE * 2 , 0 )),
254+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE * 2 , 0 )),
261255 RECORDS_PER_SLICE , 1 ,
262256 2 , Arrays .asList (RECORDS_PER_SLICE , RECORDS_PER_SLICE ),
263257 Arrays .asList (new ReferenceContext (0 ), new ReferenceContext (0 )),
264258 Arrays .asList (1 , 1 )
265259 },
266260 {
267- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE * 3 + 1 , 0 )),
261+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE * 3 + 1 , 0 )),
268262 RECORDS_PER_SLICE , 2 ,
269263 2 , Arrays .asList (RECORDS_PER_SLICE * 2 , RECORDS_PER_SLICE + 1 ),
270264 Arrays .asList (new ReferenceContext (0 ), new ReferenceContext (0 )),
271265 Arrays .asList (2 , 2 )
272266 },
273267 {
274- new RecordSupplier (CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE * 4 , 0 )),
268+ new QuietTestWrapper <> (CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE * 4 , 0 )),
275269 RECORDS_PER_SLICE , 2 ,
276270 2 , Arrays .asList (RECORDS_PER_SLICE * 2 , RECORDS_PER_SLICE * 2 ),
277271 Arrays .asList (new ReferenceContext (0 ), new ReferenceContext (0 )),
@@ -280,7 +274,7 @@ private Object[][] getMultipleContainerSliceDistribution() {
280274 {
281275 // this generates one container because although it has records mapped to two different reference
282276 // contigs, there aren't enough records to reach the minimum single ref threshold
283- new RecordSupplier (Stream .of (
277+ new QuietTestWrapper <> (Stream .of (
284278 CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE - 1 , 0 ),
285279 CRAMStructureTestHelper .createSAMRecordsMapped (1 , 1 ))
286280 .flatMap (List ::stream )
@@ -293,7 +287,7 @@ private Object[][] getMultipleContainerSliceDistribution() {
293287 {
294288 // this generates one container because it has some mapped (but not enough to reach the
295289 // minimum single ref threshold), and one unmapped
296- new RecordSupplier (Stream .of (
290+ new QuietTestWrapper <> (Stream .of (
297291 CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE - 1 , 0 ),
298292 CRAMStructureTestHelper .createSAMRecordsUnmapped (1 ))
299293 .flatMap (List ::stream )
@@ -305,7 +299,7 @@ private Object[][] getMultipleContainerSliceDistribution() {
305299 },
306300 {
307301 // this generates two containers since it has some mapped and one unmapped
308- new RecordSupplier (Stream .of (
302+ new QuietTestWrapper <> (Stream .of (
309303 CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE * 2 , 0 ),
310304 CRAMStructureTestHelper .createSAMRecordsUnmapped (RECORDS_PER_SLICE ))
311305 .flatMap (List ::stream )
@@ -318,7 +312,7 @@ private Object[][] getMultipleContainerSliceDistribution() {
318312 {
319313 // this generates two containers since it has some mapped, but not enough to emit a single
320314 // ref container, and one unmapped, which goes into a second container
321- new RecordSupplier (Stream .of (
315+ new QuietTestWrapper <> (Stream .of (
322316 CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE / 2 , 0 ),
323317 CRAMStructureTestHelper .createSAMRecordsUnmapped (RECORDS_PER_SLICE ))
324318 .flatMap (List ::stream )
@@ -334,7 +328,7 @@ private Object[][] getMultipleContainerSliceDistribution() {
334328 // even though we allow 2 slices/container, this generates two containers since it has
335329 // some mapped and one unmapped, and we won't emit a second single-ref slice into the
336330 // first container once we've emitted the multi-ref slice!
337- new RecordSupplier (Stream .of (
331+ new QuietTestWrapper <> (Stream .of (
338332 CRAMStructureTestHelper .createSAMRecordsMapped (RECORDS_PER_SLICE / 2 , 0 ),
339333 CRAMStructureTestHelper .createSAMRecordsUnmapped (RECORDS_PER_SLICE ))
340334 .flatMap (List ::stream )
@@ -353,7 +347,7 @@ private Object[][] getMultipleContainerSliceDistribution() {
353347 // use records from multiple (not coordinate-ordered) reference contexts to
354348 // force creation of one multi-ref (after name sorting, the first container has a mix of
355349 // ref 0 and ref 1), and one single ref container
356- new RecordSupplier (Stream .of (
350+ new QuietTestWrapper <> (Stream .of (
357351 CRAMStructureTestHelper .createQueryNameSortedSAMRecords (RECORDS_PER_SLICE /2 ,1 ),
358352 CRAMStructureTestHelper .createQueryNameSortedSAMRecords (RECORDS_PER_SLICE /2 ,0 ),
359353 CRAMStructureTestHelper .createQueryNameSortedSAMRecords (RECORDS_PER_SLICE ,1 ))
0 commit comments