VcfReader { public static void stream(final Readable readable, final VcfStreamListener listener) throws IOException { StreamingVcfParser.stream(readable, listener); } private  VcfReader(); static void parse(final Readable readable, final VcfParseListener listener); static void stream(final Readable readable, final VcfStreamListener listener); static VcfHeader header(final Readable readable); static Iterable<VcfSample> samples(final Readable readable); static Iterable<VcfRecord> records(final Readable readable); static VcfHeader header(final File file); static VcfHeader header(final URL url); static VcfHeader header(final InputStream inputStream); static Iterable<VcfSample> samples(final File file); static Iterable<VcfSample> samples(final URL url); static Iterable<VcfSample> samples(final InputStream inputStream); static Iterable<VcfRecord> records(final File file); static Iterable<VcfRecord> records(final URL url); static Iterable<VcfRecord> records(final InputStream inputStream);  }
@Test(expected=NullPointerException.class) public void testStreamNullReadable() throws Exception { stream(null, streamListener); }
@Test(expected=NullPointerException.class) public void testStreamNullListener() throws Exception { stream(readable, null); }
@Test public void testStream() throws Exception { stream(readable, streamListener); }
@Test public void testStreamFile() throws Exception { try (BufferedReader reader = new BufferedReader(new FileReader(createFile(VCF)))) { stream(reader, new VcfStreamAdapter() { @Override public void header(final VcfHeader header) { validateHeader(header); } @Override public void sample(final VcfSample sample) { validateSample(sample); } @Override public void record(final VcfRecord record) { validateRecord(record); } }); } }
@Test public void testGatkGvcf() throws Exception { try (BufferedReader reader = new BufferedReader(new InputStreamReader(createInputStream("gatk-example.gvcf")))) { stream(reader, new VcfStreamListener() { @Override public void header(final VcfHeader header) { validateHeader(header); int count = 0; for (String meta : header.getMeta()) { if (meta.startsWith("##GVCFBlock")) { count++; } } assertEquals(4, count); } @Override public void sample(final VcfSample sample) { assertTrue("NA12878".equals(sample.getId())); } @Override public void record(final VcfRecord record) { if (record.getPos() == 10000212) { assertEquals("A", record.getRef()); assertEquals(1, record.getAlt().length); assertEquals("<NON_REF>", record.getAlt()[0]); } else if (record.getPos() == 10001298) { assertEquals("T", record.getRef()); assertEquals(2, record.getAlt().length); assertEquals("A", record.getAlt()[0]); assertEquals("<NON_REF>", record.getAlt()[1]); } } }); } }