### Question:
TabixQuery implements VariantQuery { @Override public VariantQueryResult executeQuery(String sequence, int startPos, int stopPos) { if (startPos < 0) throw new IllegalArgumentException("StartPos must be bigger then 0"); if (stopPos <= startPos) throw new IllegalArgumentException("StopPos must be bigger then startPos "); try { TabixIterator tabixIterator = index.queryTabixIndex(sequence, startPos, stopPos, inputStream); return new TabixQueryResult(inputStream, new TabixQueryIterator(tabixIterator, variantLineMapper)); } catch (IOException e) { throw new GenotypeDataException(e); } } TabixQuery(File bzipFile, TabixIndex index, VariantLineMapper variantLineMapper); @Override VariantQueryResult executeQuery(String sequence, int startPos, int stopPos); @Override VariantQueryResult executeQuery(String sequence); @Override VariantQueryResult executeQuery(String sequence, int startPos);  }### Answer:
@Test public void queryPos() throws IOException { result = query.executeQuery("1", 565286, 6097450); Iterator<GeneticVariant> it = result.iterator(); int i = 0; while (it.hasNext()) { i++; GeneticVariant variant = it.next(); assertNotNull(variant); assertEquals(variant.getSequenceName(), "1"); } assertEquals(i, 5); }
@Test public void querySeq1() throws IOException { result = query.executeQuery("1"); Iterator<GeneticVariant> it = result.iterator(); int i = 0; while (it.hasNext()) { i++; GeneticVariant variant = it.next(); assertNotNull(variant); assertEquals(variant.getSequenceName(), "1"); } assertEquals(i, 6); }
@Test public void querySeq2() throws IOException { result = query.executeQuery("2"); Iterator<GeneticVariant> it = result.iterator(); int i = 0; while (it.hasNext()) { i++; GeneticVariant variant = it.next(); assertNotNull(variant); assertEquals(variant.getSequenceName(), "2"); } assertEquals(i, 1); }
@Test public void queryStartPos() { result = query.executeQuery("1", 3172273); Iterator<GeneticVariant> variants = result.iterator(); assertNotNull(variants); assertTrue(variants.hasNext()); assertEquals(variants.next().getPrimaryVariantId(), "rs2455100"); assertFalse(variants.hasNext()); assertNotNull(query.executeQuery("x", 3172273)); assertFalse(query.executeQuery("x", 3172273).iterator().hasNext()); assertNotNull(query.executeQuery("1", 31722730)); assertFalse(query.executeQuery("1", 31722730).iterator().hasNext()); }