/** * Test reading a local tabix file * * @throws java.io.IOException */ @Test public void testLocalQuery() throws IOException { TabixIteratorLineReader lineReader = new TabixIteratorLineReader( tabixReader.query(tabixReader.chr2tid("4"), 320, 330)); int nRecords = 0; String nextLine; while ((nextLine = lineReader.readLine()) != null) { Assert.assertTrue(nextLine.startsWith("4")); nRecords++; } Assert.assertTrue(nRecords > 0); }
/** * Return iterator over all features overlapping the given interval * * @param chr * @param start * @param end * @return * @throws IOException */ @Override public CloseableTribbleIterator<T> query(final String chr, final int start, final int end) throws IOException { final List<String> mp = getSequenceNames(); if (mp == null) throw new TribbleException.TabixReaderFailure("Unable to find sequence named " + chr + " in the tabix index. ", path); if (!mp.contains(chr)) { return new EmptyIterator<T>(); } final TabixIteratorLineReader lineReader = new TabixIteratorLineReader(tabixReader.query(tabixReader.chr2tid(chr), start - 1, end)); return new FeatureIterator<T>(lineReader, start - 1, end); }
/** * Return iterator over all features overlapping the given interval * * @param chr * @param start * @param end * @return * @throws IOException */ @Override public CloseableTribbleIterator<T> query(final String chr, final int start, final int end) throws IOException { final List<String> mp = getSequenceNames(); if (mp == null) throw new TribbleException.TabixReaderFailure("Unable to find sequence named " + chr + " in the tabix index. ", path); if (!mp.contains(chr)) { return new EmptyIterator<T>(); } final TabixIteratorLineReader lineReader = new TabixIteratorLineReader(tabixReader.query(tabixReader.chr2tid(chr), start - 1, end)); return new FeatureIterator<T>(lineReader, start - 1, end); }
/** * Test reading a tabix file over http * * @throws java.io.IOException */ @Test public void testRemoteQuery() throws IOException { String tabixFile = TestUtil.BASE_URL_FOR_HTTP_TESTS +"igvdata/tabix/trioDup.vcf.gz"; TabixReader tabixReader = new TabixReader(tabixFile); TabixIteratorLineReader lineReader = new TabixIteratorLineReader( tabixReader.query(tabixReader.chr2tid("4"), 320, 330)); int nRecords = 0; String nextLine; while ((nextLine = lineReader.readLine()) != null) { Assert.assertTrue(nextLine.startsWith("4")); nRecords++; } Assert.assertTrue(nRecords > 0); }
/** * Return iterator over all features overlapping the given interval * * @param chr * @param start * @param end * @return * @throws IOException */ public CloseableTribbleIterator<T> query(final String chr, final int start, final int end) throws IOException { final List<String> mp = getSequenceNames(); if (mp == null) throw new TribbleException.TabixReaderFailure("Unable to find sequence named " + chr + " in the tabix index. ", path); if (!mp.contains(chr)) { return new EmptyIterator<T>(); } final TabixIteratorLineReader lineReader = new TabixIteratorLineReader(tabixReader.query(tabixReader.chr2tid(chr), start - 1, end)); return new FeatureIterator<T>(lineReader, start - 1, end); }