use of htsjdk.tribble.readers.LineIterator in project gatk by broadinstitute.
the class GenomicsDBImport method getReaderFromVCFUri.
/**
* Creates a feature reader object from a given VCF URI (can also be
* a local file path) and returns it
* @param variantPath URI or file path
* @return Feature reader
*/
private AbstractFeatureReader<VariantContext, LineIterator> getReaderFromVCFUri(final String variantPath) {
final String variantURI = IOUtils.getPath(variantPath).toAbsolutePath().toUri().toString();
final Function<SeekableByteChannel, SeekableByteChannel> cloudWrapper = (cloudPrefetchBuffer > 0 ? is -> SeekableByteChannelPrefetcher.addPrefetcher(cloudPrefetchBuffer, is) : Function.identity());
final Function<SeekableByteChannel, SeekableByteChannel> cloudIndexWrapper = (cloudIndexPrefetchBuffer > 0 ? is -> SeekableByteChannelPrefetcher.addPrefetcher(cloudIndexPrefetchBuffer, is) : Function.identity());
return AbstractFeatureReader.getFeatureReader(variantURI, null, new VCFCodec(), true, cloudWrapper, cloudIndexWrapper);
}
use of htsjdk.tribble.readers.LineIterator in project gatk by broadinstitute.
the class TableCodecUnitTest method testDecodeFailsNoHeader.
@Test(expectedExceptions = UserException.MalformedFile.class)
public void testDecodeFailsNoHeader() {
TableCodec tc = new TableCodec();
LineReader reader = makeReader(asList("1:1 1 2 3"));
LineIterator li = new LineIteratorImpl(reader);
tc.readActualHeader(li);
}
use of htsjdk.tribble.readers.LineIterator in project gatk by broadinstitute.
the class TableCodecUnitTest method testDecodeOnlyComments.
@Test
public void testDecodeOnlyComments() {
TableCodec tc = new TableCodec();
LineReader reader = makeReader(asList("#HEADER a b c", "#HEADER d e f"));
LineIterator li = new LineIteratorImpl(reader);
final List<String> strings = tc.readActualHeader(li);
Assert.assertEquals(strings, emptyList());
}
use of htsjdk.tribble.readers.LineIterator in project gatk 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 TableCodecUnitTest method testTwoHeaders.
@Test
public void testTwoHeaders() {
TableCodec tc = new TableCodec();
LineReader reader = makeReader(asList("HEADER a b c", "HEADER d e f"));
LineIterator li = new LineIteratorImpl(reader);
final List<String> strings = tc.readActualHeader(li);
Assert.assertEquals(strings, asList("HEADER", "a", "b", "c"));
}
Aggregations