use of org.broadinstitute.hellbender.utils.runtime.ProgressLogger in project gatk by broadinstitute.
the class CollectQualityYieldMetrics method doWork.
/**
* Main method for the program. Checks that all input files are present and
* readable and that the output file can be written to. Then iterates through
* all the records accumulating metrics. Finally writes metrics file
*/
@Override
protected Object doWork() {
final ProgressLogger progress = new ProgressLogger(logger);
File output = new File(qualityYieldMetricsArgs.output);
// Some quick parameter checking
IOUtil.assertFileIsReadable(INPUT);
IOUtil.assertFileIsWritable(output);
logger.info("Reading input file and calculating metrics.");
final SamReader sam = SamReaderFactory.makeDefault().referenceSequence(REFERENCE_SEQUENCE).open(INPUT);
final MetricsFile<QualityYieldMetrics, Integer> metricsFile = getMetricsFile();
final QualityYieldMetrics metrics = new QualityYieldMetrics();
metrics.setUseOriginalQualities(qualityYieldMetricsArgs.useOriginalQualities);
for (final SAMRecord rec : sam) {
metrics.addRead(new SAMRecordToGATKReadAdapter(rec));
progress.record(rec);
}
metrics.finish();
metricsFile.addMetric(metrics);
metricsFile.write(output);
return null;
}
Aggregations