public Sam2CramRecordFactory(final byte[] refBases, final SAMFileHeader samFileHeader, final Version version) { this.refBases = refBases; this.version = version; this.header = samFileHeader; final List<SAMReadGroupRecord> readGroups = samFileHeader.getReadGroups(); for (int i = 0; i < readGroups.size(); i++) { final SAMReadGroupRecord readGroupRecord = readGroups.get(i); readGroupMap.put(readGroupRecord.getId(), i); } }
private boolean compareReadGroups(final SAMFileHeader h1, final SAMFileHeader h2) { final List<SAMReadGroupRecord> l1 = h1.getReadGroups(); final List<SAMReadGroupRecord> l2 = h2.getReadGroups(); if (!compareValues(l1.size(), l2.size(), "Number of read groups")) { return false; } boolean ret = true; for (int i = 0; i < l1.size(); ++i) { ret = compareReadGroup(l1.get(i), l2.get(i)) && ret; } return ret; }
public SAMRecordDuplicateComparator(final List<SAMFileHeader> headers) { // pre-populate the library names for (final SAMFileHeader header : headers) { for (final SAMReadGroupRecord readGroup : header.getReadGroups()) { final String libraryName = readGroup.getLibrary(); if (null != libraryName) { final short libraryId = this.nextLibraryId++; this.libraryIds.put(libraryName, libraryId); } } } }
public LibraryIdGenerator(final SAMFileHeader header) { this.header = header; for (final SAMReadGroupRecord readGroup : header.getReadGroups()) { final String library = LibraryIdGenerator.getReadGroupLibraryName(readGroup); DuplicationMetrics metrics = metricsByLibrary.get(library); if (metrics == null) { metrics = new DuplicationMetrics(); metrics.LIBRARY = library; metricsByLibrary.put(library, metrics); } } }
@Override protected void setup(final SAMFileHeader header, final File samFile) { IOUtil.assertFileIsWritable(OUTPUT); IOUtil.assertFileIsWritable(CHART_OUTPUT); // If we're working with a single library, assign that library's name // as a suffix to the plot title final List<SAMReadGroupRecord> readGroups = header.getReadGroups(); if (readGroups.size() == 1) { this.plotSubtitle = readGroups.get(0).getLibrary(); if (null == this.plotSubtitle) this.plotSubtitle = ""; } }
@Override protected void setup(final SAMFileHeader header, final File samFile) { IOUtil.assertFileIsWritable(CHART_OUTPUT); // If we're working with a single library, assign that library's name // as a suffix to the plot title final List<SAMReadGroupRecord> readGroups = header.getReadGroups(); if (readGroups.size() == 1) { plotSubtitle = StringUtil.asEmptyIfNull(readGroups.get(0).getLibrary()); } }
@Override protected void setup(final SAMFileHeader header, final File samFile) { IOUtil.assertFileIsWritable(OUTPUT); IOUtil.assertFileIsWritable(CHART_OUTPUT); // If we're working with a single library, assign that library's name // as a suffix to the plot title final List<SAMReadGroupRecord> readGroups = header.getReadGroups(); if (readGroups.size() == 1) { this.plotSubtitle = readGroups.get(0).getLibrary(); if (null == this.plotSubtitle) this.plotSubtitle = ""; } }
private Map<String, SAMFileHeader> createHeaderMap( final SAMFileHeader inHeader, final SortOrder sortOrder, final boolean removeAlignmentInformation) { final Map<String, SAMFileHeader> headerMap = new HashMap<>(); for (final SAMReadGroupRecord readGroup : inHeader.getReadGroups()) { final SAMFileHeader header = createOutHeader(inHeader, sortOrder, removeAlignmentInformation); header.addReadGroup(readGroup); headerMap.put(readGroup.getId(), header); } return headerMap; }
/** * Initialize the recalibration engine */ private void initializeRecalibrationEngine() { int numReadGroups = 0; for ( final SAMFileHeader header : getToolkit().getSAMFileHeaders() ) numReadGroups += header.getReadGroups().size(); recalibrationEngine = new RecalibrationEngine(requestedCovariates, numReadGroups, RAC.RECAL_TABLE_UPDATE_LOG, lowMemoryMode); }
@Override protected void setup(final SAMFileHeader header, final File samFile) { IOUtil.assertFileIsWritable(CHART_OUTPUT); final List<SAMReadGroupRecord> readGroups = header.getReadGroups(); if (readGroups.size() == 1) { plotSubtitle = StringUtil.asEmptyIfNull(readGroups.get(0).getLibrary()); } hist = new HistogramGenerator(); }
@Override public void initialize() { for ( final SAMReadGroupRecord rg : getToolkit().getSAMFileHeader().getReadGroups() ) { readGroupInfo.put(rg.getId(), new PerReadGroupInfo()); } }
@Override protected void setup(final SAMFileHeader header, final File samFile) { IOUtil.assertFileIsWritable(OUTPUT); IOUtil.assertFileIsWritable(Histogram_FILE); //Delegate actual collection to InsertSizeMetricCollector multiCollector = new InsertSizeMetricsCollector(METRIC_ACCUMULATION_LEVEL, header.getReadGroups(), MINIMUM_PCT, HISTOGRAM_WIDTH, DEVIATIONS, INCLUDE_DUPLICATES); }
@Override protected void setup(final SAMFileHeader header, final File samFile) { IOUtil.assertFileIsWritable(OUTPUT); IOUtil.assertFileIsWritable(Histogram_FILE); //Delegate actual collection to InsertSizeMetricCollector multiCollector = new InsertSizeMetricsCollector(METRIC_ACCUMULATION_LEVEL, header.getReadGroups(), MINIMUM_PCT, HISTOGRAM_WIDTH, DEVIATIONS, INCLUDE_DUPLICATES); }
@Override protected void setup(final SAMFileHeader header, final File samFile) { IOUtil.assertFileIsWritable(OUTPUT); if (header.getSequenceDictionary().isEmpty()) { log.warn(INPUT.getAbsoluteFile() + " has no sequence dictionary. If any reads " + "in the file are aligned, then alignment summary metrics collection will fail."); } final boolean doRefMetrics = REFERENCE_SEQUENCE != null; collector = new AlignmentSummaryMetricsCollector(METRIC_ACCUMULATION_LEVEL, header.getReadGroups(), doRefMetrics, ADAPTER_SEQUENCE, MAX_INSERT_SIZE, EXPECTED_PAIR_ORIENTATIONS, IS_BISULFITE_SEQUENCED); }
@Override protected void setup(final SAMFileHeader header, final File samFile) { IOUtil.assertFileIsWritable(OUTPUT); if (header.getSequenceDictionary().isEmpty()) { log.warn(INPUT.getAbsoluteFile() + " has no sequence dictionary. If any reads " + "in the file are aligned, then alignment summary metrics collection will fail."); } final boolean doRefMetrics = REFERENCE_SEQUENCE != null; collector = new AlignmentSummaryMetricsCollector(METRIC_ACCUMULATION_LEVEL, header.getReadGroups(), doRefMetrics, ADAPTER_SEQUENCE, MAX_INSERT_SIZE, EXPECTED_PAIR_ORIENTATIONS, IS_BISULFITE_SEQUENCED); }
@Override protected void setup(final SAMFileHeader header, final File samFile) { IOUtil.assertFileIsWritable(OUTPUT); if (Histogram_FILE != null) { IOUtil.assertFileIsWritable(Histogram_FILE); } //Delegate actual collection to GcMetricsCollector multiCollector = new GcMetricsCollector(UNPAIRED_FRAGMENT_SIZE, getReadPairConcordanceCalculator(), METRIC_ACCUMULATION_LEVEL, header.getReadGroups()); }
@Override protected void setup(final SAMFileHeader header, final File samFile) { IOUtil.assertFileIsWritable(CHART_OUTPUT); IOUtil.assertFileIsWritable(SUMMARY_OUTPUT); IOUtil.assertFileIsReadable(REFERENCE_SEQUENCE); //Calculate windowsByGc for the reference sequence final int[] windowsByGc = GcBiasUtils.calculateRefWindowsByGc(BINS, REFERENCE_SEQUENCE, SCAN_WINDOW_SIZE); //Delegate actual collection to GcBiasMetricCollector multiCollector = new GcBiasMetricsCollector(METRIC_ACCUMULATION_LEVEL, windowsByGc, header.getReadGroups(), SCAN_WINDOW_SIZE, IS_BISULFITE_SEQUENCED, ALSO_IGNORE_DUPLICATES); }
/** * Returns the platform unit for a read group given its index. * * @param group the index of the targeted read group in the range * [1,{@link #getReadGroupCount()}] * @return never <code>null</code>. */ protected final String getPlatformUnit(final int group) { checkReadGroupIndex(group); return getHeader().getReadGroups().get(group - 1).getPlatformUnit(); }
public static SAMFileHeader duplicateSAMFileHeader(SAMFileHeader toCopy) { SAMFileHeader copy = new SAMFileHeader(); copy.setSortOrder(toCopy.getSortOrder()); copy.setGroupOrder(toCopy.getGroupOrder()); copy.setProgramRecords(toCopy.getProgramRecords()); copy.setReadGroups(toCopy.getReadGroups()); copy.setSequenceDictionary(toCopy.getSequenceDictionary()); for (Map.Entry<String, String> e : toCopy.getAttributes()) copy.setAttribute(e.getKey(), e.getValue()); return copy; }
private GATKSAMRecord makeRead() { final SAMReadGroupRecord rg = header.getReadGroups().get(0); final String readName = String.format("%s.%d.%s", "read", readI, rg.getId()); final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, readName, 0, 1, readLength); read.setReadGroup(new GATKSAMReadGroupRecord(rg)); if ( payloadInBytes > 0 ) // add a payload byte array to push memory use per read even higher read.setAttribute("PL", new byte[payloadInBytes]); return read; } }