/** * Gets the first locus that this bin can index into. * @param bin The bin to test. * @return first position that associated with given bin number */ @Override public int getFirstLocusInBin(Bin bin) { if (bin.getBinNumber() < SRA_BIN_INDEX_OFFSET) { throw new RuntimeException("SRA only supports bins from the last level"); } return (bin.getBinNumber() - SRA_BIN_INDEX_OFFSET) * SRA_BIN_SIZE + 1; }
/** * Gets the first locus that this bin can index into. * @param bin The bin to test. * @return first position that associated with given bin number */ @Override public int getFirstLocusInBin(Bin bin) { if (bin.getBinNumber() < SRA_BIN_INDEX_OFFSET) { throw new RuntimeException("SRA only supports bins from the last level"); } return (bin.getBinNumber() - SRA_BIN_INDEX_OFFSET) * SRA_BIN_SIZE + 1; }
/** * Gets the last locus that this bin can index into. * @param bin The bin to test. * @return last position that associated with given bin number */ @Override public int getLastLocusInBin(Bin bin) { if (bin.getBinNumber() < SRA_BIN_INDEX_OFFSET) { throw new RuntimeException("SRA only supports bins from the last level"); } return (bin.getBinNumber() - SRA_BIN_INDEX_OFFSET + 1) * SRA_BIN_SIZE; }
/** * Gets the last locus that this bin can index into. * @param bin The bin to test. * @return last position that associated with given bin number */ @Override public int getLastLocusInBin(Bin bin) { if (bin.getBinNumber() < SRA_BIN_INDEX_OFFSET) { throw new RuntimeException("SRA only supports bins from the last level"); } return (bin.getBinNumber() - SRA_BIN_INDEX_OFFSET + 1) * SRA_BIN_SIZE; }
/** * SRA only operates on bins from last level * @param bin The bin for which to determine the level. * @return bin level */ @Override public int getLevelForBin(Bin bin) { if (bin.getBinNumber() < SRA_BIN_INDEX_OFFSET) { throw new RuntimeException("SRA only supports bins from the last level"); } return GenomicIndexUtil.LEVEL_STARTS.length - 1; }
/** * SRA only operates on bins from last level * @param bin The bin for which to determine the level. * @return bin level */ @Override public int getLevelForBin(Bin bin) { if (bin.getBinNumber() < SRA_BIN_INDEX_OFFSET) { throw new RuntimeException("SRA only supports bins from the last level"); } return GenomicIndexUtil.LEVEL_STARTS.length - 1; }
/** * Does this content have anything in this bin? */ public boolean containsBin(final Bin bin) { return mBinList.getBin(bin.getBinNumber()) != null; }
/** * Does this content have anything in this bin? */ public boolean containsBin(final Bin bin) { return mBinList.getBin(bin.getBinNumber()) != null; }
/** * Does this content have anything in this bin? */ public boolean containsBin(final Bin bin) { return mBinList.getBin(bin.getBinNumber()) != null; }
/** * Gets the last locus that this bin can index into. * @param bin The bin to test. * @return The last position that the given bin can represent. */ public int getLastLocusInBin(final Bin bin) { final int level = getLevelForBin(bin); final int levelStart = GenomicIndexUtil.LEVEL_STARTS[level]; final int levelSize = ((level==getNumIndexLevels()-1) ? GenomicIndexUtil.MAX_BINS-1 : GenomicIndexUtil.LEVEL_STARTS[level+1]) - levelStart; return (bin.getBinNumber()-levelStart+1)*(GenomicIndexUtil.BIN_GENOMIC_SPAN /levelSize); }
public int getParentBinNumber(Bin bin) { if (bin == null) { throw new SAMException("Tried to get parent bin for null bin."); } return getParentBinNumber(bin.getBinNumber()); }
/** * Gets the first locus that this bin can index into. * @param bin The bin to test. * @return The last position that the given bin can represent. */ public int getFirstLocusInBin(final Bin bin) { final int level = getLevelForBin(bin); final int levelStart = GenomicIndexUtil.LEVEL_STARTS[level]; final int levelSize = ((level==getNumIndexLevels()-1) ? GenomicIndexUtil.MAX_BINS-1 : GenomicIndexUtil.LEVEL_STARTS[level+1]) - levelStart; return (bin.getBinNumber() - levelStart)*(GenomicIndexUtil.BIN_GENOMIC_SPAN /levelSize)+1; }
/** * Gets the first locus that this bin can index into. * @param bin The bin to test. * @return The last position that the given bin can represent. */ public int getFirstLocusInBin(final Bin bin) { final int level = getLevelForBin(bin); final int levelStart = GenomicIndexUtil.LEVEL_STARTS[level]; final int levelSize = ((level==getNumIndexLevels()-1) ? GenomicIndexUtil.MAX_BINS-1 : GenomicIndexUtil.LEVEL_STARTS[level+1]) - levelStart; return (bin.getBinNumber() - levelStart)*(GenomicIndexUtil.BIN_GENOMIC_SPAN /levelSize)+1; }
/** * Gets the last locus that this bin can index into. * @param bin The bin to test. * @return The last position that the given bin can represent. */ public int getLastLocusInBin(final Bin bin) { final int level = getLevelForBin(bin); final int levelStart = GenomicIndexUtil.LEVEL_STARTS[level]; final int levelSize = ((level==getNumIndexLevels()-1) ? GenomicIndexUtil.MAX_BINS-1 : GenomicIndexUtil.LEVEL_STARTS[level+1]) - levelStart; return (bin.getBinNumber()-levelStart+1)*(GenomicIndexUtil.BIN_GENOMIC_SPAN /levelSize); }
@Override public int getLevelForBin(Bin bin) { if(bin == null || bin.getBinNumber() > getMaxBins()) { throw new SAMException("Tried to get level for invalid bin: " + bin); } for (int i = getBinDepth()-1; i > -1 ; i--) { if (bin.getBinNumber() >= getFirstBinInLevelForCSI(i)) { return i; } } throw new SAMException("Unable to find correct level for bin: " + bin); }
@Override public int getFirstLocusInBin(Bin bin) { if(bin == null || bin.getBinNumber() > getMaxBins()) { throw new SAMException("Tried to get first locus for invalid bin: " + bin); } int level = getLevelForBin(bin); int firstBinOnLevel = getFirstBinInLevelForCSI(level); int levelSize = getLevelSize(level); return (bin.getBinNumber() - firstBinOnLevel)*(getMaxSpan()/levelSize) + 1; }
@Override public int getLastLocusInBin(Bin bin) { if(bin == null || bin.getBinNumber() > getMaxBins()) { throw new SAMException("Tried to get last locus for invalid bin: " + bin); } int level = getLevelForBin(bin); int firstBinOnLevel = getFirstBinInLevelForCSI(level); int levelSize = getLevelSize(level); return (bin.getBinNumber() - firstBinOnLevel + 1)*(getMaxSpan()/levelSize); }
@Test(dataProvider = "testBinOverlappings") public void testBinOverlappings(SRAAccession acc, int reference, int firstLocus, int lastLocus, Set<Integer> binNumbers) { final SRAIndex index = getIndex(acc); final Iterator<Bin> binIterator = index.getBinsOverlapping(reference, firstLocus, lastLocus).iterator(); final Set<Integer> binNumbersFromIndex = new HashSet<>(); while (binIterator.hasNext()) { final Bin bin = binIterator.next(); binNumbersFromIndex.add(bin.getBinNumber() - SRA_BIN_OFFSET); } Assert.assertEquals(binNumbers, binNumbersFromIndex); }
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()); } }