Documentation ¶
Overview ¶
Package bgzf implements BGZF format reading and writing according to the SAM specification.
The specification is available at https://github.com/samtools/hts-specs.
Index ¶
Constants ¶
const ( BlockSize = 0x0ff00 // The maximum size of an uncompressed input data block. MaxBlockSize = 0x10000 // The maximum size of a compressed output block. )
Variables ¶
var ( ErrClosed = errors.New("bgzf: use of closed writer") ErrBlockOverflow = errors.New("bgzf: block overflow") ErrWrongFileType = errors.New("bgzf: file is a directory") ErrNoEnd = errors.New("bgzf: cannot determine offset from end") ErrNotASeeker = errors.New("bgzf: not a seeker") ErrContaminatedCache = errors.New("bgzf: cache owner mismatch") ErrNoBlockSize = errors.New("bgzf: could not determine block size") ErrBlockSizeMismatch = errors.New("bgzf: unexpected block size") )
Functions ¶
Types ¶
type Block ¶
type Block interface { // Base returns the file offset of the start of // the gzip member from which the Block data was // decompressed. Base() int64 io.Reader // Used returns whether one or more bytes have // been read from the Block. Used() bool // NextBase returns the expected position of the next // BGZF block. It returns -1 if the Block is not valid. NextBase() int64 // contains filtered or unexported methods }
Block wraps interaction with decompressed BGZF data blocks.
type Cache ¶
type Cache interface { // Get returns the Block in the Cache with the specified // base or a nil Block if it does not exist. The returned // Block must be removed from the Cache. Get(base int64) Block // Put inserts a Block into the Cache, returning the Block // that was evicted or nil if no eviction was necessary and // a boolean indicating whether the put Block was retained // by the Cache. Put(Block) (evicted Block, retained bool) // Peek returns whether a Block exists in the cache for the // given base. If a Block satisfies the request, then exists // is returned as true with the offset for the next Block in // the stream, otherwise false and -1. Peek(base int64) (exists bool, next int64) }
Cache is a Block caching type. Basic cache implementations are provided in the cache package. A Cache must be safe for concurrent use.
If a Cache is a Wrapper, its Wrap method is called on newly created blocks.
type Reader ¶
type Reader struct { gzip.Header // Blocked specifies the behaviour of the // Reader at the end of a BGZF member. // If the Reader is Blocked, a Read that // reaches the end of a BGZF block will // return io.EOF. This error is not sticky, // so a subsequent Read will progress to // the next block if it is available. Blocked bool // contains filtered or unexported fields }
Reader implements BGZF blocked gzip decompression.
func NewReader ¶
NewReader returns a new BGZF reader.
The number of concurrent read decompressors is specified by rd. If rd is 0, GOMAXPROCS concurrent will be created. The returned Reader should be closed after use to avoid leaking resources.
func (*Reader) BlockLen ¶
BlockLen returns the number of bytes remaining to be read from the current BGZF block.
func (*Reader) LastChunk ¶
LastChunk returns the region of the BGZF file read by the last read operation or the resulting virtual offset of the last successful seek operation.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx represents a multi-read transaction.
type Writer ¶
Writer implements BGZF blocked gzip compression.
func NewWriter ¶
NewWriter returns a new Writer. Writes to the returned writer are compressed and written to w.
The number of concurrent write compressors is specified by wc.
func NewWriterLevel ¶
NewWriterLevel returns a new Writer using the specified compression level instead of gzip.DefaultCompression. Allowable level options are integer values between between gzip.BestSpeed and gzip.BestCompression inclusive.
The number of concurrent write compressors is specified by wc.
func (*Writer) Close ¶
Close closes the Writer, waiting for any pending writes before returning the final error of the Writer.
func (*Writer) Flush ¶
Flush writes unwritten data to the underlying io.Writer. Flush does not block.
func (*Writer) Next ¶
Next returns the index of the start of the next write within the decompressed data block.
func (*Writer) Wait ¶
Wait waits for all pending writes to complete and returns the subsequent error state of the Writer.
Directories ¶
Path | Synopsis |
---|---|
Package cache provides basic block cache types for the bgzf package.
|
Package cache provides basic block cache types for the bgzf package. |
Package index provides common code for CSI and tabix BGZF indexing.
|
Package index provides common code for CSI and tabix BGZF indexing. |