OpenMS
Loading...
Searching...
No Matches
TargetedSpectraExtractor::BinnedSpectrumComparator Class Reference

Comparator implementation that scores query spectra against the library using BinnedSpectralContrastAngle on pre-binned spectra. More...

#include <OpenMS/ANALYSIS/OPENSWATH/TargetedSpectraExtractor.h>

Inheritance diagram for TargetedSpectraExtractor::BinnedSpectrumComparator:
[legend]
Collaboration diagram for TargetedSpectraExtractor::BinnedSpectrumComparator:
[legend]

Public Member Functions

 ~BinnedSpectrumComparator () override=default
 
void generateScores (const MSSpectrum &spec, std::vector< std::pair< Size, double > > &scores, double min_score) const override
 Bin spec with the configured bin parameters and score it against every entry of the cached library; keep only matches >= min_score.
 
void init (const std::vector< MSSpectrum > &library, const std::map< std::string, DataValue > &options) override
 Cache library, pre-binning each spectrum with the current parameters, and apply any options overrides.
 
- Public Member Functions inherited from TargetedSpectraExtractor::Comparator
virtual ~Comparator ()=default
 
const std::vector< MSSpectrum > & getLibrary () const
 Return the reference library passed to the most recent init call.
 

Private Attributes

BinnedSpectralContrastAngle cmp_bs_
 
std::vector< BinnedSpectrumbs_library_
 
double bin_size_ = 0.02
 
UInt peak_spread_ = 0
 
double bin_offset_ = 0.0
 

Additional Inherited Members

- Protected Attributes inherited from TargetedSpectraExtractor::Comparator
std::vector< MSSpectrumlibrary_
 

Detailed Description

Comparator implementation that scores query spectra against the library using BinnedSpectralContrastAngle on pre-binned spectra.

The reference library is binned exactly once at init time and the cached BinnedSpectrum objects are reused across generateScores calls; only the query spectrum is re-binned on each call. Bin parameters can be overridden through the options map passed to init.

Constructor & Destructor Documentation

◆ ~BinnedSpectrumComparator()

~BinnedSpectrumComparator ( )
overridedefault

Member Function Documentation

◆ generateScores()

void generateScores ( const MSSpectrum spec,
std::vector< std::pair< Size, double > > &  scores,
double  min_score 
) const
inlineoverridevirtual

Bin spec with the configured bin parameters and score it against every entry of the cached library; keep only matches >= min_score.

The query spectrum is wrapped in a new BinnedSpectrum with the current bin_size, peak_spread, and bin_offset (no precursor m/z carried over) and then compared one-by-one against the cached library bins via BinnedSpectralContrastAngle.

Parameters
[in]specQuery spectrum to bin and score.
[out]scoresCleared on entry, then filled with (library_index, score) pairs for matches that clear the threshold; unsorted.
[in]min_scoreLower bound on the kept score (inclusive).

Implements TargetedSpectraExtractor::Comparator.

◆ init()

void init ( const std::vector< MSSpectrum > &  library,
const std::map< std::string, DataValue > &  options 
)
overridevirtual

Cache library, pre-binning each spectrum with the current parameters, and apply any options overrides.

Honours three optional keys in options:

  • "bin_size" (double) — m/z bin width. Default 0.02 (suited for high-resolution data; the comment in the header lists 1.0 as the nominal-mass default).
  • "peak_spread" (UInt) — how many neighbour bins receive contributions from each peak. Default 0.
  • "bin_offset" (double) — m/z offset added to the bin boundaries. Default 0.0.

Both the inherited library_ vector and the internal bs_library_ vector of BinnedSpectrum objects are cleared and rebuilt on every call. Emits one OPENMS_LOG_INFO line reporting the loaded library size.

Implements TargetedSpectraExtractor::Comparator.

Member Data Documentation

◆ bin_offset_

double bin_offset_ = 0.0
private

◆ bin_size_

double bin_size_ = 0.02
private

◆ bs_library_

std::vector<BinnedSpectrum> bs_library_
private

◆ cmp_bs_

BinnedSpectralContrastAngle cmp_bs_
private

◆ peak_spread_

UInt peak_spread_ = 0
private