OpenMS
Loading...
Searching...
No Matches
MultiplexResolverAlgorithm.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Lars Nilse, Timo Sachsenberg $
7// --------------------------------------------------------------------------
8
9#pragma once
10
15
16#include <map>
17#include <string>
18#include <unordered_map>
19#include <vector>
20
21namespace OpenMS
22{
23 class AASequence;
24 class MultiplexDeltaMassesGenerator;
25
71 {
72 public:
75
96 void resolve(const ConsensusMap& map_in, ConsensusMap& map_out, ConsensusMap& map_conflicts,
97 const MSExperiment& blacklist = MSExperiment()) const;
98
111 std::vector<bool> checkIdentifications(const ConsensusFeature& consensus) const;
112
126 std::vector<double> expectedChannelMZs(const AASequence& sequence, int charge, Size& position) const;
127
138 std::vector<double> expectedChannelMZs(const AASequence& sequence, int charge, Size& position,
139 std::vector<MultiplexDeltaMasses::LabelSet>& label_sets) const;
140
152 static bool hasBlacklistOwners(const MSExperiment& blacklist);
153
155 static UInt64 blacklistOwner(const MSSpectrum& spectrum, Size peak_index);
156
158 static void setBlacklistOwners(MSSpectrum& spectrum, const std::vector<UInt64>& owners);
159
161 enum class OwnerRelation
162 {
163 ORPHAN,
164 OWN,
165 SAME_PEPTIDE,
166 UNIDENTIFIED,
167 OTHER_PEPTIDE
168 };
169
171 using OwnerPeptides = std::unordered_map<UInt64, std::string>;
172
180 OwnerPeptides ownerPeptides(const ConsensusMap& multiplets) const;
181
183 std::string peptideKey(const PeptideHit& hit, int charge) const;
184
192 static OwnerRelation classifyBlacklistOwner(UInt64 owner, const ConsensusFeature& consensus, const OwnerPeptides& peptides);
193
203 static OwnerRelation classifyBlacklistOwner(UInt64 owner, const std::string& peptide, const OwnerPeptides& peptides);
204
212 static bool isForeign(OwnerRelation relation);
214
215 protected:
218
220 static double deltaMassFromMapIndex_(const ConsensusFeature::HandleSetType& feature_handles, unsigned idx);
221
230 static double matchLabelSet_(const std::vector<MultiplexDeltaMasses::DeltaMass>& pattern,
231 const MultiplexDeltaMasses::LabelSet& label_set, int& index_label_set);
232
243 bool matchDeltaMasses_(const ConsensusFeature& consensus, double detected_delta_mass_at_label_set,
244 const std::vector<MultiplexDeltaMasses::DeltaMass>& pattern,
245 double theoretical_delta_mass_at_label_set, std::vector<bool>& delta_mass_matched) const;
246
260 int findMatchingPattern_(const ConsensusFeature& consensus, double detected_delta_mass_at_label_set,
261 const AASequence& sequence, const MultiplexDeltaMasses::LabelSet& label_set,
262 const std::vector<MultiplexDeltaMasses>& theoretical_patterns,
263 const std::vector<std::vector<std::string>>& samples,
264 std::vector<bool>& delta_mass_matched, int& index_label_set) const;
265
282 static bool matchesResidues_(const std::vector<MultiplexDeltaMasses::DeltaMass>& pattern, const AASequence& sequence,
283 const std::vector<std::vector<std::string>>& samples);
284
286 static double findNewMZ_(double mz, int charge, const std::vector<MultiplexDeltaMasses::DeltaMass>& pattern,
287 const std::vector<bool>& delta_mass_matched);
288
290 bool isBlacklisted_(const MSExperiment& blacklist, double rt, double mz, size_t charge, const ConsensusFeature& consensus) const;
291
294 {
295 Size dummies = 0;
296 Size added = 0;
297 Size dummies_vetoed = 0;
298 Size added_vetoed = 0;
299 Size other_peptide = 0;
300 Size same_peptide = 0;
301 Size unidentified = 0;
302 Size usable = 0;
303 Size own = 0;
304 Size orphan = 0;
305 Size anonymous = 0;
306 };
307
314 bool isReservedByOther_(const MSExperiment& blacklist, double rt, double mz, size_t charge, const ConsensusFeature& consensus,
315 const OwnerPeptides& peptides, OwnerCheckCounts_& counts) const;
316
330 ConsensusFeature completeConsensus_(const ConsensusFeature& consensus, const std::vector<MultiplexDeltaMasses::DeltaMass>& pattern,
331 const std::vector<bool>& delta_mass_matched, int index_label_set,
332 const MSExperiment& blacklist, const OwnerPeptides* peptides = nullptr,
333 OwnerCheckCounts_* counts = nullptr) const;
334
336 double mass_tolerance_ = 0.1;
338 double mz_tolerance_ = 10.0;
340 double rt_tolerance_ = 5.0;
342 bool use_blacklist_owners_ = false;
343
344 void updateMembers_() override;
345 };
346} // namespace OpenMS
Definition AASequence.h:96
A consensus feature spanning multiple LC-MS/MS experiments.
Definition ConsensusFeature.h:45
std::set< FeatureHandle, FeatureHandle::IndexLess > HandleSetType
Type definitions.
Definition ConsensusFeature.h:49
A container for consensus elements.
Definition ConsensusMap.h:67
A base class for all classes handling default parameters.
Definition DefaultParamHandler.h:66
In-Memory representation of a mass spectrometry run.
Definition MSExperiment.h:49
The representation of a 1D spectrum.
Definition MSSpectrum.h:45
generates complete list of all possible mass shifts due to isotopic labelling
Definition MultiplexDeltaMassesGenerator.h:36
std::multiset< std::string > LabelSet
set of labels associated with a mass shift
Definition MultiplexDeltaMasses.h:46
Completes peptide multiplets and resolves quant/ID conflicts within them.
Definition MultiplexResolverAlgorithm.h:71
void resolve(const ConsensusMap &map_in, ConsensusMap &map_out, ConsensusMap &map_conflicts, const MSExperiment &blacklist=MSExperiment()) const
Split the annotated multiplets of map_in into resolved and conflicting ones.
std::vector< double > expectedChannelMZs(const AASequence &sequence, int charge, Size &position) const
Where the peptide of sequence appears in every channel.
std::vector< bool > checkIdentifications(const ConsensusFeature &consensus) const
Which peptide identifications of consensus agree with its detected mass shifts?
std::vector< double > expectedChannelMZs(const AASequence &sequence, int charge, Size &position, std::vector< MultiplexDeltaMasses::LabelSet > &label_sets) const
As expectedChannelMZs() above, and the labels of the peptide in every channel.
bool isBlacklisted_(const MSExperiment &blacklist, double rt, double mz, size_t charge, const ConsensusFeature &consensus) const
Is one of the first three isotopes of a (dummy) feature at this position blacklisted?...
static double matchLabelSet_(const std::vector< MultiplexDeltaMasses::DeltaMass > &pattern, const MultiplexDeltaMasses::LabelSet &label_set, int &index_label_set)
Mass shift of the theoretical pattern whose label set equals label_set.
static OwnerRelation classifyBlacklistOwner(UInt64 owner, const ConsensusFeature &consensus, const OwnerPeptides &peptides)
How the feature owner, which reserved a blacklisted peak, relates to the multiplet consensus.
OwnerRelation
How the owner of a blacklisted peak relates to a multiplet.
Definition MultiplexResolverAlgorithm.h:162
MultiplexDeltaMassesGenerator createGenerator_() const
The generator of the theoretical mass-shift patterns, as configured in the sections algorithm and lab...
static bool hasBlacklistOwners(const MSExperiment &blacklist)
static OwnerRelation classifyBlacklistOwner(UInt64 owner, const std::string &peptide, const OwnerPeptides &peptides)
How the feature owner, which reserved a blacklisted peak, relates to the peptide peptide (of an ident...
static bool matchesResidues_(const std::vector< MultiplexDeltaMasses::DeltaMass > &pattern, const AASequence &sequence, const std::vector< std::vector< std::string > > &samples)
Does every channel of pattern label exactly the residues sequence has?
int findMatchingPattern_(const ConsensusFeature &consensus, double detected_delta_mass_at_label_set, const AASequence &sequence, const MultiplexDeltaMasses::LabelSet &label_set, const std::vector< MultiplexDeltaMasses > &theoretical_patterns, const std::vector< std::vector< std::string > > &samples, std::vector< bool > &delta_mass_matched, int &index_label_set) const
Find the theoretical delta mass pattern matching the detected one.
OwnerPeptides ownerPeptides(const ConsensusMap &multiplets) const
The peptide of every detected channel (feature handle with a unique id) of the identified multiplets ...
static double findNewMZ_(double mz, int charge, const std::vector< MultiplexDeltaMasses::DeltaMass > &pattern, const std::vector< bool > &delta_mass_matched)
m/z of the lightest peptide of the complete multiplet, given the incomplete one at mz
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
static UInt64 blacklistOwner(const MSSpectrum &spectrum, Size peak_index)
The unique id of the feature that reserved peak peak_index of spectrum (UniqueIdInterface::INVALID if...
bool isReservedByOther_(const MSExperiment &blacklist, double rt, double mz, size_t charge, const ConsensusFeature &consensus, const OwnerPeptides &peptides, OwnerCheckCounts_ &counts) const
Is a peak reserved by another multiplet within the m/z tolerance of one of the first three isotopes a...
static bool isForeign(OwnerRelation relation)
Does a peak reserved by an owner of this relation belong to another multiplet? (UNIDENTIFIED,...
static double deltaMassFromMapIndex_(const ConsensusFeature::HandleSetType &feature_handles, unsigned idx)
Relative delta mass between the first feature handle and the handle with map index idx (NaN if absent...
std::unordered_map< UInt64, std::string > OwnerPeptides
Peptide (as compared by classifyBlacklistOwner()) of each detected channel of the identified multiple...
Definition MultiplexResolverAlgorithm.h:171
MultiplexResolverAlgorithm()
Constructor; registers the algorithm and labels parameter sections.
std::string peptideKey(const PeptideHit &hit, int charge) const
The peptide of hit at charge charge, as ownerPeptides() names it (the sequence without the labels,...
bool matchDeltaMasses_(const ConsensusFeature &consensus, double detected_delta_mass_at_label_set, const std::vector< MultiplexDeltaMasses::DeltaMass > &pattern, double theoretical_delta_mass_at_label_set, std::vector< bool > &delta_mass_matched) const
Check whether all delta masses of the detected pattern match one of the theoretical pattern.
ConsensusFeature completeConsensus_(const ConsensusFeature &consensus, const std::vector< MultiplexDeltaMasses::DeltaMass > &pattern, const std::vector< bool > &delta_mass_matched, int index_label_set, const MSExperiment &blacklist, const OwnerPeptides *peptides=nullptr, OwnerCheckCounts_ *counts=nullptr) const
Complete an incomplete multiplet with dummy features.
static void setBlacklistOwners(MSSpectrum &spectrum, const std::vector< UInt64 > &owners)
Record owners (one unique id per peak, INVALID if none) as the owners of the peaks of spectrum.
What the owner-aware blacklist check found in resolve(), for its log.
Definition MultiplexResolverAlgorithm.h:294
Represents a single spectrum match (candidate) for a specific tandem mass spectrum (MS/MS).
Definition PeptideHit.h:52
uint64_t UInt64
Unsigned integer type (64bit)
Definition Types.h:47
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19