/** * Returns count of records unassociated with any reference. Call before the index file is closed * * @return meta data at the end of the bam index that indicates count of records holding no coordinates * or null if no meta data (old index format) */ @Override public Long getNoCoordinateCount() { if (metaDataPos > 0 && position() != metaDataPos) { seek(metaDataPos); } skipToSequence(getNumberOfReferences()); try { // in case of old index file without meta data return readLong(); } catch (final Exception e) { return null; } }
/** * Return meta data for the given reference including information about number of aligned, unaligned, and noCoordinate records * * @param reference the reference of interest * @return meta data for the reference */ @Override public BAMIndexMetaData getMetaData(final int reference) { if (metaDataPos > 0 && position() != metaDataPos) { seek(metaDataPos); } final List<Chunk> metaDataChunks = new ArrayList<Chunk>(); final int sequenceCount = getNumberOfReferences(); if (reference >= sequenceCount) { return null; } skipToSequence(reference); final int binCount = readInteger(); // n_bin for (int binNumber = 0; binNumber < binCount; binNumber++) { final int indexBin = readInteger(); // bin final long lOffset = readLong(); // loffset final int nChunks = readInteger(); // n_chunk if (indexBin == getMaxBins() + 1) { readChunks(nChunks, metaDataChunks); } else { skipBytes(BAMFileConstants.CSI_CHUNK_SIZE * nChunks); } } return new BAMIndexMetaData(metaDataChunks); }
skipToSequence(referenceSequence);