OpenMS
Loading...
Searching...
No Matches
ObservationMatch.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: Hendrik Weisser $
6// $Authors: Hendrik Weisser $
7// --------------------------------------------------------------------------
8
9#pragma once
10
12
16#include <OpenMS/METADATA/PeptideHit.h> // for "PeakAnnotation"
18
19
20namespace OpenMS
21{
22 namespace IdentificationDataInternal
23 {
24 // @TODO: move "PeakAnnotation" out of "PeptideHit"
25 typedef std::vector<PeptideHit::PeakAnnotation> PeakAnnotations;
26 typedef std::map<std::optional<ProcessingStepRef>,
28
30 // @TODO: this allows adducts with duplicate names, but requires different
31 // sum formulas/charges - is this what we want?
33 {
34 bool operator()(const AdductInfo& left, const AdductInfo& right) const
35 {
36 return (std::make_pair(left.getCharge(), left.getEmpiricalFormula()) <
37 std::make_pair(right.getCharge(), right.getEmpiricalFormula()));
38 }
39 };
40
41 typedef std::set<AdductInfo, AdductCompare> Adducts;
43 typedef std::optional<AdductRef> AdductOpt;
44
47 {
49
51
53
55
56 // peak annotations (fragment ion matches), potentially from different
57 // data processing steps:
59
72
74
76 {
78 if (charge == 0)
79 {
80 charge = other.charge;
81 }
82 else if (charge != other.charge)
83 {
84 throw Exception::InvalidValue(__FILE__, __LINE__,
85 OPENMS_PRETTY_FUNCTION,
86 "Trying to overwrite ObservationMatch charge with conflicting value.",
88 }
89
90 if (!adduct_opt)
91 {
92 adduct_opt = other.adduct_opt;
93 }
94 else if (adduct_opt != other.adduct_opt)
95 {
96 throw Exception::InvalidValue(__FILE__, __LINE__,
97 OPENMS_PRETTY_FUNCTION,
98 "Trying to overwrite ObservationMatch adduct_opt with conflicting value.",
99 (*adduct_opt)->getName());
100 }
101
102 peak_annotations.insert(other.peak_annotations.begin(),
103 other.peak_annotations.end());
104 return *this;
105 }
106 };
107
108 // all matches for the same observation should be consecutive, so make sure
109 // the observation is used as the first member in the composite key:
111
113 }
114}
Mass-arithmetic helper for ionizing adducts (e.g. [M+H]+, [2M-H]-, [M+2K-H]+).
Definition AdductInfo.h:91
int getCharge() const
Signed ion charge.
const EmpiricalFormula & getEmpiricalFormula() const
Neutral EmpiricalFormula of the adduct part alone (no M, no n-mer multiplier).
Invalid value exception.
Definition Exception.h:306
A collection of identification records, unique and ordered by the key formed from the members KeyMemb...
Definition IDDataContainer.h:62
int Int
Signed integer type.
Definition Types.h:72
IDSequencedContainer< AppliedProcessingStep, std::optional< ProcessingStepRef >, &AppliedProcessingStep::processing_step_opt > AppliedProcessingSteps
Definition AppliedProcessingStep.h:64
std::optional< AdductRef > AdductOpt
Definition ObservationMatch.h:43
IteratorWrapper< Adducts::iterator > AdductRef
Definition ObservationMatch.h:42
IteratorWrapper< Observations::iterator > ObservationRef
Definition Observation.h:58
IteratorWrapper< ObservationMatches::iterator > ObservationMatchRef
Definition ObservationMatch.h:112
std::vector< PeptideHit::PeakAnnotation > PeakAnnotations
Definition ObservationMatch.h:25
std::map< std::optional< ProcessingStepRef >, PeakAnnotations > PeakAnnotationSteps
Definition ObservationMatch.h:27
std::set< AdductInfo, AdductCompare > Adducts
Definition ObservationMatch.h:41
std::string toStr(int i)
Definition StringUtils.h:100
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Comparator for adducts.
Definition ObservationMatch.h:33
bool operator()(const AdductInfo &left, const AdductInfo &right) const
Definition ObservationMatch.h:34
Variant type holding Peptide/Compound/Oligo references and convenience functions.
Definition IdentifiedMolecule.h:29
Wrapper that adds operator< to iterators, so they can be used as (part of) keys in maps/sets or multi...
Definition MetaData.h:20
Representation of a search hit (e.g. peptide-spectrum match).
Definition ObservationMatch.h:47
ObservationMatch(const ObservationMatch &)=default
AdductOpt adduct_opt
optional reference to adduct
Definition ObservationMatch.h:54
IdentifiedMolecule identified_molecule_var
Definition ObservationMatch.h:48
Int charge
Definition ObservationMatch.h:52
ObservationMatch & merge(const ObservationMatch &other)
Definition ObservationMatch.h:75
PeakAnnotationSteps peak_annotations
Definition ObservationMatch.h:58
ObservationMatch(IdentifiedMolecule identified_molecule_var, ObservationRef observation_ref, Int charge=0, const std::optional< AdductRef > &adduct_opt=std::nullopt, const AppliedProcessingSteps &steps_and_scores=AppliedProcessingSteps(), const PeakAnnotationSteps &peak_annotations=PeakAnnotationSteps())
Definition ObservationMatch.h:60
ObservationRef observation_ref
Definition ObservationMatch.h:50
Base class for ID data with scores and processing steps (and meta info)
Definition ScoredProcessingResult.h:23
AppliedProcessingSteps steps_and_scores
Definition ScoredProcessingResult.h:24
ScoredProcessingResult & merge(const ScoredProcessingResult &other)
Merge in data from another object.