@Test(dataProvider = "bedDataProvider") public void testCreateLinearIndexFromBED(final File inputBEDFIle) throws Exception { Index index = IndexFactory.createLinearIndex(inputBEDFIle, new BEDCodec()); String chr = "chr2"; Assert.assertTrue(index.getSequenceNames().contains(chr)); Assert.assertTrue(index.containsChromosome(chr)); Assert.assertEquals(1, index.getSequenceNames().size()); List<Block> blocks = index.getBlocks(chr, 1, 50); Assert.assertEquals(1, blocks.size()); Block block = blocks.get(0); Assert.assertEquals(78, block.getSize()); }
/** * Return an iterator to iterate over features overlapping the specified interval * <p/> * Note that TribbleIndexedFeatureReader only supports issuing and manipulating a single query * for each reader. That is, the behavior of the following code is undefined: * <p/> * reader = new TribbleIndexedFeatureReader() * Iterator it1 = reader.query("x", 10, 20) * Iterator it2 = reader.query("x", 1000, 1010) * <p/> * As a consequence of this, the TribbleIndexedFeatureReader are also not thread-safe. * * @param chr contig * @param start start position * @param end end position * @return an iterator of records in this interval * @throws IOException */ @Override public CloseableTribbleIterator<T> query(final String chr, final int start, final int end) throws IOException { if (!this.hasIndex()) { throw new TribbleException("Index not found for: " + path); } if (index.containsChromosome(chr)) { final List<Block> blocks = index.getBlocks(chr, start - 1, end); return new QueryIterator(chr, start, end, blocks); } else { return new EmptyIterator<>(); } }
/** * Return an iterator to iterate over features overlapping the specified interval * <p/> * Note that TribbleIndexedFeatureReader only supports issuing and manipulating a single query * for each reader. That is, the behavior of the following code is undefined: * <p/> * reader = new TribbleIndexedFeatureReader() * Iterator it1 = reader.query("x", 10, 20) * Iterator it2 = reader.query("x", 1000, 1010) * <p/> * As a consequence of this, the TribbleIndexedFeatureReader are also not thread-safe. * * @param chr contig * @param start start position * @param end end position * @return an iterator of records in this interval * @throws IOException */ public CloseableTribbleIterator<T> query(final String chr, final int start, final int end) throws IOException { if (!this.hasIndex()) { throw new TribbleException("Index not found for: " + path); } if (index.containsChromosome(chr)) { final List<Block> blocks = index.getBlocks(chr, start - 1, end); return new QueryIterator(chr, start, end, blocks); } else { return new EmptyIterator<T>(); } }
/** * Return an iterator to iterate over features overlapping the specified interval * <p/> * Note that TribbleIndexedFeatureReader only supports issuing and manipulating a single query * for each reader. That is, the behavior of the following code is undefined: * <p/> * reader = new TribbleIndexedFeatureReader() * Iterator it1 = reader.query("x", 10, 20) * Iterator it2 = reader.query("x", 1000, 1010) * <p/> * As a consequence of this, the TribbleIndexedFeatureReader are also not thread-safe. * * @param chr contig * @param start start position * @param end end position * @return an iterator of records in this interval * @throws IOException */ @Override public CloseableTribbleIterator<T> query(final String chr, final int start, final int end) throws IOException { if (!this.hasIndex()) { throw new TribbleException("Index not found for: " + path); } if (index.containsChromosome(chr)) { final List<Block> blocks = index.getBlocks(chr, start - 1, end); return new QueryIterator(chr, start, end, blocks); } else { return new EmptyIterator<>(); } }