Source:
protected int doWork() { for (final File targetInterval : TARGET_INTERVALS) IOUtil.assertFileIsReadable(targetInterval); IOUtil.assertFileIsReadable(INPUT); IOUtil.assertFileIsWritable(OUTPUT); if (PER_TARGET_COVERAGE != null) IOUtil.assertFileIsWritable(PER_TARGET_COVERAGE); final SamReader reader = SamReaderFactory.makeDefault().referenceSequence(REFERENCE_SEQUENCE).open(INPUT); final IntervalList targetIntervals = IntervalList.fromFiles(TARGET_INTERVALS); SequenceUtil.assertSequenceDictionariesEqual( reader.getFileHeader().getSequenceDictionary(), targetIntervals.getHeader().getSequenceDictionary()); SequenceUtil.assertSequenceDictionariesEqual( reader.getFileHeader().getSequenceDictionary(), getProbeIntervals().getHeader().getSequenceDictionary() ); ReferenceSequenceFile ref = null; if (REFERENCE_SEQUENCE != null) { IOUtil.assertFileIsReadable(REFERENCE_SEQUENCE); ref = ReferenceSequenceFileFactory.getReferenceSequenceFile(REFERENCE_SEQUENCE); SequenceUtil.assertSequenceDictionariesEqual( reader.getFileHeader().getSequenceDictionary(), ref.getSequenceDictionary(), INPUT, REFERENCE_SEQUENCE ); } final COLLECTOR collector = makeCollector( METRIC_ACCUMULATION_LEVEL, reader.getFileHeader().getReadGroups(), ref, PER_TARGET_COVERAGE, targetIntervals, getProbeIntervals(), getProbeSetName() ); final ProgressLogger progress = new ProgressLogger(log); for (final SAMRecord record : reader) { collector.acceptRecord(record, null); progress.record(record); } final MetricsFile<METRIC, Integer> metrics = getMetricsFile(); collector.finish(); collector.addAllLevelsToFile(metrics); metrics.write(OUTPUT); return 0; }

Target:
protected int doWork() { for (final File targetInterval : TARGET_INTERVALS) IOUtil.assertFileIsReadable(targetInterval); IOUtil.assertFileIsReadable(INPUT); IOUtil.assertFileIsWritable(OUTPUT); if (PER_TARGET_COVERAGE != null) IOUtil.assertFileIsWritable(PER_TARGET_COVERAGE); final SamReader reader = SamReaderFactory.makeDefault().referenceSequence(REFERENCE_SEQUENCE).open(INPUT); final IntervalList targetIntervals = IntervalList.fromFiles(TARGET_INTERVALS); SequenceUtil.assertSequenceDictionariesEqual( reader.getFileHeader().getSequenceDictionary(), targetIntervals.getHeader().getSequenceDictionary()); SequenceUtil.assertSequenceDictionariesEqual( reader.getFileHeader().getSequenceDictionary(), getProbeIntervals().getHeader().getSequenceDictionary() ); ReferenceSequenceFile ref = null; if (REFERENCE_SEQUENCE != null) { IOUtil.assertFileIsReadable(REFERENCE_SEQUENCE); ref = ReferenceSequenceFileFactory.getReferenceSequenceFile(REFERENCE_SEQUENCE); SequenceUtil.assertSequenceDictionariesEqual( reader.getFileHeader().getSequenceDictionary(), ref.getSequenceDictionary(), INPUT, REFERENCE_SEQUENCE ); } final COLLECTOR collector = makeCollector( METRIC_ACCUMULATION_LEVEL, reader.getFileHeader().getReadGroups(), ref, PER_TARGET_COVERAGE, targetIntervals, getProbeIntervals(), getProbeSetName() ); final ProgressLogger progress = new ProgressLogger(log); for (final SAMRecord record : reader) { collector.acceptRecord(record, null); progress.record(record); } final MetricsFile<METRIC, Integer> metrics = getMetricsFile(); collector.finish(); collector.addAllLevelsToFile(metrics); metrics.write(OUTPUT); CloserUtil.close(reader); return 0; }