@Test (expectedExceptions = SAMFormatException.class) public static void testGetIndexException() { Assert.assertNotNull(bamFileReaderWrong.getIndex()); }
@Test public static void testGetIndexOK() { Assert.assertTrue(bamFileReaderBAI.hasIndex()); Assert.assertTrue(bamFileReaderCSI.hasIndex()); Assert.assertTrue(bamFileReaderNull.hasIndex()); Assert.assertNotNull(bamFileReaderBAI.getIndex()); Assert.assertNotNull(bamFileReaderCSI.getIndex()); Assert.assertNotNull(bamFileReaderNull.getIndex()); }
final long startOfLastLinearBin = getIndex().getStartOfLastLinearBin(); if (startOfLastLinearBin != -1) { mCompressedInputStream.seek(startOfLastLinearBin);
final long startOfLastLinearBin = getIndex().getStartOfLastLinearBin(); if (startOfLastLinearBin != -1) { mCompressedInputStream.seek(startOfLastLinearBin);
final long startOfLastLinearBin = getIndex().getStartOfLastLinearBin(); if (startOfLastLinearBin != -1) { mCompressedInputStream.seek(startOfLastLinearBin);
final long startOfLastLinearBin = getIndex().getStartOfLastLinearBin(); if (startOfLastLinearBin != -1) { mCompressedInputStream.seek(startOfLastLinearBin);
/** * Prints meta-data statistics from BAM index (.bai) file * Statistics include count of aligned and unaligned reads for each reference sequence * and a count of all records with no start coordinate */ static public BAMIndexMetaData[] getIndexStats(final BAMFileReader bam) { AbstractBAMFileIndex index = (AbstractBAMFileIndex) bam.getIndex(); // read through all the bins of every reference. int nRefs = index.getNumberOfReferences(); BAMIndexMetaData[] result = new BAMIndexMetaData[nRefs == 0 ? 1 : nRefs]; for (int i = 0; i < nRefs; i++) { result[i] = index.getMetaData(i); } if (result[0] == null) { result[0] = new BAMIndexMetaData(); } final Long noCoordCount = index.getNoCoordinateCount(); if (noCoordCount != null) // null in old index files without metadata result[0].setNoCoordinateRecordCount(noCoordCount); return result; } }
private CloseableIterator<SAMRecord> createIndexIterator(final QueryInterval[] intervals, final boolean contained) { assertIntervalsOptimized(intervals); BAMFileSpan span = getFileSpan(intervals, getIndex()); // Create an iterator over the above chunk boundaries. final BAMFileIndexIterator iterator = new BAMFileIndexIterator(span == null ? null : span.toCoordinateArray()); // Add some preprocessing filters for edge-case reads that don't fit into this // query type. return new BAMQueryFilteringIterator(iterator, new BAMQueryMultipleIntervalsIteratorFilter(intervals, contained)); }
/** * Prints meta-data statistics from BAM index (.bai) file * Statistics include count of aligned and unaligned reads for each reference sequence * and a count of all records with no start coordinate */ static public BAMIndexMetaData[] getIndexStats(final BAMFileReader bam){ AbstractBAMFileIndex index = (AbstractBAMFileIndex) bam.getIndex(); // read through all the bins of every reference. int nRefs = index.getNumberOfReferences(); BAMIndexMetaData[] result = new BAMIndexMetaData[nRefs == 0 ? 1 : nRefs]; for (int i = 0; i < nRefs; i++) { result[i] = index.getMetaData(i); } if (result[0] == null){ result[0] = new BAMIndexMetaData(); } final Long noCoordCount = index.getNoCoordinateCount(); if (noCoordCount != null) // null in old index files without metadata result[0].setNoCoordinateRecordCount(noCoordCount); return result; } }
/** * Prints meta-data statistics from BAM index (.bai or .csi) file * Statistics include count of aligned and unaligned reads for each reference sequence * and a count of all records with no start coordinate */ static public BAMIndexMetaData[] getIndexStats(final BAMFileReader bam) { AbstractBAMFileIndex index = (AbstractBAMFileIndex) bam.getIndex(); // read through all the bins of every reference. int nRefs = index.getNumberOfReferences(); BAMIndexMetaData[] result = new BAMIndexMetaData[nRefs == 0 ? 1 : nRefs]; for (int i = 0; i < nRefs; i++) { result[i] = index.getMetaData(i); } if (result[0] == null) { result[0] = new BAMIndexMetaData(); } final Long noCoordCount = index.getNoCoordinateCount(); if (noCoordCount != null) // null in old index files without metadata result[0].setNoCoordinateRecordCount(noCoordCount); return result; } }
private CloseableIterator<SAMRecord> createIndexIterator(final QueryInterval[] intervals, final boolean contained) { assertIntervalsOptimized(intervals); BAMFileSpan span = getFileSpan(intervals, getIndex()); // Create an iterator over the above chunk boundaries. final BAMFileIndexIterator iterator = new BAMFileIndexIterator(span == null ? null : span.toCoordinateArray()); // Add some preprocessing filters for edge-case reads that don't fit into this // query type. return new BAMQueryFilteringIterator(iterator, new BAMQueryMultipleIntervalsIteratorFilter(intervals, contained)); }
private CloseableIterator<SAMRecord> createIndexIterator(final QueryInterval[] intervals, final boolean contained) { assertIntervalsOptimized(intervals); BAMFileSpan span = getFileSpan(intervals, getIndex()); // Create an iterator over the above chunk boundaries. final BAMFileIndexIterator iterator = new BAMFileIndexIterator(span == null ? null : span.toCoordinateArray()); // Add some preprocessing filters for edge-case reads that don't fit into this // query type. return new BAMQueryFilteringIterator(iterator, new BAMQueryMultipleIntervalsIteratorFilter(intervals, contained)); }
/** * Prepare to iterate through SAMRecords in the given reference that start exactly at the given start coordinate. * @param referenceIndex Desired reference sequence. * @param start 1-based alignment start. */ private CloseableIterator<SAMRecord> createStartingAtIndexIterator(final int referenceIndex, final int start) { // Hit the index to determine the chunk boundaries for the required data. final BAMIndex fileIndex = getIndex(); final BAMFileSpan fileSpan = fileIndex.getSpanOverlapping(referenceIndex, start, 0); final long[] filePointers = fileSpan != null ? fileSpan.toCoordinateArray() : null; // Create an iterator over the above chunk boundaries. final BAMFileIndexIterator iterator = new BAMFileIndexIterator(filePointers); // Add some preprocessing filters for edge-case reads that don't fit into this // query type. return new BAMQueryFilteringIterator(iterator,new BAMStartingAtIteratorFilter(referenceIndex,start)); }
/** * Prepare to iterate through SAMRecords in the given reference that start exactly at the given start coordinate. * @param referenceIndex Desired reference sequence. * @param start 1-based alignment start. */ private CloseableIterator<SAMRecord> createStartingAtIndexIterator(final int referenceIndex, final int start) { // Hit the index to determine the chunk boundaries for the required data. final BAMIndex fileIndex = getIndex(); final BAMFileSpan fileSpan = fileIndex.getSpanOverlapping(referenceIndex, start, 0); final long[] filePointers = fileSpan != null ? fileSpan.toCoordinateArray() : null; // Create an iterator over the above chunk boundaries. final BAMFileIndexIterator iterator = new BAMFileIndexIterator(filePointers); // Add some preprocessing filters for edge-case reads that don't fit into this // query type. return new BAMQueryFilteringIterator(iterator,new BAMStartingAtIteratorFilter(referenceIndex,start)); }
/** * Prepare to iterate through SAMRecords in the given reference that start exactly at the given start coordinate. * @param referenceIndex Desired reference sequence. * @param start 1-based alignment start. */ private CloseableIterator<SAMRecord> createStartingAtIndexIterator(final int referenceIndex, final int start) { // Hit the index to determine the chunk boundaries for the required data. final BAMIndex fileIndex = getIndex(); final BAMFileSpan fileSpan = fileIndex.getSpanOverlapping(referenceIndex, start, 0); final long[] filePointers = fileSpan != null ? fileSpan.toCoordinateArray() : null; // Create an iterator over the above chunk boundaries. final BAMFileIndexIterator iterator = new BAMFileIndexIterator(filePointers); // Add some preprocessing filters for edge-case reads that don't fit into this // query type. return new BAMQueryFilteringIterator(iterator,new BAMStartingAtIteratorFilter(referenceIndex,start)); }
/** * Prepare to iterate through SAMRecords in the given reference that start exactly at the given start coordinate. * @param referenceIndex Desired reference sequence. * @param start 1-based alignment start. */ private CloseableIterator<SAMRecord> createStartingAtIndexIterator(final int referenceIndex, final int start) { // Hit the index to determine the chunk boundaries for the required data. final BAMIndex fileIndex = getIndex(); final BAMFileSpan fileSpan = fileIndex.getSpanOverlapping(referenceIndex, start, 0); final long[] filePointers = fileSpan != null ? fileSpan.toCoordinateArray() : null; // Create an iterator over the above chunk boundaries. final BAMFileIndexIterator iterator = new BAMFileIndexIterator(filePointers); // Add some preprocessing filters for edge-case reads that don't fit into this // query type. return new BAMQueryFilteringIterator(iterator,new BAMStartingAtIteratorFilter(referenceIndex,start)); }
private CloseableIterator<SAMRecord> createIndexIterator(final QueryInterval[] intervals, final boolean contained) { assertIntervalsOptimized(intervals); // Hit the index to determine the chunk boundaries for the required data. final BAMFileSpan[] inputSpans = new BAMFileSpan[intervals.length]; final BAMIndex fileIndex = getIndex(); for (int i = 0; i < intervals.length; ++i) { final QueryInterval interval = intervals[i]; final BAMFileSpan span = fileIndex.getSpanOverlapping(interval.referenceIndex, interval.start, interval.end); inputSpans[i] = span; } final long[] filePointers; if (inputSpans.length > 0) { filePointers = BAMFileSpan.merge(inputSpans).toCoordinateArray(); } else { filePointers = null; } // Create an iterator over the above chunk boundaries. final BAMFileIndexIterator iterator = new BAMFileIndexIterator(filePointers); // Add some preprocessing filters for edge-case reads that don't fit into this // query type. return new BAMQueryFilteringIterator(iterator, new BAMQueryMultipleIntervalsIteratorFilter(intervals, contained)); }