@Test public void testFilteredCounts() { final GenomeAnalysisEngine engine = new GenomeAnalysisEngine(); engine.setGenomeLocParser(genomeLocParser); final Collection<SAMReaderID> samFiles = new ArrayList<>(); final SAMReaderID readerID = new SAMReaderID(testBAM, new Tags()); samFiles.add(readerID); final List<ReadFilter> filters = new ArrayList<>(); filters.add(new EveryTenthReadFilter()); final SAMDataSource dataSource = new SAMDataSource( samFiles, new ThreadAllocation(), null, genomeLocParser, false, SAMFileReader.ValidationStringency.STRICT, null, null, new ValidationExclusion(), filters, new ArrayList<ReadTransformer>(), false, (byte) 30, false, true); engine.setReadsDataSource(dataSource); final TraverseReadsNano traverseReadsNano = new TraverseReadsNano(1); final DummyReadWalker walker = new DummyReadWalker(); traverseReadsNano.initialize(engine, walker, null); for (final Shard shard : dataSource.createShardIteratorOverAllReads(new ReadShardBalancer())) { final ReadShardDataProvider dataProvider = new ReadShardDataProvider( shard, engine.getGenomeLocParser(), dataSource.seek(shard), reference, new ArrayList<ReferenceOrderedDataSource>()); traverseReadsNano.traverse(walker, dataProvider, 0); dataProvider.close(); } Assert.assertEquals( (long) engine .getCumulativeMetrics() .getCountsByFilter() .get(EveryTenthReadFilter.class.getSimpleName()), contigs.size() * numReadsPerContig / 10); }
@BeforeClass private void init() throws IOException { reference = new CachingIndexedFastaSequenceFile(new File(b37KGReference)); dictionary = reference.getSequenceDictionary(); genomeLocParser = new GenomeLocParser(dictionary); header = ArtificialSAMUtils.createDefaultReadGroup(new SAMFileHeader(), "test", "test"); header.setSequenceDictionary(dictionary); header.setSortOrder(SAMFileHeader.SortOrder.coordinate); readGroup = new GATKSAMReadGroupRecord(header.getReadGroup("test")); final List<GATKSAMRecord> reads = new ArrayList<>(); for (final String contig : contigs) { for (int i = 1; i <= numReadsPerContig; i++) { reads.add(buildSAMRecord("read" + contig + "_" + i, contig, i)); } } createBAM(reads); }
@Test public void testCountsFromActiveRegionTraversal() { final GenomeAnalysisEngine engine = new GenomeAnalysisEngine(); engine.setGenomeLocParser(genomeLocParser); final Collection<SAMReaderID> samFiles = new ArrayList<>(); final SAMReaderID readerID = new SAMReaderID(testBAM, new Tags()); samFiles.add(readerID); final SAMDataSource dataSource = new SAMDataSource( samFiles, new ThreadAllocation(), null, genomeLocParser, false, SAMFileReader.ValidationStringency.STRICT, null, null, new ValidationExclusion(), new ArrayList<ReadFilter>(), new ArrayList<ReadTransformer>(), false, (byte) 30, false, true); engine.setReadsDataSource(dataSource); final Set<String> samples = SampleUtils.getSAMFileSamples(dataSource.getHeader()); final List<GenomeLoc> intervals = new ArrayList<>(contigs.size()); for (final String contig : contigs) intervals.add(genomeLocParser.createGenomeLoc(contig, 1, numReadsPerContig)); final TraverseActiveRegions traverseActiveRegions = new TraverseActiveRegions(); final DummyActiveRegionWalker walker = new DummyActiveRegionWalker(); traverseActiveRegions.initialize(engine, walker, null); for (final Shard shard : dataSource.createShardIteratorOverIntervals( new GenomeLocSortedSet(genomeLocParser, intervals), new ActiveRegionShardBalancer())) { final WindowMaker windowMaker = new WindowMaker( shard, genomeLocParser, dataSource.seek(shard), shard.getGenomeLocs(), samples); for (WindowMaker.WindowMakerIterator window : windowMaker) { final LocusShardDataProvider dataProvider = new LocusShardDataProvider( shard, shard.getReadProperties(), genomeLocParser, window.getLocus(), window, reference, new ArrayList<ReferenceOrderedDataSource>()); traverseActiveRegions.traverse(walker, dataProvider, 0); dataProvider.close(); } windowMaker.close(); } Assert.assertEquals( engine.getCumulativeMetrics().getNumReadsSeen(), contigs.size() * numReadsPerContig); Assert.assertEquals( engine.getCumulativeMetrics().getNumIterations(), contigs.size() * numReadsPerContig); }