private BAMFileReader(final BlockCompressedInputStream compressedInputStream, final File indexFile, final boolean eagerDecode, final String source, final ValidationStringency validationStringency, final SAMRecordFactory factory) throws IOException { mIndexFile = indexFile; mIsSeekable = true; mCompressedInputStream = compressedInputStream; mStream = new BinaryCodec(new DataInputStream(mCompressedInputStream)); this.eagerDecode = eagerDecode; this.mValidationStringency = validationStringency; this.samRecordFactory = factory; this.mFileHeader = readHeader(this.mStream, this.mValidationStringency, source); mFirstRecordPointer = mCompressedInputStream.getFilePointer(); }
private BAMFileReader(final BlockCompressedInputStream compressedInputStream, final SeekableStream indexStream, final boolean eagerDecode, final String source, final ValidationStringency validationStringency, final SAMRecordFactory factory) throws IOException { mIndexStream = indexStream; mIsSeekable = true; mCompressedInputStream = compressedInputStream; mStream = new BinaryCodec(new DataInputStream(mCompressedInputStream)); this.eagerDecode = eagerDecode; this.mValidationStringency = validationStringency; this.samRecordFactory = factory; this.mFileHeader = readHeader(this.mStream, this.mValidationStringency, source); mFirstRecordPointer = mCompressedInputStream.getFilePointer(); }
/** * Prepare to read BAM from a stream (not seekable) * @param stream source of bytes. * @param eagerDecode if true, decode all BAM fields as reading rather than lazily. * @param validationStringency Controls how to handle invalidate reads or header lines. */ BAMFileReader(final InputStream stream, final File indexFile, final boolean eagerDecode, final ValidationStringency validationStringency, final SAMRecordFactory factory) throws IOException { mIndexFile = indexFile; mIsSeekable = false; mCompressedInputStream = new BlockCompressedInputStream(stream); mStream = new BinaryCodec(new DataInputStream(mCompressedInputStream)); this.eagerDecode = eagerDecode; this.mValidationStringency = validationStringency; this.samRecordFactory = factory; this.mFileHeader = readHeader(this.mStream, this.mValidationStringency, null); }
/** * Prepare to read BAM from a compressed stream (seekable) * @param compressedInputStream source of bytes * @param indexStream BAM index stream * @param eagerDecode if true, decode all BAM fields as reading rather than lazily. * @param useAsynchronousIO if true, use asynchronous I/O * @param source string used when reporting errors * @param validationStringency Controls how to handle invalidate reads or header lines. * @param samRecordFactory SAM record factory * @throws IOException */ private BAMFileReader(final BlockCompressedInputStream compressedInputStream, final SeekableStream indexStream, final boolean eagerDecode, final boolean useAsynchronousIO, final String source, final ValidationStringency validationStringency, final SAMRecordFactory samRecordFactory) throws IOException { mIndexStream = indexStream; mIsSeekable = true; mCompressedInputStream = compressedInputStream; mStream = new BinaryCodec(new DataInputStream(mCompressedInputStream)); this.eagerDecode = eagerDecode; this.mValidationStringency = validationStringency; this.samRecordFactory = samRecordFactory; this.mFileHeader = readHeader(this.mStream, this.mValidationStringency, source); mFirstRecordPointer = mCompressedInputStream.getFilePointer(); }
/** * Prepare to read BAM from a compressed stream (seekable) * @param compressedInputStream source of bytes * @param indexStream BAM index stream * @param eagerDecode if true, decode all BAM fields as reading rather than lazily. * @param useAsynchronousIO if true, use asynchronous I/O * @param source string used when reporting errors * @param validationStringency Controls how to handle invalidate reads or header lines. * @param samRecordFactory SAM record factory * @throws IOException */ private BAMFileReader(final BlockCompressedInputStream compressedInputStream, final SeekableStream indexStream, final boolean eagerDecode, final boolean useAsynchronousIO, final String source, final ValidationStringency validationStringency, final SAMRecordFactory samRecordFactory) throws IOException { mIndexStream = indexStream; mIsSeekable = true; mCompressedInputStream = compressedInputStream; mStream = new BinaryCodec(new DataInputStream(mCompressedInputStream)); this.eagerDecode = eagerDecode; this.mValidationStringency = validationStringency; this.samRecordFactory = samRecordFactory; this.mFileHeader = readHeader(this.mStream, this.mValidationStringency, source); mFirstRecordPointer = mCompressedInputStream.getFilePointer(); }
/** * Prepare to read BAM from a compressed stream (seekable) * @param compressedInputStream source of bytes * @param indexFile BAM index file * @param eagerDecode if true, decode all BAM fields as reading rather than lazily. * @param useAsynchronousIO if true, use asynchronous I/O * @param source string used when reporting errors * @param validationStringency Controls how to handle invalidate reads or header lines. * @param samRecordFactory SAM record factory * @throws IOException */ private BAMFileReader(final BlockCompressedInputStream compressedInputStream, final File indexFile, final boolean eagerDecode, final boolean useAsynchronousIO, final String source, final ValidationStringency validationStringency, final SAMRecordFactory samRecordFactory) throws IOException { mIndexFile = indexFile; mIsSeekable = true; mCompressedInputStream = compressedInputStream; mStream = new BinaryCodec(new DataInputStream(mCompressedInputStream)); this.eagerDecode = eagerDecode; this.mValidationStringency = validationStringency; this.samRecordFactory = samRecordFactory; this.mFileHeader = readHeader(this.mStream, this.mValidationStringency, source); mFirstRecordPointer = mCompressedInputStream.getFilePointer(); }
/** * Prepare to read BAM from a compressed stream (seekable) * @param compressedInputStream source of bytes * @param indexFile BAM index file * @param eagerDecode if true, decode all BAM fields as reading rather than lazily. * @param useAsynchronousIO if true, use asynchronous I/O * @param source string used when reporting errors * @param validationStringency Controls how to handle invalidate reads or header lines. * @param samRecordFactory SAM record factory * @throws IOException */ private BAMFileReader(final BlockCompressedInputStream compressedInputStream, final File indexFile, final boolean eagerDecode, final boolean useAsynchronousIO, final String source, final ValidationStringency validationStringency, final SAMRecordFactory samRecordFactory) throws IOException { mIndexFile = indexFile; mIsSeekable = true; mCompressedInputStream = compressedInputStream; mStream = new BinaryCodec(new DataInputStream(mCompressedInputStream)); this.eagerDecode = eagerDecode; this.mValidationStringency = validationStringency; this.samRecordFactory = samRecordFactory; this.mFileHeader = readHeader(this.mStream, this.mValidationStringency, source); mFirstRecordPointer = mCompressedInputStream.getFilePointer(); this.useAsynchronousIO = useAsynchronousIO; }
/** * Prepare to read BAM from a compressed stream (seekable) * @param compressedInputStream source of bytes * @param indexStream BAM index stream * @param eagerDecode if true, decode all BAM fields as reading rather than lazily. * @param useAsynchronousIO if true, use asynchronous I/O * @param source string used when reporting errors * @param validationStringency Controls how to handle invalidate reads or header lines. * @param samRecordFactory SAM record factory * @throws IOException */ private BAMFileReader(final BlockCompressedInputStream compressedInputStream, final SeekableStream indexStream, final boolean eagerDecode, final boolean useAsynchronousIO, final String source, final ValidationStringency validationStringency, final SAMRecordFactory samRecordFactory) throws IOException { mIndexStream = indexStream; mIsSeekable = true; mCompressedInputStream = compressedInputStream; mStream = new BinaryCodec(new DataInputStream(mCompressedInputStream)); this.eagerDecode = eagerDecode; this.mValidationStringency = validationStringency; this.samRecordFactory = samRecordFactory; this.mFileHeader = readHeader(this.mStream, this.mValidationStringency, source); mFirstRecordPointer = mCompressedInputStream.getFilePointer(); this.useAsynchronousIO = useAsynchronousIO; }
/** * Prepare to read BAM from a compressed stream (seekable) * @param compressedInputStream source of bytes * @param indexFile BAM index file * @param eagerDecode if true, decode all BAM fields as reading rather than lazily. * @param useAsynchronousIO if true, use asynchronous I/O * @param source string used when reporting errors * @param validationStringency Controls how to handle invalidate reads or header lines. * @param samRecordFactory SAM record factory * @throws IOException */ private BAMFileReader(final BlockCompressedInputStream compressedInputStream, final File indexFile, final boolean eagerDecode, final boolean useAsynchronousIO, final String source, final ValidationStringency validationStringency, final SAMRecordFactory samRecordFactory) throws IOException { mIndexFile = indexFile; mIsSeekable = true; mCompressedInputStream = compressedInputStream; mStream = new BinaryCodec(new DataInputStream(mCompressedInputStream)); this.eagerDecode = eagerDecode; this.mValidationStringency = validationStringency; this.samRecordFactory = samRecordFactory; this.mFileHeader = readHeader(this.mStream, this.mValidationStringency, source); mFirstRecordPointer = mCompressedInputStream.getFilePointer(); }
/** * Prepare to read BAM from a stream (not seekable) * @param stream source of bytes. * @param indexFile BAM index file * @param eagerDecode if true, decode all BAM fields as reading rather than lazily. * @param useAsynchronousIO if true, use asynchronous I/O * @param validationStringency Controls how to handle invalidate reads or header lines. * @param samRecordFactory SAM record factory * @param inflaterFactory InflaterFactory used by BlockCompressedInputStream * @throws IOException */ BAMFileReader(final InputStream stream, final File indexFile, final boolean eagerDecode, final boolean useAsynchronousIO, final ValidationStringency validationStringency, final SAMRecordFactory samRecordFactory, final InflaterFactory inflaterFactory) throws IOException { mIndexFile = indexFile; mIsSeekable = false; mCompressedInputStream = useAsynchronousIO ? new AsyncBlockCompressedInputStream(stream, inflaterFactory) : new BlockCompressedInputStream(stream, inflaterFactory); mStream = new BinaryCodec(new DataInputStream(mCompressedInputStream)); this.eagerDecode = eagerDecode; this.mValidationStringency = validationStringency; this.samRecordFactory = samRecordFactory; this.mFileHeader = readHeader(this.mStream, this.mValidationStringency, null); }
/** * Prepare to read BAM from a stream (not seekable) * @param stream source of bytes. * @param indexFile BAM index file * @param eagerDecode if true, decode all BAM fields as reading rather than lazily. * @param useAsynchronousIO if true, use asynchronous I/O * @param validationStringency Controls how to handle invalidate reads or header lines. * @param samRecordFactory SAM record factory * @param inflaterFactory InflaterFactory used by BlockCompressedInputStream * @throws IOException */ BAMFileReader(final InputStream stream, final File indexFile, final boolean eagerDecode, final boolean useAsynchronousIO, final ValidationStringency validationStringency, final SAMRecordFactory samRecordFactory, final InflaterFactory inflaterFactory) throws IOException { mIndexFile = indexFile; mIsSeekable = false; mCompressedInputStream = useAsynchronousIO ? new AsyncBlockCompressedInputStream(stream, inflaterFactory) : new BlockCompressedInputStream(stream, inflaterFactory); mStream = new BinaryCodec(new DataInputStream(mCompressedInputStream)); this.eagerDecode = eagerDecode; this.mValidationStringency = validationStringency; this.samRecordFactory = samRecordFactory; this.mFileHeader = readHeader(this.mStream, this.mValidationStringency, null); this.useAsynchronousIO = useAsynchronousIO; }
/** * Prepare to read BAM from a stream (not seekable) * @param stream source of bytes. * @param indexFile BAM index file * @param eagerDecode if true, decode all BAM fields as reading rather than lazily. * @param useAsynchronousIO if true, use asynchronous I/O * @param validationStringency Controls how to handle invalidate reads or header lines. * @param samRecordFactory SAM record factory * @param inflaterFactory InflaterFactory used by BlockCompressedInputStream * @throws IOException */ BAMFileReader(final InputStream stream, final File indexFile, final boolean eagerDecode, final boolean useAsynchronousIO, final ValidationStringency validationStringency, final SAMRecordFactory samRecordFactory, final InflaterFactory inflaterFactory) throws IOException { mIndexFile = indexFile; mIsSeekable = false; mCompressedInputStream = useAsynchronousIO ? new AsyncBlockCompressedInputStream(stream, inflaterFactory) : new BlockCompressedInputStream(stream, inflaterFactory); mStream = new BinaryCodec(new DataInputStream(mCompressedInputStream)); this.eagerDecode = eagerDecode; this.mValidationStringency = validationStringency; this.samRecordFactory = samRecordFactory; this.mFileHeader = readHeader(this.mStream, this.mValidationStringency, null); }
@Test public void testWriteHeader() throws IOException { final SAMRecordSetBuilder builder = new SAMRecordSetBuilder(true, SAMFileHeader.SortOrder.coordinate); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); BAMFileWriter.writeHeader(baos, builder.getHeader()); baos.close(); try (BinaryCodec binaryCodec = new BinaryCodec(new DataInputStream(new BlockCompressedInputStream(new ByteArrayInputStream(baos.toByteArray()))))) { SAMFileHeader samFileHeader = BAMFileReader.readHeader(binaryCodec, ValidationStringency.STRICT, null); Assert.assertEquals(samFileHeader, builder.getHeader()); } } }