@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()); }
try { final BAMFileReader bam = new BAMFileReader(inputBamFile, null, false, false, ValidationStringency.SILENT, new DefaultSAMRecordFactory()); if (!bam.hasIndex()) { throw new SAMException("No index for bam file " + inputBamFile);
try { final BAMFileReader bam = new BAMFileReader(inputBamFile, null, false, ValidationStringency.SILENT, new DefaultSAMRecordFactory()); if (!bam.hasIndex()) { throw new SAMException("No index for bam file " + inputBamFile);
try { final BAMFileReader bam = new BAMFileReader(inputBamFile, null, false, false, ValidationStringency.SILENT, new DefaultSAMRecordFactory()); if (!bam.hasIndex() || bam.getIndexType() == null) { throw new SAMException("No index for bam file " + inputBamFile);
/** * Retrieves the index for the given file type. Ensure that the index is of the specified type. * @return An index of the given type. */ @Override public BAMIndex getIndex() { if(!hasIndex()) throw new SAMException("No index is available for this BAM file."); if(mIndex == null) { if (mIndexFile != null) mIndex = mEnableIndexCaching ? new CachingBAMFileIndex(mIndexFile, getFileHeader().getSequenceDictionary(), mEnableIndexMemoryMapping) : new DiskBasedBAMFileIndex(mIndexFile, getFileHeader().getSequenceDictionary(), mEnableIndexMemoryMapping); else mIndex = mEnableIndexCaching ? new CachingBAMFileIndex(mIndexStream, getFileHeader().getSequenceDictionary()) : new DiskBasedBAMFileIndex(mIndexStream, getFileHeader().getSequenceDictionary()); } return mIndex; }
/** * Retrieves the index for the given file type. Ensure that the index is of the specified type. * @return An index of the given type. */ public BAMIndex getIndex() { if(!hasIndex()) throw new SAMException("No index is available for this BAM file."); if(mIndex == null) { if (mIndexFile != null) mIndex = mEnableIndexCaching ? new CachingBAMFileIndex(mIndexFile, getFileHeader().getSequenceDictionary(), mEnableIndexMemoryMapping) : new DiskBasedBAMFileIndex(mIndexFile, getFileHeader().getSequenceDictionary(), mEnableIndexMemoryMapping); else mIndex = mEnableIndexCaching ? new CachingBAMFileIndex(mIndexStream, getFileHeader().getSequenceDictionary()) : new DiskBasedBAMFileIndex(mIndexStream, getFileHeader().getSequenceDictionary()); } return mIndex; }
/** * Retrieves the index for the given file type. Ensure that the index is of the specified type. * @return An index of the given type. */ @Override public BAMIndex getIndex() { if(!hasIndex()) throw new SAMException("No index is available for this BAM file."); if(mIndex == null) { if (mIndexFile != null) mIndex = mEnableIndexCaching ? new CachingBAMFileIndex(mIndexFile, getFileHeader().getSequenceDictionary(), mEnableIndexMemoryMapping) : new DiskBasedBAMFileIndex(mIndexFile, getFileHeader().getSequenceDictionary(), mEnableIndexMemoryMapping); else mIndex = mEnableIndexCaching ? new CachingBAMFileIndex(mIndexStream, getFileHeader().getSequenceDictionary()) : new DiskBasedBAMFileIndex(mIndexStream, getFileHeader().getSequenceDictionary()); } return mIndex; }
/** * Retrieves the index for the given file type. Ensure that the index is of the specified type. * @return An index of the given type. */ @Override public BAMIndex getIndex() { if(!hasIndex()) throw new SAMException("No index is available for this BAM file."); if(mIndex == null) { SamIndexes samIndex = getIndexType(); if (samIndex == null) { mIndex = mEnableIndexCaching ? new CachingBAMFileIndex(mIndexStream, getFileHeader().getSequenceDictionary()) : new DiskBasedBAMFileIndex(mIndexStream, getFileHeader().getSequenceDictionary()); } else if (samIndex.equals(SamIndexes.BAI)) { mIndex = mEnableIndexCaching ? new CachingBAMFileIndex(mIndexFile, getFileHeader().getSequenceDictionary(), mEnableIndexMemoryMapping) : new DiskBasedBAMFileIndex(mIndexFile, getFileHeader().getSequenceDictionary(), mEnableIndexMemoryMapping); } else if (samIndex.equals(SamIndexes.CSI)) { mIndex = new CSIIndex(mIndexFile, mEnableIndexMemoryMapping, getFileHeader().getSequenceDictionary()); } else { throw new SAMFormatException("Unsupported BAM index file: " + mIndexFile.getName()); } } return mIndex; }