use of org.molgenis.vcf.VcfReader in project molgenis by molgenis.
the class VcfRepositoryTest method testGetEntityType.
// Regression test for https://github.com/molgenis/molgenis/issues/6528
@Test(expectedExceptions = MolgenisDataException.class, expectedExceptionsMessageRegExp = "Failed to read VCF Metadata from file; nested exception is java.io.IOException: error processing source")
public void testGetEntityType() throws IOException {
VcfReaderFactory vcfReaderFactory = mock(VcfReaderFactory.class);
VcfReader vcfReader = mock(VcfReader.class);
doThrow(new IOException("error processing source")).when(vcfReader).getVcfMeta();
when(vcfReaderFactory.get()).thenReturn(vcfReader);
String entityTypeId = "entityTypeId";
VcfAttributes vcfAttributes = mock(VcfAttributes.class);
EntityTypeFactory entityTypeFactory = mock(EntityTypeFactory.class);
AttributeFactory attrMetaFactory = mock(AttributeFactory.class);
VcfRepository vcfRepository = new VcfRepository(vcfReaderFactory, entityTypeId, vcfAttributes, entityTypeFactory, attrMetaFactory);
vcfRepository.getEntityType();
}
use of org.molgenis.vcf.VcfReader in project molgenis by molgenis.
the class VcfReaderFactoryImpl method get.
@Override
public VcfReader get() {
try {
InputStream inputStream = new FileInputStream(file);
if (file.getName().endsWith(".gz")) {
inputStream = new GZIPInputStream(inputStream);
} else if (file.getName().endsWith(".zip")) {
ZipFile zipFile = new ZipFile(file.getPath());
Enumeration<? extends ZipEntry> e = zipFile.entries();
// your only file
ZipEntry entry = e.nextElement();
inputStream = zipFile.getInputStream(entry);
}
VcfReader reader = new VcfReader(new InputStreamReader(inputStream, UTF_8));
// bootstrap reader so close() can close all readers
vcfReaderRegistry.add(reader);
return reader;
} catch (IOException e) {
throw new MolgenisDataException("Failed to create VCF Reader for file" + file.getAbsolutePath(), e);
}
}
Aggregations