@Override public void close() { this.inputStream.close(); } }
@Override public void close() { this.inputStream.close(); } }
@Override public void close(PositionalBufferedStream positionalBufferedStream) { positionalBufferedStream.close(); }
@Override public void close() { if ( is != null ) is.close(); lineBuffer = null; }
@Override public void close() { if ( is != null ) is.close(); lineBuffer = null; }
@Override public void close() { if ( is != null ) is.close(); lineBuffer = null; }
@Override public void close() throws IOException { in.close(); }
@Override public void close() throws IOException { in.close(); }
@Override public void close() throws IOException { in.close(); }
public static void main(String[] args) throws Exception { final File testFile = new File(args[0]); final int iterations = Integer.valueOf(args[1]); final boolean includeInputStream = Boolean.valueOf(args[2]); final boolean doReadFileInChunks = Boolean.valueOf(args[3]); System.out.printf("Testing %s%n", args[0]); for (int i = 0; i < iterations; i++) { if ( includeInputStream ) { final InputStream is = new FileInputStream(testFile); if ( doReadFileInChunks ) readFileInChunks("InputStream", is); else readFileByLine("InputStream", is); is.close(); } final PositionalBufferedStream pbs = new PositionalBufferedStream(new FileInputStream(testFile)); if ( doReadFileInChunks ) readFileInChunks("PositionalBufferedStream", pbs); else readFileByLine("PositionalBufferedStream", pbs); pbs.close(); } }
public static void main(String[] args) throws Exception { final File testFile = new File(args[0]); final int iterations = Integer.valueOf(args[1]); final boolean includeInputStream = Boolean.valueOf(args[2]); final boolean doReadFileInChunks = Boolean.valueOf(args[3]); System.out.printf("Testing %s%n", args[0]); for (int i = 0; i < iterations; i++) { if ( includeInputStream ) { final InputStream is = new FileInputStream(testFile); if ( doReadFileInChunks ) readFileInChunks("InputStream", is); else readFileByLine("InputStream", is); is.close(); } final PositionalBufferedStream pbs = new PositionalBufferedStream(new FileInputStream(testFile)); if ( doReadFileInChunks ) readFileInChunks("PositionalBufferedStream", pbs); else readFileByLine("PositionalBufferedStream", pbs); pbs.close(); } }
public static void main(String[] args) throws Exception { final File testFile = new File(args[0]); final int iterations = Integer.valueOf(args[1]); final boolean includeInputStream = Boolean.valueOf(args[2]); final boolean doReadFileInChunks = Boolean.valueOf(args[3]); System.out.printf("Testing %s%n", args[0]); for (int i = 0; i < iterations; i++) { if ( includeInputStream ) { final InputStream is = new FileInputStream(testFile); if ( doReadFileInChunks ) readFileInChunks("InputStream", is); else readFileByLine("InputStream", is); is.close(); } final PositionalBufferedStream pbs = new PositionalBufferedStream(new FileInputStream(testFile)); if ( doReadFileInChunks ) readFileInChunks("PositionalBufferedStream", pbs); else readFileByLine("PositionalBufferedStream", pbs); pbs.close(); } }
/** * read the header from the file * * @throws IOException throws an IOException if we can't open the file */ private void readHeader() throws IOException { InputStream is = null; PositionalBufferedStream pbs = null; try { is = ParsingUtils.openInputStream(path); if (path.endsWith("gz")) { // TODO -- warning I don't think this can work, the buffered input stream screws up position is = new GZIPInputStream(new BufferedInputStream(is)); } pbs = new PositionalBufferedStream(is); final SOURCE source = codec.makeSourceFromStream(pbs); header = codec.readHeader(source); } catch (Exception e) { throw new TribbleException.MalformedFeatureFile("Unable to parse header with error: " + e.getMessage(), path, e); } finally { if (pbs != null) pbs.close(); else if (is != null) is.close(); } }
/** * read the header from the file * * @throws IOException throws an IOException if we can't open the file */ private void readHeader() throws IOException { InputStream is = null; PositionalBufferedStream pbs = null; try { is = ParsingUtils.openInputStream(path, wrapper); if (IOUtil.hasBlockCompressedExtension(new URI(URLEncoder.encode(path, "UTF-8")))) { // TODO: TEST/FIX THIS! https://github.com/samtools/htsjdk/issues/944 // TODO -- warning I don't think this can work, the buffered input stream screws up position is = new GZIPInputStream(new BufferedInputStream(is)); } pbs = new PositionalBufferedStream(is); final SOURCE source = codec.makeSourceFromStream(pbs); header = codec.readHeader(source); } catch (Exception e) { throw new TribbleException.MalformedFeatureFile("Unable to parse header with error: " + e.getMessage(), path, e); } finally { if (pbs != null) pbs.close(); else if (is != null) is.close(); } }
/** * read the header from the file * * @throws IOException throws an IOException if we can't open the file */ private void readHeader() throws IOException { InputStream is = null; PositionalBufferedStream pbs = null; try { is = ParsingUtils.openInputStream(path, wrapper); if (IOUtil.hasBlockCompressedExtension(new URI(URLEncoder.encode(path, "UTF-8")))) { // TODO: TEST/FIX THIS! https://github.com/samtools/htsjdk/issues/944 // TODO -- warning I don't think this can work, the buffered input stream screws up position is = new GZIPInputStream(new BufferedInputStream(is)); } pbs = new PositionalBufferedStream(is); final SOURCE source = codec.makeSourceFromStream(pbs); header = codec.readHeader(source); } catch (Exception e) { throw new TribbleException.MalformedFeatureFile("Unable to parse header with error: " + e.getMessage(), path, e); } finally { if (pbs != null) pbs.close(); else if (is != null) is.close(); } }
rate = ((double) lineCount) / dt; printStatus("PositionalBufferedStream", lineCount, rate, dt); pbs.close();
pbs.close();
public static VariantContextContainer readAllVCs(final File input, final BCF2Codec codec) throws IOException { PositionalBufferedStream headerPbs = new PositionalBufferedStream(new FileInputStream(input)); FeatureCodecHeader header = codec.readHeader(headerPbs); headerPbs.close(); final PositionalBufferedStream pbs = new PositionalBufferedStream(new FileInputStream(input)); pbs.skip(header.getHeaderEnd()); final VCFHeader vcfHeader = (VCFHeader)header.getHeaderValue(); return new VariantContextTestProvider.VariantContextContainer(vcfHeader, new VariantContextTestProvider.VCIterable(codec, vcfHeader) { @Override public boolean hasNext() { try { return !pbs.isDone(); } catch (IOException e) { throw new RuntimeException(e); } } @Override public Object nextSource() { return pbs; } }); }
private void testStream(final byte[] bytes) throws IOException { final InputStream is = new ByteArrayInputStream(bytes); final PositionalBufferedStream pbs = new PositionalBufferedStream(is); int bytePos = 0; while ( ! pbs.isDone() ) { Assert.assertTrue(bytePos < bytes.length); // test position Assert.assertEquals(pbs.getPosition(), bytePos); // test peek final byte atPos = bytes[bytePos]; Assert.assertEquals(toByte(pbs.peek()), atPos); // test position Assert.assertEquals(pbs.getPosition(), bytePos); // test read Assert.assertEquals(toByte(pbs.read()), atPos); bytePos++; // test position Assert.assertEquals(pbs.getPosition(), bytePos); // test repeek if ( bytePos < bytes.length ) { Assert.assertEquals(toByte(pbs.peek()), bytes[bytePos]); // test position Assert.assertEquals(pbs.getPosition(), bytePos); } } Assert.assertEquals(bytePos, bytes.length); pbs.close(); }
final VCFCodec headerParser = new VCFCodec(); this.header = (VCFHeader) headerParser.readActualHeader(lineIterator); bps.close(); } catch ( IOException e ) { throw new TribbleException("I/O error while reading BCF2 header");