Bin Query¶
Binned multi-track query primitive. Walks fixed-size bins across chromosomes
and queries signal_at() on each track per bin.
This is the shared primitive underneath annotate_chromatin() and
bin_summarize. It produces raw per-bin signal values without
classification or merging.
BinResult
dataclass
¶
One bin's signal from a single track.
signal is computed by signal_at() before the object is
yielded — it is never a lazy pointer to an outer-loop variable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chrom
|
str
|
Chromosome name. |
required |
start
|
int
|
Bin start (0-based, inclusive). |
required |
end
|
int
|
Bin end (0-based, exclusive). |
required |
signal
|
float
|
Pre-computed scalar signal for this bin. |
required |
Examples:
bin_query
¶
Walk bins across chromosomes, querying a single track.
signal_at(chrom, start, end) is called before each
yield — the float is computed inline during the sweep.
No closures. No deferred evaluation. No lazy iterators in fields.
For multi-track queries, use bin_positions() and call
signal_at() per track in the consuming code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track
|
'Track'
|
Track to query (must implement |
required |
chrom_sizes
|
dict[str, int]
|
Chromosome name to length mapping. |
required |
bin_size
|
int
|
Bin size in base pairs. |
required |
Yields:
| Type | Description |
|---|---|
BinResult
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If bin_size is not an int. |
ValueError
|
If bin_size is less than 1. |
Examples: