Source:
<code>protected int doWork() { IOUtil.assertFileIsReadable(INPUT); IOUtil.assertFileIsWritable(OUTPUT); final ProgressLogger progress = new ProgressLogger(log, 50000000, "Processed", "read pairs"); final SamReader reader = SamReaderFactory.makeDefault().open(INPUT); final PeekableIterator<SAMRecord> iterator = new PeekableIterator<>(reader.iterator()); final IntermediateMetrics usableMetrics = new IntermediateMetrics(); usableMetrics.metrics.TYPE = FILTERING_STRINGENCY.USABLE; final IntermediateMetrics rawMetrics = new IntermediateMetrics(); rawMetrics.metrics.TYPE = FILTERING_STRINGENCY.RAW; QuerySortedReadPairIteratorUtil.ReadPair pairToAnalyze = QuerySortedReadPairIteratorUtil.getNextReadPair(iterator); while (pairToAnalyze != null) { calculateMetricsForRead(pairToAnalyze, usableMetrics, MINIMUM_USABLE_MAPPING_QUALITY, MINIMUM_USABLE_BASE_QUALITY); calculateMetricsForRead(pairToAnalyze, rawMetrics, MINIMUM_RAW_MAPPING_QUALITY, MINIMUM_RAW_BASE_QUALITY); progress.record(pairToAnalyze.read1); pairToAnalyze = QuerySortedReadPairIteratorUtil.getNextReadPair(iterator); } <START> final long genomeTerritory = (GENOME_TERRITORY == null) ? reader.getFileHeader().getSequenceDictionary().getReferenceLength() : GENOME_TERRITORY; <END> usableMetrics.metrics.GENOME_TERRITORY = genomeTerritory; finalizeMetrics(usableMetrics); rawMetrics.metrics.GENOME_TERRITORY = genomeTerritory; finalizeMetrics(rawMetrics); final MetricsFile<QuerySortedSeqMetrics, Integer> out = getMetricsFile(); out.addMetric(usableMetrics.metrics); out.addMetric(rawMetrics.metrics); out.write(OUTPUT); return 0; }</code><technical_language>add validation for GENOME_TERRITORY - values > 0 valid</technical_language>

Target:
protected int doWork() { IOUtil.assertFileIsReadable(INPUT); IOUtil.assertFileIsWritable(OUTPUT); final ProgressLogger progress = new ProgressLogger(log, 50000000, "Processed", "read pairs"); final SamReader reader = SamReaderFactory.makeDefault().open(INPUT); final PeekableIterator<SAMRecord> iterator = new PeekableIterator<>(reader.iterator()); final IntermediateMetrics usableMetrics = new IntermediateMetrics(); usableMetrics.metrics.TYPE = FILTERING_STRINGENCY.USABLE; final IntermediateMetrics rawMetrics = new IntermediateMetrics(); rawMetrics.metrics.TYPE = FILTERING_STRINGENCY.RAW; QuerySortedReadPairIteratorUtil.ReadPair pairToAnalyze = QuerySortedReadPairIteratorUtil.getNextReadPair(iterator); while (pairToAnalyze != null) { calculateMetricsForRead(pairToAnalyze, usableMetrics, MINIMUM_USABLE_MAPPING_QUALITY, MINIMUM_USABLE_BASE_QUALITY); calculateMetricsForRead(pairToAnalyze, rawMetrics, MINIMUM_RAW_MAPPING_QUALITY, MINIMUM_RAW_BASE_QUALITY); progress.record(pairToAnalyze.read1); pairToAnalyze = QuerySortedReadPairIteratorUtil.getNextReadPair(iterator); } final long genomeTerritory = (GENOME_TERRITORY == null || GENOME_TERRITORY < 1L) ? reader.getFileHeader().getSequenceDictionary().getReferenceLength() : GENOME_TERRITORY; usableMetrics.metrics.GENOME_TERRITORY = genomeTerritory; finalizeMetrics(usableMetrics); rawMetrics.metrics.GENOME_TERRITORY = genomeTerritory; finalizeMetrics(rawMetrics); final MetricsFile<QuerySortedSeqMetrics, Integer> out = getMetricsFile(); out.addMetric(usableMetrics.metrics); out.addMetric(rawMetrics.metrics); out.write(OUTPUT); return 0; }