VcfReader { public static Iterable<VcfRecord> records(final Readable readable) throws IOException { return VcfRecordParser.records(readable); } 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 testRecordsNullReadable() throws Exception { records((Readable) null); }
@Test public void testRecordsEmptyReadable() throws Exception { records(emptyReadable); }
@Test public void testRecords() throws Exception { Iterable<VcfRecord> records = records(readable); assertNotNull(records); assertTrue(ImmutableList.copyOf(records).isEmpty()); }
@Test(expected=NullPointerException.class) public void testRecordsNullFile() throws Exception { records((File) null); }
@Test public void testRecordsFile() throws Exception { validateRecords(records(createFile(VCF))); }
@Test(expected=NullPointerException.class) public void testRecordsNullURL() throws Exception { records((URL) null); }
@Test public void testRecordsURL() throws Exception { validateRecords(records(createURL(VCF))); }
@Test(expected=NullPointerException.class) public void testRecordsNullInputStream() throws Exception { records((InputStream) null); }
@Test public void testRecordsInputStream() throws Exception { validateRecords(records(createInputStream(VCF))); }
@Test(expected=IOException.class) public void testInvalidDataLine() throws Exception { records(createInputStream("invalid-data-line.vcf")); }
@Test(expected=IOException.class) public void testInvalidPos() throws Exception { records(createInputStream("invalid-pos.vcf")); }
@Test(expected=IOException.class) public void testInvalidQual() throws Exception { records(createInputStream("invalid-qual.vcf")); }
@Test public void testRecordsFullInfo() throws Exception { VcfRecord record = records(createInputStream("chr22-info.vcf")).iterator().next(); assertNotNull(record); assertEquals("0.0649", record.getInfo().get("LDAF").get(0)); assertEquals("0.8652", record.getInfo().get("RSQ").get(0)); assertEquals("2184", record.getInfo().get("AN").get(0)); assertEquals("0.0046", record.getInfo().get("ERATE").get(0)); assertEquals("SNP", record.getInfo().get("VT").get(0)); assertNotNull(record.getInfo().get("AA")); assertTrue(record.getInfo().get("AA").isEmpty()); assertEquals("0.9799", record.getInfo().get("AVGPOST").get(0)); assertEquals("0.0149", record.getInfo().get("THETA").get(0)); assertEquals("LOWCOV", record.getInfo().get("SNPSOURCE").get(0)); assertEquals("134", record.getInfo().get("AC").get(0)); assertEquals("0.06", record.getInfo().get("AF").get(0)); assertEquals("0.04", record.getInfo().get("ASN_AF").get(0)); assertEquals("0.05", record.getInfo().get("AMR_AF").get(0)); assertEquals("0.10", record.getInfo().get("AFR_AF").get(0)); assertEquals("0.06", record.getInfo().get("EUR_AF").get(0)); assertEquals("0|0", record.getGenotypes().get("NA20828").getGt()); assertEquals(ImmutableList.of("0|0"), record.getGenotypes().get("NA20828").getFields().get("GT")); assertEquals(ImmutableList.of("0.000"), record.getGenotypes().get("NA20828").getFields().get("DS")); assertEquals(ImmutableList.of("-0.02", "-1.38", "-5.00"), record.getGenotypes().get("NA20828").getFields().get("GL")); }
@Test public void testMissingQual() throws Exception { VcfRecord record = records(createInputStream("missing-qual.vcf")).iterator().next(); assertNotNull(record); assertTrue(Double.isNaN(record.getQual())); }
@Test public void testMissingAlt() throws Exception { VcfRecord record = records(createInputStream("missing-alt.vcf")).iterator().next(); assertNotNull(record); assertNotNull(record.getAlt()); assertEquals(0, record.getAlt().length); }
@Test public void testMissingFilter() throws Exception { VcfRecord record = records(createInputStream("missing-filter.vcf")).iterator().next(); assertNotNull(record); assertNotNull(record.getFilter()); assertEquals(0, record.getFilter().length); }
@Test public void testMissingGenotypeField() throws Exception { VcfRecord record = records(createInputStream("missing-genotype-field.vcf")).iterator().next(); assertNotNull(record); assertEquals("0|0", record.getGenotypes().get("NA20828").getGt()); assertEquals(ImmutableList.of("0|0"), record.getGenotypes().get("NA20828").getFields().get("GT")); assertTrue(record.getGenotypes().get("NA20828").getFields().get("DS").isEmpty()); assertEquals(ImmutableList.of("-0.02", "-1.38", "-5.00"), record.getGenotypes().get("NA20828").getFields().get("GL")); }
@Test public void testMissingId() throws Exception { VcfRecord record = records(createInputStream("missing-id.vcf")).iterator().next(); assertNotNull(record); assertNotNull(record.getId()); assertEquals(0, record.getId().length); }
@Test public void testCephGatkHaplotypeJoint() throws Exception { VcfRecord record = records(createInputStream("ceph-bwa-j-gatk-haplotype-joint.excerpt.vcf")).iterator().next(); assertNull(record.getGenotypes().get("NA12878-3").getGt()); assertEquals("0/1", record.getGenotypes().get("NA12891-3").getGt()); assertEquals("0/0", record.getGenotypes().get("NA12892-3").getGt()); }