![]() |
OpenMS
|
Helper utilities for matching MS2 spectra to LC-MS features by precursor (m/z, RT). More...
#include <OpenMS/ANALYSIS/MAPMATCHING/FeatureMapping.h>
Classes | |
| class | FeatureMappingInfo |
| Input bundle: feature maps and a spatial index over them. More... | |
| class | FeatureToMs2Indices |
| Output bundle: per-feature MS2 spectrum indices + the list of unassigned MS2 spectra. More... | |
Static Public Member Functions | |
| static FeatureToMs2Indices | assignMS2IndexToFeature (const MSExperiment &spectra, const FeatureMappingInfo &fm_info, const double &precursor_mz_tolerance, const double &precursor_rt_tolerance, bool ppm) |
| Assign each MS2 spectrum to the feature whose precursor matches it best. | |
Helper utilities for matching MS2 spectra to LC-MS features by precursor (m/z, RT).
The class is a thin namespace holding two nested record types and one static algorithm:
A typical caller builds a FeatureMappingInfo once (loading the maps and constructing the kd-tree), then calls assignMS2IndexToFeature per MS run. The kd-tree must be built from the same maps stored in feature_maps so that the indices returned by range queries refer back into the caller-visible feature pointers.
Workflows that use this include SIRIUS export and other "annotate MS2 with quantified feature" pipelines.
| class OpenMS::FeatureMapping::FeatureMappingInfo |
Input bundle: feature maps and a spatial index over them.
feature_maps owns the raw FeatureMap objects (one per input run); kd_tree is a KDTreeFeatureMaps pre-populated with the same features and provides fast (RT, m/z) range queries. The caller is responsible for keeping the two consistent (i.e. building the kd-tree from the same maps stored here).
| Class Members | ||
|---|---|---|
| vector< FeatureMap > | feature_maps | feature data, one map per input run |
| KDTreeFeatureMaps | kd_tree |
(RT, m/z) kd-tree referencing the features in feature_maps |
| class OpenMS::FeatureMapping::FeatureToMs2Indices |
Output bundle: per-feature MS2 spectrum indices + the list of unassigned MS2 spectra.
Keys of assignedMS2 are non-owning pointers into the FeatureMap data held by the FeatureMappingInfo passed to assignMS2IndexToFeature; the values are spectrum indices into the spectra input. unassignedMS2 holds the indices of MS2 spectra that had at least one precursor but no feature inside the tolerance window (MS2 spectra without a precursor are silently dropped and appear in neither container).
| Class Members | ||
|---|---|---|
| map< const BaseFeature *, vector< size_t > > | assignedMS2 | MS2 spectrum indices grouped by the feature they were assigned to. |
| vector< size_t > | unassignedMS2 | Indices of MS2 spectra that had a precursor but no feature inside the tolerance window. |
|
static |
Assign each MS2 spectrum to the feature whose precursor matches it best.
For every MS2 spectrum in spectra:
unassignedMS2).fm_info.kd_tree using a rectangular tolerance window: RT: precursor_rt_tolerance (absolute, around the spectrum's RT) m/z: precursor_mz_tolerance (ppm if ppm is true, otherwise Th, around the first precursor's m/z) Features from any map are eligible (the kd-tree query is run with include_features_from_same_map = true).unassignedMS2.precursors()[0] only).The result groups spectrum indices by their winning feature; each spectrum index appears at most once in either the assigned or the unassigned collection.
| [in] | spectra | Run-level spectrum container (MS1 and MS2 mixed; MS2 spectra are processed). |
| [in] | fm_info | Feature maps + kd-tree bundle (the kd-tree must reference fm_info.feature_maps). |
| [in] | precursor_mz_tolerance | Half-width of the m/z tolerance window (ppm if ppm, else Th). |
| [in] | precursor_rt_tolerance | Half-width of the RT tolerance window in seconds (absolute). |
| [in] | ppm | If true, interpret precursor_mz_tolerance as ppm; otherwise as Th. |