pub fn greedy_non_overlapping(
calls: &[NucleosomeCall],
params: &CallParams,
) -> Vec<NucleosomeCall>Expand description
Select non-overlapping calls, taking the highest scoring first.
Candidates are considered in descending score order, and one is accepted only if no
already-accepted dyad lies within CallParams::exclusion of it. The result is
returned in ascending dyad order, as the reference prints it.
The reference scans every accepted call for every candidate, which is quadratic and
dominates its runtime at chromosome scale. Accepted dyads are kept in a sorted set here
and the exclusion window is a range query over it, which is the same rule in
O(n log n).
Two behaviours of the reference are reproduced deliberately. Its accepted-position
array is initialised holding a single zero, and its scan includes that element, so a
phantom call at position 0 rejects every candidate within the exclusion window of it;
no dyad at or below exclusion can ever be accepted. And where scores tie, the
reference’s order comes from Perl hash iteration, which is randomised per process, so
its choice among equal scores is not reproducible even against itself; ties are broken
here by ascending dyad so that this implementation at least is deterministic.