Search in sources :

Example 1 with IntervalListReferenceSequenceMask

use of htsjdk.samtools.util.IntervalListReferenceSequenceMask in project gatk by broadinstitute.

the class CollectSequencingArtifactMetrics method setup.

@Override
protected void setup(final SAMFileHeader header, final File samFile) {
    preAdapterSummaryOut = new File(OUTPUT + SequencingArtifactMetrics.PRE_ADAPTER_SUMMARY_EXT);
    preAdapterDetailsOut = new File(OUTPUT + SequencingArtifactMetrics.PRE_ADAPTER_DETAILS_EXT);
    baitBiasSummaryOut = new File(OUTPUT + SequencingArtifactMetrics.BAIT_BIAS_SUMMARY_EXT);
    baitBiasDetailsOut = new File(OUTPUT + SequencingArtifactMetrics.BAIT_BIAS_DETAILS_EXT);
    IOUtil.assertFileIsWritable(preAdapterSummaryOut);
    IOUtil.assertFileIsWritable(preAdapterDetailsOut);
    IOUtil.assertFileIsWritable(baitBiasSummaryOut);
    IOUtil.assertFileIsWritable(baitBiasDetailsOut);
    for (final SAMReadGroupRecord rec : header.getReadGroups()) {
        samples.add(getOrElse(rec.getSample(), UNKNOWN_SAMPLE));
        libraries.add(getOrElse(rec.getLibrary(), UNKNOWN_LIBRARY));
    }
    if (INTERVALS != null) {
        IOUtil.assertFileIsReadable(INTERVALS);
        intervalMask = new IntervalListReferenceSequenceMask(IntervalList.fromFile(INTERVALS).uniqued());
    }
    if (DB_SNP != null) {
        IOUtil.assertFileIsReadable(DB_SNP);
        dbSnpMask = new DbSnpBitSetUtil(DB_SNP, header.getSequenceDictionary());
    }
    // set record-level filters
    final List<SamRecordFilter> filters = new ArrayList<>();
    filters.add(new FailsVendorReadQualityFilter());
    filters.add(new NotPrimaryAlignmentFilter());
    filters.add(new DuplicateReadFilter());
    // discard unmapped reads
    filters.add(new AlignedFilter(true));
    filters.add(new MappingQualityFilter(MINIMUM_MAPPING_QUALITY));
    if (!INCLUDE_UNPAIRED) {
        final int effectiveMaxInsertSize = (MAXIMUM_INSERT_SIZE == 0) ? Integer.MAX_VALUE : MAXIMUM_INSERT_SIZE;
        filters.add(new InsertSizeFilter(MINIMUM_INSERT_SIZE, effectiveMaxInsertSize));
    }
    recordFilter = new AggregateFilter(filters);
    // set up the artifact counters
    final String sampleAlias = StringUtil.join(",", new ArrayList<>(samples));
    for (final String library : libraries) {
        artifactCounters.put(library, new ArtifactCounter(sampleAlias, library, CONTEXT_SIZE, TANDEM_READS));
    }
}
Also used : SAMReadGroupRecord(htsjdk.samtools.SAMReadGroupRecord) DbSnpBitSetUtil(org.broadinstitute.hellbender.utils.variant.DbSnpBitSetUtil) IntervalListReferenceSequenceMask(htsjdk.samtools.util.IntervalListReferenceSequenceMask) MetricsFile(htsjdk.samtools.metrics.MetricsFile) File(java.io.File)

Aggregations

SAMReadGroupRecord (htsjdk.samtools.SAMReadGroupRecord)1 MetricsFile (htsjdk.samtools.metrics.MetricsFile)1 IntervalListReferenceSequenceMask (htsjdk.samtools.util.IntervalListReferenceSequenceMask)1 File (java.io.File)1 DbSnpBitSetUtil (org.broadinstitute.hellbender.utils.variant.DbSnpBitSetUtil)1