pub struct TimsTofSyntheticsPrecursorFrameBuilder {
pub ions: BTreeMap<u32, Vec<IonSim>>,
pub peptides: BTreeMap<u32, PeptidesSim>,
pub scans: Vec<ScansSim>,
pub frames: Vec<FramesSim>,
pub precursor_frame_id_set: HashSet<u32>,
pub frame_to_abundances: BTreeMap<u32, (Vec<u32>, Vec<f32>)>,
pub peptide_to_ions: BTreeMap<u32, (Vec<f32>, Vec<Vec<u32>>, Vec<Vec<f32>>, Vec<i8>, Vec<MzSpectrum>)>,
pub frame_to_rt: BTreeMap<u32, f32>,
pub scan_to_mobility: BTreeMap<u32, f32>,
pub peptide_to_events: BTreeMap<u32, f32>,
pub ion_id_to_peptide_charge: BTreeMap<u32, (u32, i8)>,
}Fields§
§ions: BTreeMap<u32, Vec<IonSim>>§peptides: BTreeMap<u32, PeptidesSim>§scans: Vec<ScansSim>§frames: Vec<FramesSim>§precursor_frame_id_set: HashSet<u32>§frame_to_abundances: BTreeMap<u32, (Vec<u32>, Vec<f32>)>§peptide_to_ions: BTreeMap<u32, (Vec<f32>, Vec<Vec<u32>>, Vec<Vec<f32>>, Vec<i8>, Vec<MzSpectrum>)>§frame_to_rt: BTreeMap<u32, f32>§scan_to_mobility: BTreeMap<u32, f32>§peptide_to_events: BTreeMap<u32, f32>§ion_id_to_peptide_charge: BTreeMap<u32, (u32, i8)>Mapping from ion_id to (peptide_id, charge) for DDA precursor lookup
Implementations§
Source§impl TimsTofSyntheticsPrecursorFrameBuilder
impl TimsTofSyntheticsPrecursorFrameBuilder
Sourcepub fn from_source(path: &Path, source: &DistributionSource) -> Result<Self>
pub fn from_source(path: &Path, source: &DistributionSource) -> Result<Self>
Construct the builder with occurrence/abundance distributions sourced from
source (P4): Columns (legacy JSON, the default — byte-unchanged) or the
render-time Projector. Identical-shape PeptidesSim/IonSim either way,
so the maps + all downstream consumers are untouched.
Sourcepub fn from_entities(
ions: Vec<IonSim>,
peptides: Vec<PeptidesSim>,
scans: Vec<ScansSim>,
frames: Vec<FramesSim>,
) -> Self
pub fn from_entities( ions: Vec<IonSim>, peptides: Vec<PeptidesSim>, scans: Vec<ScansSim>, frames: Vec<FramesSim>, ) -> Self
Construct the builder from already-loaded, in-memory entities instead of
reading the database. Used by the lazy builders, which load only a
per-batch slice of peptides/ions (the scans/frames metadata is full).
All lookup maps are derived identically to from_source, so a builder
constructed here behaves exactly like an eager one restricted to the
supplied entities.
Sourcepub fn precursor_frame_contributions(
&self,
frame_id: u32,
) -> Vec<(i32, MzSpectrum)>
pub fn precursor_frame_contributions( &self, frame_id: u32, ) -> Vec<(i32, MzSpectrum)>
Vendor-neutral MS1 spectral-contribution kernel (P6a): the ordered
(scan, scaled_spectrum) contributions for a precursor frame — for each
(peptide, ion, scan) the isotope spectrum scaled by its abundance factor,
PRE m/z-noise, in builder order (peptide → ion → scan). Bruker aggregates
these per scan into a TimsFrame (see build_precursor_frame); a non-IMS
instrument sums them into a single MS1 Scan. Factoring this out lets both
vendors share the exact same physics without duplicating it.
Sourcepub fn precursor_scan_spectrum(&self, frame_id: u32) -> MzSpectrum
pub fn precursor_scan_spectrum(&self, frame_id: u32) -> MzSpectrum
Faithful sum of the per-scan contributions for a frame into ONE spectrum:
Σ_scans (scaled_spectrum). The scan coordinate is discarded; peaks at the
same m/z merge (from_collection’s deterministic m/z binning).
NOTE — this is not the correct non-IMS MS1 physics. It reproduces what
the TIMS scan grid captured, whose total mobility mass is Σ scan_abundance
≲ target_p (grid truncation) and can be far less for ions whose mobility
sits at/outside the grid edge (those are under-counted, or dropped entirely
when no scan captured them). A real no-mobility instrument has no such grid,
so it sees the FULL mobility marginal — use
Self::precursor_scan_marginal_spectrum for the Astral render. This
captured-grid collapse is kept as a diagnostic / exact-equivalent of the
Bruker per-scan contributions.
Sourcepub fn precursor_scan_marginal_spectrum(&self, frame_id: u32) -> MzSpectrum
pub fn precursor_scan_marginal_spectrum(&self, frame_id: u32) -> MzSpectrum
Non-IMS (e.g. Astral) MS1 spectrum: the full mobility marginal (P6c).
A no-mobility instrument integrates the entire ion-mobility distribution
(marginal = 1.0 by construction) — it cannot lose ions to TIMS-grid
truncation. So each (peptide, ion) in the frame contributes its isotope
spectrum scaled by frame_abundance × ion_abundance × total_events, with
the per-scan mobility split (scan_abundance, summing to ≲ target_p)
replaced by the full marginal 1.0. Crucially, ions are included by frame
membership (frame_abundance > 0), NOT by whether the TIMS grid captured
any of their mobility — so grid-edge ions [precursor_scan_spectrum] would
under-count or drop are recorded at full abundance. PRE m/z-noise; peaks at
the same m/z merge deterministically.
Sourcepub fn render_precursor_scan(
&self,
frame_id: u32,
data_mode: DataMode,
) -> RenderedEvent
pub fn render_precursor_scan( &self, frame_id: u32, data_mode: DataMode, ) -> RenderedEvent
Render a precursor (MS1) frame as a vendor-neutral RenderedEvent::Scan
for a non-IMS instrument (P6c). This is the scan-based render core’s MS1
path: it collapses the mobility axis via
Self::precursor_scan_marginal_spectrum (the full mobility marginal, the
correct non-IMS physics — NOT the captured-grid sum) into the single MS1
spectrum an Astral/Orbitrap records.
The spectrum is tagged as physical-m/z, NOT detector-applied, at the
IntensityStage::Mobility stage — the marginal already carries the yield
(events), time (frame abundance) and mobility (fully integrated) factors,
but no quadrupole transmission (MS1 is unisolated) and no detector response;
the writer / detector model applies those downstream without double-
counting. data_mode is the instrument’s MS1 acquisition mode (Astral MS1 =
Profile). Returns an empty-spectrum Scan for a frame with no
contributions (the caller decides whether to emit it).
Sourcepub fn build_precursor_frame(
&self,
frame_id: u32,
mz_noise_precursor: bool,
uniform: bool,
precursor_noise_ppm: f64,
right_drag: bool,
) -> TimsFrame
pub fn build_precursor_frame( &self, frame_id: u32, mz_noise_precursor: bool, uniform: bool, precursor_noise_ppm: f64, right_drag: bool, ) -> TimsFrame
Sourcepub fn build_precursor_frames(
&self,
frame_ids: Vec<u32>,
mz_noise_precursor: bool,
uniform: bool,
precursor_noise_ppm: f64,
right_drag: bool,
num_threads: usize,
) -> Vec<TimsFrame>
pub fn build_precursor_frames( &self, frame_ids: Vec<u32>, mz_noise_precursor: bool, uniform: bool, precursor_noise_ppm: f64, right_drag: bool, num_threads: usize, ) -> Vec<TimsFrame>
pub fn build_precursor_frame_annotated( &self, frame_id: u32, mz_noise_precursor: bool, uniform: bool, precursor_noise_ppm: f64, right_drag: bool, ) -> TimsFrameAnnotated
pub fn build_precursor_frames_annotated( &self, frame_ids: Vec<u32>, mz_noise_precursor: bool, uniform: bool, precursor_noise_ppm: f64, right_drag: bool, num_threads: usize, ) -> Vec<TimsFrameAnnotated>
Auto Trait Implementations§
impl Freeze for TimsTofSyntheticsPrecursorFrameBuilder
impl RefUnwindSafe for TimsTofSyntheticsPrecursorFrameBuilder
impl Send for TimsTofSyntheticsPrecursorFrameBuilder
impl Sync for TimsTofSyntheticsPrecursorFrameBuilder
impl Unpin for TimsTofSyntheticsPrecursorFrameBuilder
impl UnsafeUnpin for TimsTofSyntheticsPrecursorFrameBuilder
impl UnwindSafe for TimsTofSyntheticsPrecursorFrameBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.