private void processAlignment(final SBIIndexWriter indexWriter, final SAMRecord rec) { final SAMFileSource source = rec.getFileSource(); if (source == null) { throw new SAMException("No source (virtual file offsets); needed for indexing on BAM Record " + rec); } final BAMFileSpan filePointer = (BAMFileSpan) source.getFilePointer(); indexWriter.processRecord(filePointer.getFirstOffset()); }
.open(SamInputResource.of(inFile)); SAMFileSpan span = open.indexing().getFilePointerSpanningReads(); long bamStart = ((BAMFileSpan) span).getFirstOffset(); newSplit = new FileVirtualSplit(fSplit.getPath(), bamStart,
.open(SamInputResource.of(inFile)); SAMFileSpan span = open.indexing().getFilePointerSpanningReads(); long bamStart = ((BAMFileSpan) span).getFirstOffset(); newSplit = new FileVirtualSplit(fSplit.getPath(), bamStart,
return ((BAMFileSpan) span).getFirstOffset();
/** * This is to check that the indexing actually works and not just skips records. The approach is to forbid reading of the first * container and try accessing reads from the first and the second containers. The first attempt should fail but the second should succeed. * * @throws IOException */ @Test public void testUnnecessaryIO() throws IOException { final SeekableStream baiStream = SamIndexes.asBaiSeekableStreamOrNull(new ByteArraySeekableStream(indexBytes), header.getSequenceDictionary()); BAMIndex index = new CachingBAMFileIndex(baiStream, header.getSequenceDictionary()); int refID = 0; long start = index.getSpanOverlapping(refID, 1, Integer.MAX_VALUE).getFirstOffset(); long end = index.getSpanOverlapping(refID + 1, 1, Integer.MAX_VALUE).getFirstOffset(); TabuRegionInputStream tabuIS = new TabuRegionInputStream(Arrays.asList(new Chunk[]{new Chunk(start, end)}), new ByteArraySeekableStream(cramBytes)); CRAMFileReader reader = new CRAMFileReader(tabuIS, new ByteArraySeekableStream(indexBytes), source, ValidationStringency.SILENT); try { // the attempt to read 1st container, which will happen when the iterator is initialized, must throw CloseableIterator<SAMRecord> it = reader.queryAlignmentStart(header.getSequence(refID).getSequenceName(), 1); Assert.fail(); } catch (TabuError e) { } // reading after the 1st container should be ok: refID = 2; final CloseableIterator<SAMRecord> iterator = reader.queryAlignmentStart(header.getSequence(refID).getSequenceName(), 1); Assert.assertNotNull(iterator); Assert.assertTrue(iterator.hasNext()); }
SAMFileSpan span = open.indexing().getFilePointerSpanningReads(); if (span instanceof BAMFileSpan) { return ((BAMFileSpan) span).getFirstOffset();
SAMFileSpan span = open.indexing().getFilePointerSpanningReads(); if (span instanceof BAMFileSpan) { return ((BAMFileSpan) span).getFirstOffset();