public CRAMIntervalIterator(final QueryInterval[] queries, final boolean contained) { this(queries, contained, coordinatesFromQueryIntervals(getIndex(), queries)); }
public CRAMIntervalIterator(final QueryInterval[] queries, final boolean contained) { this(queries, contained, coordinatesFromQueryIntervals(getIndex(), queries)); }
@Test(expectedExceptions = SAMException.class) public void testCRAMReader7_WithoutCRAMIndex() throws IOException { File indexFile = null; CRAMFileReader reader = new CRAMFileReader(CRAM_WITHOUT_CRAI, indexFile, REFERENCE, ValidationStringency.STRICT); reader.getIndex(); }
@Test(expectedExceptions = SAMException.class) public void testCRAMReader4_WithoutCRAMIndex() { CRAMFileReader reader = new CRAMFileReader(CRAM_WITHOUT_CRAI, REFERENCE); reader.getIndex(); }
@Test(expectedExceptions = SAMException.class) public void testCRAMReader2_WithoutCRAMIndex() { InputStream inputStream = null; CRAMFileReader reader = new CRAMFileReader(CRAM_WITHOUT_CRAI, inputStream, REFERENCE); reader.getIndex(); }
@Test(expectedExceptions = SAMException.class) public void testCRAMReader3_WithoutCRAMIndex() { File indexFile = null; CRAMFileReader reader = new CRAMFileReader(CRAM_WITHOUT_CRAI, indexFile, REFERENCE); reader.getIndex(); }
@Test public void testCRAMReader3_ShouldUseCRAMIndex() { CRAMFileReader reader = new CRAMFileReader(CRAM_WITH_CRAI, INDEX_FILE, REFERENCE); reader.getIndex(); Assert.assertTrue(reader.hasIndex(), "Can't find existing CRAM index."); }
@Test public void testCRAMReader2_ShouldAutomaticallyFindCRAMIndex() { InputStream inputStream = null; CRAMFileReader reader = new CRAMFileReader(CRAM_WITH_CRAI, inputStream, REFERENCE); reader.getIndex(); Assert.assertTrue(reader.hasIndex(), "Can't find CRAM existing index."); }
@Test public void testCRAMReader3_ShouldAutomaticallyFindCRAMIndex() { File indexFile = null; CRAMFileReader reader = new CRAMFileReader(CRAM_WITH_CRAI, indexFile, REFERENCE); reader.getIndex(); Assert.assertTrue(reader.hasIndex(), "Can't find existing CRAM index."); }
@Test public void testCRAMReader4_ShouldAutomaticallyFindCRAMIndex() { CRAMFileReader reader = new CRAMFileReader(CRAM_WITH_CRAI, REFERENCE); reader.getIndex(); Assert.assertTrue(reader.hasIndex(), "Can't find existing CRAM index."); }
@Test public void testQueryIntervalWithFilePointers() throws IOException { CRAMFileReader reader = new CRAMFileReader( new ByteArraySeekableStream(cramBytes), new ByteArraySeekableStream(craiBytes), source, ValidationStringency.STRICT); QueryInterval[] query = new QueryInterval[]{new QueryInterval(0, 1519, 1520), new QueryInterval(1, 470535, 470536)}; BAMFileSpan fileSpan = BAMFileReader.getFileSpan(query, reader.getIndex()); final CloseableIterator<SAMRecord> iterator = reader.createIndexIterator(query, false, fileSpan.toCoordinateArray()); Assert.assertTrue(iterator.hasNext()); SAMRecord r1 = iterator.next(); Assert.assertEquals(r1.getReadName(), "3968040"); Assert.assertTrue(iterator.hasNext()); SAMRecord r2 = iterator.next(); Assert.assertEquals(r2.getReadName(), "140419"); Assert.assertFalse(iterator.hasNext()); iterator.close(); reader.close(); }
reader.setValidationStringency(ValidationStringency.SILENT); final BAMIndex index = reader.getIndex(); final SAMFileSpan spanOfSecondContainer = index.getSpanOverlapping(refId, alignmentSpan.getStart(), alignmentSpan.getStart()+ alignmentSpan.getSpan()); Assert.assertNotNull(spanOfSecondContainer);
ValidationStringency.STRICT); final BAMIndex index = reader.getIndex(); final SAMFileSpan spanOfSecondContainer = index.getSpanOverlapping(refId, alignmentSpan.getStart(), alignmentSpan.getStart()+ alignmentSpan.getSpan()); Assert.assertNotNull(spanOfSecondContainer);
@Override public CloseableIterator<SAMRecord> queryUnmapped() { final long startOfLastLinearBin = getIndex().getStartOfLastLinearBin(); final SeekableStream seekableStream = getSeekableStreamOrFailWithRTE(); final CRAMIterator newIterator; try { seekableStream.seek(0); newIterator = new CRAMIterator(seekableStream, referenceSource, validationStringency); seekableStream.seek(startOfLastLinearBin >>> 16); final Container container = ContainerIO.readContainerHeader(newIterator.getCramHeader().getVersion().major, seekableStream); seekableStream.seek(seekableStream.position() + container.containerByteSize); iterator = newIterator; boolean atAlignments; do { atAlignments = iterator.advanceToAlignmentInContainer(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX, SAMRecord.NO_ALIGNMENT_START); } while (!atAlignments && iterator.hasNext()); } catch (final IOException e) { throw new RuntimeEOFException(e); } return iterator; }
@Override public CloseableIterator<SAMRecord> queryUnmapped() { final long startOfLastLinearBin = getIndex().getStartOfLastLinearBin(); final SeekableStream seekableStream = getSeekableStreamOrFailWithRTE(); final CRAMIterator newIterator; try { seekableStream.seek(0); newIterator = new CRAMIterator(seekableStream, referenceSource, validationStringency); seekableStream.seek(startOfLastLinearBin >>> 16); final Container container = ContainerIO.readContainerHeader(newIterator.getCramHeader().getVersion().major, seekableStream); seekableStream.seek(seekableStream.position() + container.containerByteSize); iterator = newIterator; boolean atAlignments; do { atAlignments = iterator.advanceToAlignmentInContainer(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX, SAMRecord.NO_ALIGNMENT_START); } while (!atAlignments && iterator.hasNext()); } catch (final IOException e) { throw new RuntimeEOFException(e); } return iterator; }