/** * @return all chunks associated with all bins in this content */ public List<Chunk> getAllChunks() { final List<Chunk> allChunks = new ArrayList<Chunk>(); for (final Bin b : mBinList) if (b.getChunkList() != null) { allChunks.addAll(b.getChunkList()); } return Collections.unmodifiableList(allChunks); }
/** * @return all chunks associated with all bins in this content */ public List<Chunk> getAllChunks() { final List<Chunk> allChunks = new ArrayList<Chunk>(); for (final Bin b : mBinList) if (b.getChunkList() != null) { allChunks.addAll(b.getChunkList()); } return Collections.unmodifiableList(allChunks); }
/** * @return all chunks associated with all bins in this content */ public List<Chunk> getAllChunks() { final List<Chunk> allChunks = new ArrayList<Chunk>(); for (final Bin b : mBinList) if (b.getChunkList() != null) { allChunks.addAll(b.getChunkList()); } return Collections.unmodifiableList(allChunks); }
@Test public void testEmptyBin() { // Construct a new empty bin and ensure that the bin list is empty, not null. Bin bin = new Bin(1,4681); Assert.assertEquals(bin.getChunkList(),Collections.<Chunk>emptyList(),"getChunkList() in an empty bin should return an empty list."); } }
/** * @param bin Requested bin * @return chunks that represent all bases of requested bin */ private List<Chunk> getBinChunks(Bin bin) { if (bin.containsChunks()) { return bin.getChunkList(); } if (bin.getBinNumber() < SRA_BIN_INDEX_OFFSET) { throw new RuntimeException("SRA only supports bins from the last level"); } int binNumber = bin.getBinNumber() - SRA_BIN_INDEX_OFFSET; long refOffset = recordRangeInfo.getReferenceOffsets().get(bin.getReferenceSequence()); // move requested position MAX_FRAGMENT_OVERLAP bases behind, so that we take all the reads that overlap requested position int firstChunkCorrection = binNumber == 0 ? 0 : -MAX_FRAGMENT_OVERLAP; long binGlobalOffset = binNumber * SRA_BIN_SIZE + refOffset; long firstChunkNumber = (binGlobalOffset + firstChunkCorrection) / SRA_CHUNK_SIZE; long lastChunkNumber = (binGlobalOffset + SRA_BIN_SIZE - 1) / SRA_CHUNK_SIZE; List<Chunk> chunks = new ArrayList<Chunk>(); for (long chunkNumber = firstChunkNumber; chunkNumber <= lastChunkNumber; chunkNumber++) { chunks.add(new Chunk(chunkNumber * SRA_CHUNK_SIZE, (chunkNumber + 1) * SRA_CHUNK_SIZE)); } return chunks; } }
/** * * @param startPos 1-based, inclusive * @param endPos 1-based, inclusive * @return List of Chunks overlapping the given region. May return null if there are none. */ public List<Chunk> getChunksOverlapping(final int startPos, final int endPos) { final BitSet overlappingBins = GenomicIndexUtil.regionToBins(startPos,endPos); if (overlappingBins == null) return null; // System.out.println("# Sequence target TID: " + referenceIndex); final List<Chunk> chunkList = new ArrayList<Chunk>(); for (int index = overlappingBins.nextSetBit(0); index >= 0; index = overlappingBins.nextSetBit(index + 1)) { final Bin bin = getBins().getBin(index); if (bin != null) { for (final Chunk chunk : bin.getChunkList()) { chunkList.add(chunk.clone()); } } } if (chunkList.isEmpty()) { return null; } return Chunk.optimizeChunkList(chunkList, getLinearIndex().getMinimumOffset(startPos)); } /**
/** * @param bin Requested bin * @return chunks that represent all bases of requested bin */ private List<Chunk> getBinChunks(Bin bin) { if (bin.containsChunks()) { return bin.getChunkList(); } if (bin.getBinNumber() < SRA_BIN_INDEX_OFFSET) { throw new RuntimeException("SRA only supports bins from the last level"); } int binNumber = bin.getBinNumber() - SRA_BIN_INDEX_OFFSET; long refOffset = recordRangeInfo.getReferenceOffsets().get(bin.getReferenceSequence()); // move requested position MAX_FRAGMENT_OVERLAP bases behind, so that we take all the reads that overlap requested position int firstChunkCorrection = binNumber == 0 ? 0 : -MAX_FRAGMENT_OVERLAP; long binGlobalOffset = binNumber * SRA_BIN_SIZE + refOffset; long firstChunkNumber = (binGlobalOffset + firstChunkCorrection) / SRA_CHUNK_SIZE; long lastChunkNumber = (binGlobalOffset + SRA_BIN_SIZE - 1) / SRA_CHUNK_SIZE; List<Chunk> chunks = new ArrayList<Chunk>(); for (long chunkNumber = firstChunkNumber; chunkNumber <= lastChunkNumber; chunkNumber++) { chunks.add(new Chunk(chunkNumber * SRA_CHUNK_SIZE, (chunkNumber + 1) * SRA_CHUNK_SIZE)); } return chunks; } }
/** * * @param startPos 1-based, inclusive * @param endPos 1-based, inclusive * @return List of Chunks overlapping the given region. May return null if there are none. */ public List<Chunk> getChunksOverlapping(final int startPos, final int endPos) { final BitSet overlappingBins = GenomicIndexUtil.regionToBins(startPos,endPos); if (overlappingBins == null) return null; // System.out.println("# Sequence target TID: " + referenceIndex); final List<Chunk> chunkList = new ArrayList<Chunk>(); for (int index = overlappingBins.nextSetBit(0); index >= 0; index = overlappingBins.nextSetBit(index + 1)) { final Bin bin = getBins().getBin(index); if (bin != null) { for (final Chunk chunk : bin.getChunkList()) { chunkList.add(chunk.clone()); } } } if (chunkList.isEmpty()) { return null; } return Chunk.optimizeChunkList(chunkList, getLinearIndex().getMinimumOffset(startPos)); } /**
/** * * @param startPos 1-based, inclusive * @param endPos 1-based, inclusive * @return List of Chunks overlapping the given region. May return null if there are none. */ public List<Chunk> getChunksOverlapping(final int startPos, final int endPos) { final BitSet overlappingBins = GenomicIndexUtil.regionToBins(startPos,endPos); if (overlappingBins == null) return null; // System.out.println("# Sequence target TID: " + referenceIndex); final List<Chunk> chunkList = new ArrayList<Chunk>(); for (int index = overlappingBins.nextSetBit(0); index >= 0; index = overlappingBins.nextSetBit(index + 1)) { final Bin bin = getBins().getBin(index); if (bin != null) { for (final Chunk chunk : bin.getChunkList()) { chunkList.add(chunk.clone()); } } } if (chunkList.isEmpty()) { return null; } return Chunk.optimizeChunkList(chunkList, getLinearIndex().getMinimumOffset(startPos)); } /**
private void writeBin(final Bin bin) { final int binNumber = bin.getBinNumber(); if (binNumber >= GenomicIndexUtil.MAX_BINS){ throw new SAMException("Unexpected bin number when writing bam index " + binNumber); } codec.writeInt(binNumber); if (bin.getChunkList() == null){ codec.writeInt(0); return; } final List<Chunk> chunkList = bin.getChunkList(); final int n_chunk = chunkList.size(); codec.writeInt(n_chunk); for (final Chunk c : chunkList) { codec.writeLong(c.getChunkStart()); codec.writeLong(c.getChunkEnd()); } }
private void writeBin(final Bin bin) { final int binNumber = bin.getBinNumber(); if (binNumber >= GenomicIndexUtil.MAX_BINS){ throw new SAMException("Unexpected bin number when writing bam index " + binNumber); } codec.writeInt(binNumber); if (bin.getChunkList() == null){ codec.writeInt(0); return; } final List<Chunk> chunkList = bin.getChunkList(); final int n_chunk = chunkList.size(); codec.writeInt(n_chunk); for (final Chunk c : chunkList) { codec.writeLong(c.getChunkStart()); codec.writeLong(c.getChunkEnd()); } }
private void writeBin(final Bin bin) { final int binNumber = bin.getBinNumber(); if (binNumber >= GenomicIndexUtil.MAX_BINS){ throw new SAMException("Unexpected bin number when writing bam index " + binNumber); } codec.writeInt(binNumber); if (bin.getChunkList() == null){ codec.writeInt(0); return; } final List<Chunk> chunkList = bin.getChunkList(); final int n_chunk = chunkList.size(); codec.writeInt(n_chunk); for (final Chunk c : chunkList) { codec.writeLong(c.getChunkStart()); codec.writeLong(c.getChunkEnd()); } }
private void writeBin(final Bin bin) { final int binNumber = bin.getBinNumber(); if (binNumber >= GenomicIndexUtil.MAX_BINS){ throw new SAMException("Unexpected bin number when writing bam index " + binNumber); } codec.writeInt(binNumber); if (bin.getChunkList() == null){ codec.writeInt(0); return; } final List<Chunk> chunkList = bin.getChunkList(); final int n_chunk = chunkList.size(); codec.writeInt(n_chunk); for (final Chunk c : chunkList) { codec.writeLong(c.getChunkStart()); codec.writeLong(c.getChunkEnd()); } }
private void writeBin(final Bin bin) { final int binNumber = bin.getBinNumber(); if (binNumber >= GenomicIndexUtil.MAX_BINS){ throw new SAMException("Unexpected bin number when writing bam index " + binNumber); } codec.writeInt(binNumber); if (bin.getChunkList() == null){ codec.writeInt(0); return; } final List<Chunk> chunkList = bin.getChunkList(); final int n_chunk = chunkList.size(); codec.writeInt(n_chunk); for (final Chunk c : chunkList) { codec.writeLong(c.getChunkStart()); codec.writeLong(c.getChunkEnd()); } }
private void writeBin(final Bin bin, final LittleEndianOutputStream los) throws IOException { los.writeInt(bin.getBinNumber()); final List<Chunk> chunkList = bin.getChunkList(); los.writeInt(chunkList.size()); for (final Chunk chunk : chunkList) { los.writeLong(chunk.getChunkStart()); los.writeLong(chunk.getChunkEnd()); } }
private void writeBin(final Bin bin, final LittleEndianOutputStream los) throws IOException { los.writeInt(bin.getBinNumber()); final List<Chunk> chunkList = bin.getChunkList(); los.writeInt(chunkList.size()); for (final Chunk chunk : chunkList) { los.writeLong(chunk.getChunkStart()); los.writeLong(chunk.getChunkEnd()); } }
private void writeBin(final Bin bin, final LittleEndianOutputStream los) throws IOException { los.writeInt(bin.getBinNumber()); final List<Chunk> chunkList = bin.getChunkList(); los.writeInt(chunkList.size()); for (final Chunk chunk: chunkList) { los.writeLong(chunk.getChunkStart()); los.writeLong(chunk.getChunkEnd()); } }
for(final Chunk chunk: coveringBin.getChunkList()) chunkList.add(chunk.clone());
for(final Chunk chunk: coveringBin.getChunkList()) chunkList.add(chunk.clone());
for(final Chunk chunk: coveringBin.getChunkList()) chunkList.add(chunk.clone());