![]() |
OpenMS
|
Pre-binned averagine isotope-distribution cache used by FLASHDeconv for fast cosine-similarity scoring. More...
#include <OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h>
Public Member Functions | |
| PrecalculatedAveragine ()=default | |
| Default-construct an empty cache (no bins populated; the accessors are not safe until the parameterised ctor is used). | |
| PrecalculatedAveragine (double min_mass, double max_mass, double delta, CoarseIsotopePatternGenerator &generator, bool use_RNA_averagine, double decoy_iso_distance=-1) | |
Precompute averagine isotope distributions across min_mass .. max_mass in steps of delta. | |
| PrecalculatedAveragine (const PrecalculatedAveragine &)=default | |
| Copy constructor. | |
| PrecalculatedAveragine (PrecalculatedAveragine &&other) noexcept=default | |
| Move constructor. | |
| PrecalculatedAveragine & | operator= (const PrecalculatedAveragine &pc)=default |
| Copy assignment. | |
| PrecalculatedAveragine & | operator= (PrecalculatedAveragine &&pc) noexcept=default |
| Move assignment. | |
| ~PrecalculatedAveragine ()=default | |
| Destructor. | |
| IsotopeDistribution | get (double mass) const |
Return the cached trimmed + L2-normalised isotope distribution for the bin containing mass. | |
| size_t | getMaxIsotopeIndex () const |
| Return the externally-set isotope-index cap. | |
| void | setMaxIsotopeIndex (int index) |
| Set the isotope-index cap consulted by external callers. Does not influence the cached distributions or other accessors. | |
| Size | getLeftCountFromApex (double mass) const |
Return the number of significant isotopes to the left of the apex for the bin containing mass. | |
| Size | getRightCountFromApex (double mass) const |
Return the number of significant isotopes to the right of the apex for the bin containing mass. | |
| Size | getApexIndex (double mass) const |
Return the index of the most-abundant isotope inside the trimmed distribution for the bin containing mass. | |
| Size | getLastIndex (double mass) const |
Return apex_index + right_count_from_apex for the bin containing mass — the index of the rightmost significant isotope. | |
| double | getAverageMassDelta (double mass) const |
Return (average_mass - monoisotopic_mass) for the bin's trimmed distribution. | |
| double | getMostAbundantMassDelta (double mass) const |
Return (most_abundant_mass - monoisotopic_mass) for the bin's trimmed distribution. | |
| double | getSNRMultiplicationFactor (double mass) const |
Return the SNR multiplication factor for the bin containing mass. | |
Private Member Functions | |
| Size | massToIndex_ (double mass) const |
Convert mass to a bin index. Clamps to [0, isotopes_.size()-1] for out-of-range inputs (no throw). | |
Private Attributes | |
| std::vector< IsotopeDistribution > | isotopes_ |
| Per-bin isotope distribution. After trimming and L2 normalisation in the constructor. | |
| std::vector< double > | norms_ |
| Per-bin L2 norm — populated and consumed alongside isotopes_ for fast cosine scoring (vestigial: not consumed by the public API in this header). | |
| std::vector< double > | average_mono_mass_difference_ |
| Per-bin difference between the average mass and the monoisotopic mass of the trimmed distribution. | |
| std::vector< double > | abundant_mono_mass_difference_ |
| Per-bin difference between the most-abundant-isotope mass and the monoisotopic mass. | |
| std::vector< double > | snr_mul_factor_ |
Per-bin SNR multiplication factor: (sum-of-normalised-intensities)^2 of the trimmed distribution. | |
| std::vector< int > | left_count_from_apex_ |
Per-bin count of significant isotopes on the left side of the apex (running maximum across bins; see the PrecalculatedAveragine parameterised constructor for the unusual running-max semantics). | |
| std::vector< int > | right_count_from_apex_ |
| Per-bin count of significant isotopes on the right side of the apex (running maximum across bins; same caveat as left_count_from_apex_). | |
| std::vector< Size > | apex_index_ |
| Per-bin index of the most-abundant isotope inside the trimmed distribution. | |
| Size | max_isotope_index_ |
| Cap on the isotope index used externally by FLASHDeconv. NOT initialised by the constructor — call setMaxIsotopeIndex before reading via getMaxIsotopeIndex. | |
| double | mass_interval_ |
Bin step size (the delta passed to the constructor). | |
| double | min_mass_ |
Lower bound of the cached mass range (the min_mass passed to the constructor). | |
Pre-binned averagine isotope-distribution cache used by FLASHDeconv for fast cosine-similarity scoring.
Builds a table keyed by a mass bin index — one IsotopeDistribution plus its derived quantities (apex index, left/right counts of significant isotopes, average / most-abundant mass offsets, an SNR multiplication factor) per mass bin from min_mass to max_mass at step delta. The constructor performs all the per-mass work up front; the accessors are O(1) table lookups via massToIndex_(mass) (rounded to the nearest bin).
Bin lookup silently clamps: any mass below min_mass maps to bin 0 and any mass above max_mass maps to the last bin, so the accessors never throw on out-of-range input.
|
default |
Default-construct an empty cache (no bins populated; the accessors are not safe until the parameterised ctor is used).
| PrecalculatedAveragine | ( | double | min_mass, |
| double | max_mass, | ||
| double | delta, | ||
| CoarseIsotopePatternGenerator & | generator, | ||
| bool | use_RNA_averagine, | ||
| double | decoy_iso_distance = -1 |
||
| ) |
Precompute averagine isotope distributions across min_mass .. max_mass in steps of delta.
For each bin mass m = i*delta in the range, calls CoarseIsotopePatternGenerator::estimateFromPeptideMonoWeight(m) (or estimateFromRNAMonoWeight(m) when use_RNA_averagine is true) and applies the following processing:
0.0001 of the total, with a minimum kept length of 2 peaks. Trimmed peaks have their intensity zeroed out, not removed from the distribution.sqrt(total_pwr) of the kept set.decoy_iso_distance is > 0, every peak's m/z is multiplied by decoy_iso_distance before trimming, then the distribution is re-sorted by mass and renormalised. This produces a "stretched" pattern whose inter-isotope spacing is decoy_iso_distance times the natural spacing.2 each, and then accumulated as a running maximum across bins — so all bins end up with the same width (the maximum seen so far during construction).Per bin, the constructor records the trimmed distribution, the apex index, the running-max left/right counts, the average-mono and most-abundant-mono mass deltas, and the SNR multiplication factor (sum-of-normalised-intensities)^2.
| [in] | min_mass | Lower bound of the cached mass range; bins are built starting at the first multiple of delta that is >= min_mass. |
| [in] | max_mass | Upper bound of the cached mass range; bin generation stops at the first multiple of delta that exceeds max_mass. |
| [in] | delta | Bin step size. |
| [in,out] | generator | Isotope-pattern generator used to compute each per-mass distribution. |
| [in] | use_RNA_averagine | If true, use the RNA-mass averagine; otherwise use peptide averagine. |
| [in] | decoy_iso_distance | > 0 enables decoy mode (per-peak m/z multiplied by this value); <= 0 disables it. Default -1. |
|
default |
Copy constructor.
|
defaultnoexcept |
Move constructor.
|
default |
Destructor.
| IsotopeDistribution get | ( | double | mass | ) | const |
Return the cached trimmed + L2-normalised isotope distribution for the bin containing mass.
| [in] | mass | Input mass to query. Out-of-range values are silently clamped to [min_mass, max_mass]. |
| Size getApexIndex | ( | double | mass | ) | const |
Return the index of the most-abundant isotope inside the trimmed distribution for the bin containing mass.
| [in] | mass | Input mass to query. Out-of-range values are silently clamped to [min_mass, max_mass]. |
| double getAverageMassDelta | ( | double | mass | ) | const |
Return (average_mass - monoisotopic_mass) for the bin's trimmed distribution.
| [in] | mass | Input mass to query. Out-of-range values are silently clamped to [min_mass, max_mass]. |
| Size getLastIndex | ( | double | mass | ) | const |
Return apex_index + right_count_from_apex for the bin containing mass — the index of the rightmost significant isotope.
| [in] | mass | Input mass to query. Out-of-range values are silently clamped to [min_mass, max_mass]. |
| Size getLeftCountFromApex | ( | double | mass | ) | const |
Return the number of significant isotopes to the left of the apex for the bin containing mass.
mass (see the parameterised constructor's left/right-count semantics).| [in] | mass | Input mass to query. Out-of-range values are silently clamped to [min_mass, max_mass]. |
| size_t getMaxIsotopeIndex | ( | ) | const |
Return the externally-set isotope-index cap.
max_isotope_index_; reading this before setMaxIsotopeIndex has been called returns an uninitialised value.| double getMostAbundantMassDelta | ( | double | mass | ) | const |
Return (most_abundant_mass - monoisotopic_mass) for the bin's trimmed distribution.
| [in] | mass | Input mass to query. Out-of-range values are silently clamped to [min_mass, max_mass]. |
| Size getRightCountFromApex | ( | double | mass | ) | const |
Return the number of significant isotopes to the right of the apex for the bin containing mass.
| [in] | mass | Input mass to query. Out-of-range values are silently clamped to [min_mass, max_mass]. |
| double getSNRMultiplicationFactor | ( | double | mass | ) | const |
Return the SNR multiplication factor for the bin containing mass.
(sum-of-normalised-intensities)^2 of the trimmed distribution. Used by FLASHDeconv for fast SNR computation.
| [in] | mass | Input mass to query. Out-of-range values are silently clamped to [min_mass, max_mass]. |
|
private |
Convert mass to a bin index. Clamps to [0, isotopes_.size()-1] for out-of-range inputs (no throw).
|
default |
Copy assignment.
|
defaultnoexcept |
Move assignment.
| void setMaxIsotopeIndex | ( | int | index | ) |
Set the isotope-index cap consulted by external callers. Does not influence the cached distributions or other accessors.
| [in] | index | New isotope-index cap value. |
|
private |
Per-bin difference between the most-abundant-isotope mass and the monoisotopic mass.
|
private |
Per-bin index of the most-abundant isotope inside the trimmed distribution.
|
private |
Per-bin difference between the average mass and the monoisotopic mass of the trimmed distribution.
|
private |
Per-bin isotope distribution. After trimming and L2 normalisation in the constructor.
|
private |
Per-bin count of significant isotopes on the left side of the apex (running maximum across bins; see the PrecalculatedAveragine parameterised constructor for the unusual running-max semantics).
|
private |
Bin step size (the delta passed to the constructor).
|
private |
Cap on the isotope index used externally by FLASHDeconv. NOT initialised by the constructor — call setMaxIsotopeIndex before reading via getMaxIsotopeIndex.
|
private |
Lower bound of the cached mass range (the min_mass passed to the constructor).
|
private |
Per-bin L2 norm — populated and consumed alongside isotopes_ for fast cosine scoring (vestigial: not consumed by the public API in this header).
|
private |
Per-bin count of significant isotopes on the right side of the apex (running maximum across bins; same caveat as left_count_from_apex_).
|
private |
Per-bin SNR multiplication factor: (sum-of-normalised-intensities)^2 of the trimmed distribution.