bx.arrays.array_tree module

class bx.arrays.array_tree.ArrayTree

Bases: object

Stores a sparse array of data as a tree.

An array of self.max values is stored in a tree in which each leaf contains self.block_size values and each internal node contains self.block_size children.

Entirely empty subtrees are not stored. Thus, the storage is efficient for data that is block sparse – having contiguous chunks of self.block_size or larger data. Currently it is not efficient if the data is strided (e.g. one or two data points in every interval of length self.block_size).

Internal nodes store Summary instances for their subtrees.

block_size
dtype
classmethod from_file(f, is_little_endian=True)
classmethod from_sequence(s, block_size=1000)

Build an ArrayTree from a sequence like object (must have at least length and getitem).

levels
max
no_leaves
root
set_range(start, end, value)
to_file(f, is_little_endian=True, no_leaves=False)
class bx.arrays.array_tree.FileArrayTreeDict

Bases: object

Access to a file containing multiple array trees indexed by a string key.

classmethod dict_to_file(dict, file, is_little_endian=True, no_leaves=False)

Writes a dictionary of array trees to a file that can then be read efficiently using this class.

bx.arrays.array_tree.array_tree_dict_from_reader(reader, sizes, default_size=2147483647, block_size=1000, no_leaves=False)