Skip to main content

resolve_fragment_ce_key

Function resolve_fragment_ce_key 

Source
pub fn resolve_fragment_ce_key<V>(
    map: &BTreeMap<(u32, i8, i32), V>,
    peptide_id: u32,
    charge: i8,
    applied_ce_ev: f64,
) -> Option<i32>
Expand description

Resolve the fragment-map collision-energy key for an applied CE (eV), tolerant to ~0.1 eV quantization noise.

The map is keyed round(stored_ce * 1e3), where stored_ce is the CE the predictor saw — quantized to 2 decimals (ion_map_fn_*: round(ce*100)) and persisted normalized as f32. The renderer only has the applied CE (DDA: full-precision ce_bias + ce_slope*mobility; DIA: the window CE). At ~0.1 eV key boundaries the stored f32 lands on the opposite side of the rounding boundary from any value reconstructed from the applied CE, so an exact key cannot be reproduced — the renderer used to silently drop those fragment series (DDA; DIA window CE is pre-rounded so it was unaffected).

Probe the natural key and its ±1 neighbours (±0.1 eV = the quantization-noise magnitude) and return the first present. A genuinely different CE (≫0.1 eV away — e.g. a prediction set built for another instrument) still resolves to None, which callers treat as a real miss. Returns None when no fragments exist near this CE for (peptide, charge).