OpenMS  2.7.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-2021.
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 
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 }
A method or algorithm argument contains illegal values.
Definition: Exception.h:656
A more convenient string class.
Definition: String.h:61
int Int
Signed integer type.
Definition: Types.h:102
std::map< boost::optional< ProcessingStepRef >, PeakAnnotations > PeakAnnotationSteps
Definition: MoleculeQueryMatch.h:54
IteratorWrapper< IdentifiedCompounds::iterator > IdentifiedCompoundRef
Definition: IdentifiedCompound.h:80
boost::variant< IdentifiedPeptideRef, IdentifiedCompoundRef, IdentifiedOligoRef > IdentifiedMoleculeRef
Definition: MoleculeQueryMatch.h:57
IteratorWrapper< IdentifiedPeptides::iterator > IdentifiedPeptideRef
Definition: IdentifiedSequence.h:116
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
std::vector< PeptideHit::PeakAnnotation > PeakAnnotations
Definition: MoleculeQueryMatch.h:52
MoleculeType
Definition: MetaData.h:64
@ SIZE_OF_MOLECULETYPE
Definition: MetaData.h:68
@ COMPOUND
Definition: MetaData.h:66
@ PROTEIN
Definition: MetaData.h:65
@ RNA
Definition: MetaData.h:67
IteratorWrapper< MoleculeQueryMatches::iterator > QueryMatchRef
Definition: MoleculeQueryMatch.h:164
IteratorWrapper< DataQueries::iterator > DataQueryRef
Definition: DataQuery.h:90
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
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Wrapper that adds operator< to iterators, so they can be used as (part of) keys in maps/sets or multi...
Definition: MetaData.h:44
Meta data for a search hit (e.g. peptide-spectrum match).
Definition: MoleculeQueryMatch.h:62
IdentifiedOligoRef getIdentifiedOligoRef() const
Definition: MoleculeQueryMatch.h:129
IdentifiedPeptideRef getIdentifiedPeptideRef() const
Definition: MoleculeQueryMatch.h:105
MoleculeType getMoleculeType() const
Definition: MoleculeQueryMatch.h:88
DataQueryRef data_query_ref
Definition: MoleculeQueryMatch.h:65
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
IdentifiedMoleculeRef identified_molecule_ref
Definition: MoleculeQueryMatch.h:63
IdentifiedCompoundRef getIdentifiedCompoundRef() const
Definition: MoleculeQueryMatch.h:117
Int charge
Definition: MoleculeQueryMatch.h:67
MoleculeQueryMatch & operator+=(const MoleculeQueryMatch &other)
Definition: MoleculeQueryMatch.h:141
MoleculeQueryMatch(const MoleculeQueryMatch &)=default
PeakAnnotationSteps peak_annotations
Definition: MoleculeQueryMatch.h:71
Base class for ID data with scores and processing steps (and meta info)
Definition: ScoredProcessingResult.h:45
ScoredProcessingResult & operator+=(const ScoredProcessingResult &other)
Merge in data from another object.
Definition: ScoredProcessingResult.h:107
AppliedProcessingSteps steps_and_scores
Definition: ScoredProcessingResult.h:46