@Test public void testCRAMReader7_ShouldUseCRAMIndex() throws IOException { CRAMFileReader reader = new CRAMFileReader(CRAM_WITH_CRAI, INDEX_FILE, REFERENCE, ValidationStringency.STRICT); Assert.assertTrue(reader.hasIndex(), "Can't find existing CRAM index."); }
@Test public void testCRAMReader7_ShouldAutomaticallyFindCRAMIndex()throws IOException { File indexFile = null; CRAMFileReader reader = new CRAMFileReader(CRAM_WITH_CRAI, indexFile, REFERENCE, ValidationStringency.STRICT); Assert.assertTrue(reader.hasIndex(), "Can't find existing CRAM 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 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."); }
@Override public BAMIndex getIndex() { if (!hasIndex()) throw new SAMException("No index is available for this CRAM file."); if (mIndex == null) { final SAMSequenceDictionary dictionary = getFileHeader() .getSequenceDictionary(); if (mIndexFile.getName().endsWith(BAMIndex.BAMIndexSuffix)) { mIndex = mEnableIndexCaching ? new CachingBAMFileIndex(mIndexFile, dictionary, mEnableIndexMemoryMapping) : new DiskBasedBAMFileIndex(mIndexFile, dictionary, mEnableIndexMemoryMapping); return mIndex; } if (!mIndexFile.getName().endsWith(CRAIIndex.CRAI_INDEX_SUFFIX)) return null; // convert CRAI into BAI: final SeekableStream baiStream; try { baiStream = SamIndexes.asBaiSeekableStreamOrNull(new SeekableFileStream(mIndexFile), iterator.getSAMFileHeader().getSequenceDictionary()); } catch (IOException e) { throw new RuntimeException(e); } mIndex = mEnableIndexCaching ? new CachingBAMFileIndex(baiStream, getFileHeader().getSequenceDictionary()) : new DiskBasedBAMFileIndex(baiStream, getFileHeader().getSequenceDictionary()); } return mIndex; }
@Override public BAMIndex getIndex() { if (!hasIndex()) throw new SAMException("No index is available for this CRAM file."); if (mIndex == null) { final SAMSequenceDictionary dictionary = getFileHeader() .getSequenceDictionary(); if (mIndexFile.getName().endsWith(BAMIndex.BAI_INDEX_SUFFIX)) { mIndex = mEnableIndexCaching ? new CachingBAMFileIndex(mIndexFile, dictionary, mEnableIndexMemoryMapping) : new DiskBasedBAMFileIndex(mIndexFile, dictionary, mEnableIndexMemoryMapping); return mIndex; } if (!mIndexFile.getName().endsWith(CRAIIndex.CRAI_INDEX_SUFFIX)) return null; // convert CRAI into BAI: final SeekableStream baiStream; try { baiStream = SamIndexes.asBaiSeekableStreamOrNull(new SeekableFileStream(mIndexFile), iterator.getSAMFileHeader().getSequenceDictionary()); } catch (IOException e) { throw new RuntimeException(e); } mIndex = mEnableIndexCaching ? new CachingBAMFileIndex(baiStream, getFileHeader().getSequenceDictionary()) : new DiskBasedBAMFileIndex(baiStream, getFileHeader().getSequenceDictionary()); } return mIndex; }
ValidationStringency.DEFAULT_STRINGENCY ); Assert.assertTrue(cramReader.hasIndex());