Documentation ¶
Overview ¶
Package bgzf provides functions for reading and writing files in the BGZF compression format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
Block represents a single BGZF block stores as a bytes.Buffer initialized to have a capacity of 65536 (max uint16).
type BlockReader ¶
type BlockReader struct {
// contains filtered or unexported fields
}
BlockReader is the decompressor for BGZF files which is at its core a gzip reader. The BGZF reader retains a *os.File to use for seek functionality as well as a *bufio.Reader to implement the io.ByteReader interface, required for reading gzip files as independent concatenated blocks, rather than a multistream.
func NewBlockReader ¶
func NewBlockReader(filename string) *BlockReader
NewBlockReader opens a new BGZF reader for the input file.
func (*BlockReader) ReadBlock ¶
func (r *BlockReader) ReadBlock(b *Block) error
ReadBlock reads the next block into the input Block. Returns io.EOF at the end of the file.
func (*BlockReader) Seek ¶
func (r *BlockReader) Seek(offset int64, whence int) (ret int64, err error)
Seek moves the reader to the beginning of the block denoted by the input offset. A subsequent call to ReadBlock will read the Seeked block. The whence input can be io.SeekStart, io.SeekCurrent, or io.SeekEnd.
type BlockWriter ¶
type BlockWriter struct {
// contains filtered or unexported fields
}
BlockWriter moves data -> compressor -> zipBlock -> file writer.
func NewBlockWriter ¶
func NewBlockWriter(w io.Writer) *BlockWriter
NewBlockWriter creates a bgzf writer from any input writer.
func (*BlockWriter) Close ¶
func (w *BlockWriter) Close() error
Close bgzf writer and add the magic EOF marker to the end of the file.
type Offset ¶
type Offset struct { Compressed int64 // offset in compressed file Uncompressed uint16 // offset in uncompressed block }
Offset for a location in the BGZF file consisting of the compressed offset (the number of bytes before the beginning of the desired block starting from the beginning of the file), and and the uncompressed offset (the number of bytes from the desired record starting from the beginning of the uncompressed block).
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Read wraps a BlockReader and provides the Next and Read functions that automatically read a new block when the previous block has been completely read.
func (*Reader) Next ¶
Next returns the next n bytes from the bgzf block. Next handles reading new block if more bytes are requested than are in the currently store block.