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
139 static bool hasBlacklistOwners(const MSExperiment& blacklist);
140
142 static UInt64 blacklistOwner(const MSSpectrum& spectrum, Size peak_index);
143
145 static void setBlacklistOwners(MSSpectrum& spectrum, const std::vector<UInt64>& owners);
146
148 enum class OwnerRelation
149 {
150 ORPHAN,
151 OWN,
152 SAME_PEPTIDE,
153 UNIDENTIFIED,
154 OTHER_PEPTIDE
155 };
156
158 using OwnerPeptides = std::unordered_map<UInt64, std::string>;
159
167 OwnerPeptides ownerPeptides(const ConsensusMap& multiplets) const;
168
170 std::string peptideKey(const PeptideHit& hit, int charge) const;
171
179 static OwnerRelation classifyBlacklistOwner(UInt64 owner, const ConsensusFeature& consensus, const OwnerPeptides& peptides);
180
190 static OwnerRelation classifyBlacklistOwner(UInt64 owner, const std::string& peptide, const OwnerPeptides& peptides);
191
199 static bool isForeign(OwnerRelation relation);
201
202 protected:
205
207 static double deltaMassFromMapIndex_(const ConsensusFeature::HandleSetType& feature_handles, unsigned idx);
208
217 static double matchLabelSet_(const std::vector<MultiplexDeltaMasses::DeltaMass>& pattern,
218 const MultiplexDeltaMasses::LabelSet& label_set, int& index_label_set);
219
230 bool matchDeltaMasses_(const ConsensusFeature& consensus, double detected_delta_mass_at_label_set,
231 const std::vector<MultiplexDeltaMasses::DeltaMass>& pattern,
232 double theoretical_delta_mass_at_label_set, std::vector<bool>& delta_mass_matched) const;
233
247 int findMatchingPattern_(const ConsensusFeature& consensus, double detected_delta_mass_at_label_set,
248 const AASequence& sequence, const MultiplexDeltaMasses::LabelSet& label_set,
249 const std::vector<MultiplexDeltaMasses>& theoretical_patterns,
250 const std::vector<std::vector<std::string>>& samples,
251 std::vector<bool>& delta_mass_matched, int& index_label_set) const;
252
269 static bool matchesResidues_(const std::vector<MultiplexDeltaMasses::DeltaMass>& pattern, const AASequence& sequence,
270 const std::vector<std::vector<std::string>>& samples);
271
273 static double findNewMZ_(double mz, int charge, const std::vector<MultiplexDeltaMasses::DeltaMass>& pattern,
274 const std::vector<bool>& delta_mass_matched);
275
277 bool isBlacklisted_(const MSExperiment& blacklist, double rt, double mz, size_t charge, const ConsensusFeature& consensus) const;
278
281 {
282 Size dummies = 0;
283 Size added = 0;
284 Size dummies_vetoed = 0;
285 Size added_vetoed = 0;
286 Size other_peptide = 0;
287 Size same_peptide = 0;
288 Size unidentified = 0;
289 Size usable = 0;
290 Size own = 0;
291 Size orphan = 0;
292 Size anonymous = 0;
293 };
294
301 bool isReservedByOther_(const MSExperiment& blacklist, double rt, double mz, size_t charge, const ConsensusFeature& consensus,
302 const OwnerPeptides& peptides, OwnerCheckCounts_& counts) const;
303
317 ConsensusFeature completeConsensus_(const ConsensusFeature& consensus, const std::vector<MultiplexDeltaMasses::DeltaMass>& pattern,
318 const std::vector<bool>& delta_mass_matched, int index_label_set,
319 const MSExperiment& blacklist, const OwnerPeptides* peptides = nullptr,
320 OwnerCheckCounts_* counts = nullptr) const;
321
323 double mass_tolerance_ = 0.1;
325 double mz_tolerance_ = 10.0;
327 double rt_tolerance_ = 5.0;
329 bool use_blacklist_owners_ = false;
330
331 void updateMembers_() override;
332 };
333} // 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:44
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?
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:149
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:158
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:281
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