Fragments
Oxbow data sources are logically grouped into fragments.
- A data source without random access (e.g., a simple stream) contains only a single fragment.
- When you register range queries using
.regions(), each query is mapped to a unique fragment. Each fragment generates its own independent stream of record batches.
Dask Partitions
When converting an Oxbow data source to a Dask data frame using .dd() or .to_dask(), oxbow maps its logical fragments to Dask partitions. Each partition is expected to be independently accessible and fit in memory.
import ox
# Single fragment (no regions defined)
ds = ox.from_bam("data/sample.bam")
print(ds.fragments())
# Multiple fragments (one per region)
ds_regions = ox.from_bam("data/sample.bam").regions(["chr1", "chr3", "chrX"])
print(ds_regions.fragments())
# Mapping fragments to Dask partitions
df = (
ox.from_bam("data/sample.bam")
.regions(["chr1", "chrX", "chrY"])
.dd() # or .to_dask()
)
# Access a specific partition
print(df.partitions[1].compute())