Search in sources :

Example 1 with QualityYieldMetrics

use of org.broadinstitute.hellbender.metrics.QualityYieldMetrics in project gatk by broadinstitute.

the class QualityYieldMetricsCollectorSpark method collectMetrics.

/**
     * Do the actual metrics collection on the provided RDD.
     * @param filteredReads The reads to be analyzed for this collector.
     * @param samHeader The SAMFileHeader associated with the reads in the input RDD.
     */
@Override
public void collectMetrics(final JavaRDD<GATKRead> filteredReads, final SAMFileHeader samHeader) {
    final QualityYieldMetrics metrics = filteredReads.aggregate(new QualityYieldMetrics().setUseOriginalQualities(args.useOriginalQualities), (hgp, read) -> hgp.addRead(read), (hgp1, hgp2) -> hgp1.combine(hgp2)).finish();
    metricsFile.addMetric(metrics);
}
Also used : Header(htsjdk.samtools.metrics.Header) QualityYieldMetrics(org.broadinstitute.hellbender.metrics.QualityYieldMetrics) ReadFilter(org.broadinstitute.hellbender.engine.filters.ReadFilter) MetricsFile(htsjdk.samtools.metrics.MetricsFile) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SAMFileHeader(htsjdk.samtools.SAMFileHeader) AuthHolder(org.broadinstitute.hellbender.engine.AuthHolder) Serializable(java.io.Serializable) MetricsUtils(org.broadinstitute.hellbender.metrics.MetricsUtils) List(java.util.List) QualityYieldMetricsArgumentCollection(org.broadinstitute.hellbender.metrics.QualityYieldMetricsArgumentCollection) JavaRDD(org.apache.spark.api.java.JavaRDD) ReadFilterLibrary(org.broadinstitute.hellbender.engine.filters.ReadFilterLibrary) QualityYieldMetrics(org.broadinstitute.hellbender.metrics.QualityYieldMetrics)

Example 2 with QualityYieldMetrics

use of org.broadinstitute.hellbender.metrics.QualityYieldMetrics 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;
}
Also used : SamReader(htsjdk.samtools.SamReader) QualityYieldMetrics(org.broadinstitute.hellbender.metrics.QualityYieldMetrics) SAMRecordToGATKReadAdapter(org.broadinstitute.hellbender.utils.read.SAMRecordToGATKReadAdapter) SAMRecord(htsjdk.samtools.SAMRecord) ProgressLogger(org.broadinstitute.hellbender.utils.runtime.ProgressLogger) MetricsFile(htsjdk.samtools.metrics.MetricsFile) File(java.io.File)

Aggregations

MetricsFile (htsjdk.samtools.metrics.MetricsFile)2 QualityYieldMetrics (org.broadinstitute.hellbender.metrics.QualityYieldMetrics)2 SAMFileHeader (htsjdk.samtools.SAMFileHeader)1 SAMRecord (htsjdk.samtools.SAMRecord)1 SamReader (htsjdk.samtools.SamReader)1 Header (htsjdk.samtools.metrics.Header)1 File (java.io.File)1 Serializable (java.io.Serializable)1 List (java.util.List)1 JavaRDD (org.apache.spark.api.java.JavaRDD)1 AuthHolder (org.broadinstitute.hellbender.engine.AuthHolder)1 ReadFilter (org.broadinstitute.hellbender.engine.filters.ReadFilter)1 ReadFilterLibrary (org.broadinstitute.hellbender.engine.filters.ReadFilterLibrary)1 MetricsUtils (org.broadinstitute.hellbender.metrics.MetricsUtils)1 QualityYieldMetricsArgumentCollection (org.broadinstitute.hellbender.metrics.QualityYieldMetricsArgumentCollection)1 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)1 SAMRecordToGATKReadAdapter (org.broadinstitute.hellbender.utils.read.SAMRecordToGATKReadAdapter)1 ProgressLogger (org.broadinstitute.hellbender.utils.runtime.ProgressLogger)1