use of htsjdk.tribble.readers.LineIterator in project gatk-protected by broadinstitute.
the class LineIteratorReaderUnitTest method testRead.
@Test(dataProvider = "testParameter")
public void testRead(@SuppressWarnings("unused") final int textSize, @SuppressWarnings("unused") final int lineSize, final int bufferSize, final String text) {
final LineIterator lineIterator = new TestLineIterator(text);
final LineIteratorReader reader = new LineIteratorReader(lineIterator);
final StringBuilder sb = new StringBuilder();
final char[] buffer = new char[bufferSize];
int readResult;
while ((readResult = reader.read(buffer, 0, bufferSize)) >= 0) {
sb.append(buffer, 0, readResult);
}
final String actualText = sb.toString();
Assert.assertEquals(actualText, text);
}
use of htsjdk.tribble.readers.LineIterator in project gatk by broadinstitute.
the class GenomicsDBImportIntegrationTest method checkGenomicsDBAgainstExpected.
private static void checkGenomicsDBAgainstExpected(final String workspace, final SimpleInterval interval, final String expectedCombinedVCF) throws IOException {
final GenomicsDBFeatureReader<VariantContext, PositionalBufferedStream> genomicsDBFeatureReader = new GenomicsDBFeatureReader<>(new File(workspace, GenomicsDBConstants.DEFAULT_VIDMAP_FILE_NAME).getAbsolutePath(), new File(workspace, GenomicsDBConstants.DEFAULT_CALLSETMAP_FILE_NAME).getAbsolutePath(), workspace, GenomicsDBConstants.DEFAULT_ARRAY_NAME, b38_reference_20_21, null, new BCF2Codec());
final AbstractFeatureReader<VariantContext, LineIterator> combinedVCFReader = AbstractFeatureReader.getFeatureReader(expectedCombinedVCF, new VCFCodec(), true);
try (CloseableTribbleIterator<VariantContext> actualVcs = genomicsDBFeatureReader.query(interval.getContig(), interval.getStart(), interval.getEnd());
CloseableTribbleIterator<VariantContext> expectedVcs = combinedVCFReader.query(interval.getContig(), interval.getStart(), interval.getEnd())) {
BaseTest.assertCondition(actualVcs, expectedVcs, (a, e) -> {
// TODO: Temporary hacks to make this test pass. Must be removed later
if (// allele order
e.getStart() != 17967343 && e.getStart() != 17966384 && // split block
e.getEnd() != 17981447) {
VariantContextTestUtils.assertVariantContextsAreEqual(a, e, Collections.emptyList());
}
});
}
}
use of htsjdk.tribble.readers.LineIterator in project gatk-protected by broadinstitute.
the class GenotypeGVCFsIntegrationTest method getVariantContexts.
/**
* Returns a list of VariantContext records from a VCF file
*
* @param vcfFile VCF file
* @return list of VariantContext records
* @throws IOException if the file does not exist or can not be opened
*/
private static List<VariantContext> getVariantContexts(final File vcfFile) throws IOException {
final VCFCodec codec = new VCFCodec();
final FileInputStream s = new FileInputStream(vcfFile);
final LineIterator lineIteratorVCF = codec.makeSourceFromStream(new PositionalBufferedStream(s));
codec.readHeader(lineIteratorVCF);
final List<VariantContext> VCs = new ArrayList<>();
while (lineIteratorVCF.hasNext()) {
final String line = lineIteratorVCF.next();
Assert.assertFalse(line == null);
VCs.add(codec.decode(line));
}
return VCs;
}
Aggregations