Search in sources :

Example 6 with SAMRecordToGATKReadAdapter

use of org.broadinstitute.hellbender.utils.read.SAMRecordToGATKReadAdapter in project gatk by broadinstitute.

the class ReadFilterLibraryUnitTest method failsVALID_ALIGNMENT_START.

@Test
public void failsVALID_ALIGNMENT_START() {
    final SAMFileHeader header = createHeaderWithReadGroups();
    final GATKRead read = simpleGoodRead(header);
    // GATKRead interface will not let us set invalid alignment starts,
    final SAMRecord corruptSAM = read.convertToSAMRecord(header);
    // so we need to convert to SAMRecord here
    corruptSAM.setAlignmentStart(-1);
    Assert.assertFalse(VALID_ALIGNMENT_START.test(new SAMRecordToGATKReadAdapter(corruptSAM)), read.toString());
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SAMRecordToGATKReadAdapter(org.broadinstitute.hellbender.utils.read.SAMRecordToGATKReadAdapter) Test(org.testng.annotations.Test)

Example 7 with SAMRecordToGATKReadAdapter

use of org.broadinstitute.hellbender.utils.read.SAMRecordToGATKReadAdapter in project gatk by broadinstitute.

the class ReadsSparkSourceUnitTest method testHeadersAreStripped.

@Test(groups = "spark")
public void testHeadersAreStripped() {
    JavaSparkContext ctx = SparkContextFactory.getTestSparkContext();
    ReadsSparkSource readSource = new ReadsSparkSource(ctx);
    final List<GATKRead> reads = readSource.getParallelReads(dirBQSR + "HiSeq.1mb.1RG.2k_lines.alternate.bam", null).collect();
    for (final GATKRead read : reads) {
        Assert.assertNull(((SAMRecordToGATKReadAdapter) read).getEncapsulatedSamRecord().getHeader(), "ReadSparkSource failed to null out header for read");
    }
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SAMRecordToGATKReadAdapter(org.broadinstitute.hellbender.utils.read.SAMRecordToGATKReadAdapter) JavaSparkContext(org.apache.spark.api.java.JavaSparkContext) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 8 with SAMRecordToGATKReadAdapter

use of org.broadinstitute.hellbender.utils.read.SAMRecordToGATKReadAdapter 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

SAMRecordToGATKReadAdapter (org.broadinstitute.hellbender.utils.read.SAMRecordToGATKReadAdapter)8 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)5 Test (org.testng.annotations.Test)5 SAMRecord (htsjdk.samtools.SAMRecord)4 File (java.io.File)2 SparkConf (org.apache.spark.SparkConf)2 SamReader (htsjdk.samtools.SamReader)1 MetricsFile (htsjdk.samtools.metrics.MetricsFile)1 ArrayList (java.util.ArrayList)1 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)1 QualityYieldMetrics (org.broadinstitute.hellbender.metrics.QualityYieldMetrics)1 SAMFileGATKReadWriter (org.broadinstitute.hellbender.utils.read.SAMFileGATKReadWriter)1 ProgressLogger (org.broadinstitute.hellbender.utils.runtime.ProgressLogger)1 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)1