OpenMS  2.5.0
MoleculeQueryMatch.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2020.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Hendrik Weisser $
32 // $Authors: Hendrik Weisser $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
40 #include <OpenMS/METADATA/PeptideHit.h> // for "PeakAnnotation"
41 
42 #include <boost/multi_index_container.hpp>
43 #include <boost/multi_index/ordered_index.hpp>
44 #include <boost/multi_index/composite_key.hpp>
45 #include <boost/variant.hpp>
46 
47 namespace OpenMS
48 {
49  namespace IdentificationDataInternal
50  {
51  // @TODO: move "PeakAnnotation" out of "PeptideHit"
52  typedef std::vector<PeptideHit::PeakAnnotation> PeakAnnotations;
53  typedef std::map<boost::optional<ProcessingStepRef>,
55 
56  typedef boost::variant<IdentifiedPeptideRef, IdentifiedCompoundRef,
58 
62  {
64 
66 
68 
69  // peak annotations (fragment ion matches), potentially from different
70  // data processing steps:
72 
75  DataQueryRef data_query_ref, Int m_charge = 0,
78  )
83  {
84  }
85 
86  MoleculeQueryMatch(const MoleculeQueryMatch&) = default;
87 
89  {
90  if (boost::get<IdentifiedPeptideRef>(&identified_molecule_ref))
91  {
92  return MoleculeType::PROTEIN;
93  }
94  if (boost::get<IdentifiedCompoundRef>(&identified_molecule_ref))
95  {
97  }
98  if (boost::get<IdentifiedOligoRef>(&identified_molecule_ref))
99  {
100  return MoleculeType::RNA;
101  }
102  return MoleculeType::SIZE_OF_MOLECULETYPE; // this shouldn't happen
103  }
104 
106  {
107  if (const IdentifiedPeptideRef* ref_ptr =
108  boost::get<IdentifiedPeptideRef>(&identified_molecule_ref))
109  {
110  return *ref_ptr;
111  }
112  String msg = "matched molecule is not a peptide";
113  throw Exception::IllegalArgument(__FILE__, __LINE__,
114  OPENMS_PRETTY_FUNCTION, msg);
115  }
116 
118  {
119  if (const IdentifiedCompoundRef* ref_ptr =
120  boost::get<IdentifiedCompoundRef>(&identified_molecule_ref))
121  {
122  return *ref_ptr;
123  }
124  String msg = "matched molecule is not a compound";
125  throw Exception::IllegalArgument(__FILE__, __LINE__,
126  OPENMS_PRETTY_FUNCTION, msg);
127  }
128 
130  {
131  if (const IdentifiedOligoRef* ref_ptr =
132  boost::get<IdentifiedOligoRef>(&identified_molecule_ref))
133  {
134  return *ref_ptr;
135  }
136  String msg = "matched molecule is not an oligonucleotide";
137  throw Exception::IllegalArgument(__FILE__, __LINE__,
138  OPENMS_PRETTY_FUNCTION, msg);
139  }
140 
142  {
144  if (charge == 0) charge = other.charge;
145  peak_annotations.insert(other.peak_annotations.begin(),
146  other.peak_annotations.end());
147  return *this;
148  }
149  };
150 
151  // all matches for the same data query should be consecutive!
152  typedef boost::multi_index_container<
153  MoleculeQueryMatch,
154  boost::multi_index::indexed_by<
155  boost::multi_index::ordered_unique<
156  boost::multi_index::composite_key<
157  MoleculeQueryMatch,
158  boost::multi_index::member<MoleculeQueryMatch, DataQueryRef,
160  boost::multi_index::member<
161  MoleculeQueryMatch, IdentifiedMoleculeRef,
165 
166  }
167 }
OpenMS::IdentificationDataInternal::PeakAnnotationSteps
std::map< boost::optional< ProcessingStepRef >, PeakAnnotations > PeakAnnotationSteps
Definition: MoleculeQueryMatch.h:54
OpenMS::IdentificationDataInternal::MoleculeType
MoleculeType
Definition: MetaData.h:63
OpenMS::Exception::IllegalArgument
A method or algorithm argument contains illegal values.
Definition: Exception.h:648
OpenMS::IdentificationDataInternal::MoleculeQueryMatch::getMoleculeType
MoleculeType getMoleculeType() const
Definition: MoleculeQueryMatch.h:88
OpenMS::IdentificationDataInternal::MoleculeQueryMatch::peak_annotations
PeakAnnotationSteps peak_annotations
Definition: MoleculeQueryMatch.h:71
OpenMS::IdentificationDataInternal::MoleculeQueryMatch::operator+=
MoleculeQueryMatch & operator+=(const MoleculeQueryMatch &other)
Definition: MoleculeQueryMatch.h:141
MetaData.h
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::IdentificationDataInternal::PROTEIN
Definition: MetaData.h:65
OpenMS::IdentificationDataInternal::ScoredProcessingResult::steps_and_scores
AppliedProcessingSteps steps_and_scores
Definition: ScoredProcessingResult.h:46
OpenMS::IdentificationDataInternal::QueryMatchRef
IteratorWrapper< MoleculeQueryMatches::iterator > QueryMatchRef
Definition: MoleculeQueryMatch.h:164
IdentifiedSequence.h
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::IdentificationDataInternal::PeakAnnotations
std::vector< PeptideHit::PeakAnnotation > PeakAnnotations
Definition: MoleculeQueryMatch.h:52
PeptideHit.h
int
OpenMS::IdentificationDataInternal::IteratorWrapper
Wrapper that adds operator< to iterators, so they can be used as (part of) keys in maps/sets or multi...
Definition: MetaData.h:43
OpenMS::IdentificationDataInternal::MoleculeQueryMatch
Meta data for a search hit (e.g. peptide-spectrum match).
Definition: MoleculeQueryMatch.h:61
OpenMS::IdentificationDataInternal::IdentifiedMoleculeRef
boost::variant< IdentifiedPeptideRef, IdentifiedCompoundRef, IdentifiedOligoRef > IdentifiedMoleculeRef
Definition: MoleculeQueryMatch.h:57
OpenMS::IdentificationDataInternal::MoleculeQueryMatches
boost::multi_index_container< MoleculeQueryMatch, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::composite_key< MoleculeQueryMatch, boost::multi_index::member< MoleculeQueryMatch, DataQueryRef, &MoleculeQueryMatch::data_query_ref >, boost::multi_index::member< MoleculeQueryMatch, IdentifiedMoleculeRef, &MoleculeQueryMatch::identified_molecule_ref > > > > > MoleculeQueryMatches
Definition: MoleculeQueryMatch.h:163
OpenMS::IdentificationDataInternal::SIZE_OF_MOLECULETYPE
Definition: MetaData.h:68
OpenMS::IdentificationDataInternal::COMPOUND
Definition: MetaData.h:66
OpenMS::IdentificationDataInternal::RNA
Definition: MetaData.h:67
OpenMS::IdentificationDataInternal::MoleculeQueryMatch::getIdentifiedCompoundRef
IdentifiedCompoundRef getIdentifiedCompoundRef() const
Definition: MoleculeQueryMatch.h:117
OpenMS::IdentificationDataInternal::AppliedProcessingSteps
boost::multi_index_container< AppliedProcessingStep, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::ordered_unique< boost::multi_index::member< AppliedProcessingStep, boost::optional< ProcessingStepRef >, &AppliedProcessingStep::processing_step_opt > > > > AppliedProcessingSteps
Definition: AppliedProcessingStep.h:116
OpenMS::IdentificationDataInternal::ScoredProcessingResult
Base class for ID data with scores and processing steps (and meta info)
Definition: ScoredProcessingResult.h:44
IdentifiedCompound.h
OpenMS::IdentificationDataInternal::MoleculeQueryMatch::identified_molecule_ref
IdentifiedMoleculeRef identified_molecule_ref
Definition: MoleculeQueryMatch.h:63
OpenMS::IdentificationDataInternal::MoleculeQueryMatch::MoleculeQueryMatch
MoleculeQueryMatch(IdentifiedMoleculeRef identified_molecule_ref, DataQueryRef data_query_ref, Int m_charge=0, const AppliedProcessingSteps &steps_and_scores=AppliedProcessingSteps(), const PeakAnnotationSteps &peak_annotations=PeakAnnotationSteps())
Definition: MoleculeQueryMatch.h:73
OpenMS::IdentificationDataInternal::MoleculeQueryMatch::data_query_ref
DataQueryRef data_query_ref
Definition: MoleculeQueryMatch.h:65
OpenMS::IdentificationDataInternal::MoleculeQueryMatch::getIdentifiedOligoRef
IdentifiedOligoRef getIdentifiedOligoRef() const
Definition: MoleculeQueryMatch.h:129
OpenMS::IdentificationDataInternal::DataQueryRef
IteratorWrapper< DataQueries::iterator > DataQueryRef
Definition: DataQuery.h:90
OpenMS::IdentificationDataInternal::MoleculeQueryMatch::getIdentifiedPeptideRef
IdentifiedPeptideRef getIdentifiedPeptideRef() const
Definition: MoleculeQueryMatch.h:105
OpenMS::IdentificationDataInternal::MoleculeQueryMatch::charge
Int charge
Definition: MoleculeQueryMatch.h:67
OpenMS::IdentificationDataInternal::ScoredProcessingResult::operator+=
ScoredProcessingResult & operator+=(const ScoredProcessingResult &other)
Merge in data from another object.
Definition: ScoredProcessingResult.h:107
OpenMS::IdentificationDataInternal::IdentifiedPeptideRef
IteratorWrapper< IdentifiedPeptides::iterator > IdentifiedPeptideRef
Definition: IdentifiedSequence.h:116
OpenMS::IdentificationDataInternal::IdentifiedCompoundRef
IteratorWrapper< IdentifiedCompounds::iterator > IdentifiedCompoundRef
Definition: IdentifiedCompound.h:80