Crate bigtools

Source
Expand description

Bigtools provides a high-level, performant API for reading and writing bigWig and bigBed files.

The original file format specification for bigWig and bigBed files is defined in this paper: https://doi.org/10.1093/bioinformatics/btq351

§Reading

The entrypoint to reading bigWigs and bigBeds is BigWigRead::open and BigBedRead::open, respectively. These take any type that implements both Read and Seek. There are also BigWigRead::open_file and BigBedRead::open_file, which take a &str and will open a File.

Once a BigWigRead or BigBedRead have been constructed, they can be read in a number of ways. First, the info (in the form of BBIFileInfo) is available in info fields. However, to access the main data, the most common method to call is BigWigRead::get_interval or BigBedRead::get_interval, which returns an Iterator of Values or BedEntrys overlapping the provided region, respectively.

§Writing

Writing new bigWigs and bigBeds is a tad more difficult. To begin, a BigWigWrite or BigBedWrite can be created using BigWigWrite::create_file or BigBedWrite::create_file.

Generally, bigWig and bigBed writing is done per chromosome, with compression and io being done on an async Runtime.

The source for data to be written to bigWigs and bigBeds come from the BBIDataSource trait. It is used to abstracts over processing the data for a bbi file. It is a lower-level API that can be useful for custom value generation or scheduling logic. Generally though, users should not need to implement this directly, but rather use provided structs BedParserStreamingIterator and BedParserParallelStreamingIterator types providing serial processing of a bed-like value stream (either from a file or an iterator) or concurrent processing from a file. See the documentation on the trait for more detailed information on how to implement.

Given some implementation of BBIDataSource (like BedParserStreamingIterator), a bigWig can be created using BigWigWrite::write or a bigBed with BigBedWrite::write. Both take a map of chromosome sizes, the aforementioned data, and a Runtime to spawn processing on.

Modules§

bed
Contains utilities useful for reading and writing bed files and bed-like data.
beddata
The types here (BedParserStreamingIterator and BedParserParallelStreamingIterator) process incoming bed-like data and process into bigWig and bigBed files.
utils

Structs§

BBIFileInfo
Info on a bbi file
BBIHeader
Header info for a bbi file
BBIWriteOptions
Options for writing to a bbi file
BedEntry
Represents a single entry in a bigBed file
BigBedIntervalIter
BigBedRead
The struct used to read a bigBed file
BigBedWrite
The struct used to write a bigBed file
BigWigIntervalIter
BigWigRead
The struct used to read a bigWig file
BigWigWrite
The struct used to write a bigWig file
Block
CachedBBIFileRead
ChromInfo
Information on a chromosome in a bbi file
CirTreeIndex
Represents a cir tree index in a bbi file. Composed of a public CirTreeIndexType, and a private location in the bbi file. This can be passed to search_cir_tree.
ReductionLevelNotFound
Summary
A summary of a section of data (may be an entire file)
Value
Represents a single value in a bigWig file
ZoomHeader
Info on a specific zoom level in a bbi file
ZoomIntervalIter
ZoomRecord
A single zoom item

Enums§

BBIFile
The type of bbi file
BBIProcessError
Possible errors encountered when processing a chromosome when writing a bbi file
BBIReadError
Possible errors encountered when reading a bbi file
BigBedReadOpenError
Possible errors encountered when opening a bigBed file to read
BigWigReadOpenError
Possible errors encountered when opening a bigWig file to read
CirTreeIndexType
What kind of cir tree in a bbi file
CirTreeSearchError
GenericBBIFileOpenError
Possible errors encountered when opening a bigBed file to read
GenericBBIRead
InputSortType
Options for required input sort order of values
ProcessDataError
Possible errors encountered when processing a value to a BBI file.
ZoomIntervalError
Potential errors found when trying to read data from a zoom level

Constants§

DEFAULT_BLOCK_SIZE
The default block size used when writing a bbi file
DEFAULT_ITEMS_PER_SLOT
The default items per slot used when writing a bbi file

Traits§

BBIDataProcessor
BBIDataSource
This trait abstracts over processing the data for a bbi file. Generally, users should not need to implement this directly, but rather use provided structs like BedParserStreamingIterator. However, this does provide a lower-level API that can be useful for custom value generation or scheduling logic.
BBIFileRead
BBIRead
Generic methods for reading a bbi file