| OpenMS 2.5.0

FeatureMap.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: Chris Bielow $
32 // $Authors: Marc Sturm, Chris Bielow, Clemens Groepl $
33 // --------------------------------------------------------------------------
34
35 #pragma once
36
37 #include <OpenMS/KERNEL/Feature.h>
38 #include <OpenMS/KERNEL/RangeManager.h>
39 #include <OpenMS/KERNEL/MSExperiment.h>
40
41 #include <OpenMS/METADATA/DocumentIdentifier.h>
42 #include <OpenMS/METADATA/MetaInfoInterface.h>
43
44 #include <OpenMS/CONCEPT/Types.h>
45 #include <OpenMS/CONCEPT/UniqueIdInterface.h>
46 #include <OpenMS/CONCEPT/UniqueIdIndexer.h>
47 #include <OpenMS/KERNEL/BaseFeature.h>
48 #include <OpenMS/OpenMSConfig.h>
49
50 #include <algorithm>
51 #include <exception>
52 #include <vector>
53
54 namespace OpenMS
55 {
56 class ProteinIdentification;
57 class PeptideIdentification;
58 class DataProcessing;
59
62 struct OPENMS_DLLAPI AnnotationStatistics
63 {
64 std::vector<Size> states;
65
66 AnnotationStatistics();
67
68 AnnotationStatistics(const AnnotationStatistics& rhs);
69
70 AnnotationStatistics& operator=(const AnnotationStatistics& rhs);
71
72 bool operator==(const AnnotationStatistics& rhs) const;
73
74 AnnotationStatistics& operator+=(BaseFeature::AnnotationState state);
75 };
76
77
79 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const AnnotationStatistics& ann);
80
95 class FeatureMap :
96 private std::vector<Feature>,
97 public MetaInfoInterface,
98 public RangeManager<2>,
99 public DocumentIdentifier,
100 public UniqueIdInterface,
101 public UniqueIdIndexer<FeatureMap>
102 {
103 public:
107 typedef std::vector<Feature> privvec;
108
109 // types
110 using privvec::value_type;
111 using privvec::iterator;
112 using privvec::const_iterator;
113 using privvec::size_type;
114 using privvec::pointer; // ConstRefVector
115 using privvec::reference; // ConstRefVector
116 using privvec::const_reference; // ConstRefVector
117 using privvec::difference_type; // ConstRefVector
118
119 // functions
120 using privvec::begin;
121 using privvec::end;
122
123 using privvec::size;
124 using privvec::resize; // ConsensusMap, FeatureXMLFile
125 using privvec::empty;
126 using privvec::reserve;
127 using privvec::operator[];
128 using privvec::at; // UniqueIdIndexer
129 using privvec::back; // FeatureXMLFile
130
131 using privvec::push_back;
132 using privvec::pop_back; // FeatureXMLFile
133 using privvec::erase; // source/VISUAL/Spectrum2DCanvas.cpp 2871, FeatureMap_test 599
134
136 typedef Feature FeatureType;
137 typedef RangeManager<2> RangeManagerType;
138 typedef std::vector<FeatureType> Base;
139 typedef Base::iterator Iterator;
140 typedef Base::const_iterator ConstIterator;
141 typedef Base::reverse_iterator ReverseIterator;
142 typedef Base::const_reverse_iterator ConstReverseIterator;
143 typedef FeatureType& Reference;
144 typedef const FeatureType& ConstReference;
146
151
153 OPENMS_DLLAPI FeatureMap();
154
156 OPENMS_DLLAPI FeatureMap(const FeatureMap& source);
157
159 OPENMS_DLLAPI ~FeatureMap() override;
161
163 OPENMS_DLLAPI FeatureMap& operator=(const FeatureMap& rhs);
164
166 OPENMS_DLLAPI bool operator==(const FeatureMap& rhs) const;
167
169 OPENMS_DLLAPI bool operator!=(const FeatureMap& rhs) const;
170
176 OPENMS_DLLAPI FeatureMap operator+(const FeatureMap& rhs) const;
177
190 OPENMS_DLLAPI FeatureMap& operator+=(const FeatureMap& rhs);
191
198 OPENMS_DLLAPI void sortByIntensity(bool reverse = false);
200
202 OPENMS_DLLAPI void sortByPosition();
203
205 OPENMS_DLLAPI void sortByRT();
206
208 OPENMS_DLLAPI void sortByMZ();
209
211 OPENMS_DLLAPI void sortByOverallQuality(bool reverse = false);
212
214
215 // Docu in base class
216 OPENMS_DLLAPI void updateRanges() override;
217
219 OPENMS_DLLAPI void swapFeaturesOnly(FeatureMap& from);
220
221 OPENMS_DLLAPI void swap(FeatureMap& from);
222
224 OPENMS_DLLAPI const std::vector<ProteinIdentification>& getProteinIdentifications() const;
225
227 OPENMS_DLLAPI std::vector<ProteinIdentification>& getProteinIdentifications();
228
230 OPENMS_DLLAPI void setProteinIdentifications(const std::vector<ProteinIdentification>& protein_identifications);
231
233 OPENMS_DLLAPI const std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications() const;
234
236 OPENMS_DLLAPI std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications();
237
239 OPENMS_DLLAPI void setUnassignedPeptideIdentifications(const std::vector<PeptideIdentification>& unassigned_peptide_identifications);
240
242 OPENMS_DLLAPI const std::vector<DataProcessing>& getDataProcessing() const;
243
245 OPENMS_DLLAPI std::vector<DataProcessing>& getDataProcessing();
246
248 OPENMS_DLLAPI void setDataProcessing(const std::vector<DataProcessing>& processing_method);
249
251 OPENMS_DLLAPI void setPrimaryMSRunPath(const StringList& s);
252
255 OPENMS_DLLAPI void setPrimaryMSRunPath(const StringList& s, MSExperiment & e);
256
258 OPENMS_DLLAPI void getPrimaryMSRunPath(StringList& toFill) const;
259
265 OPENMS_DLLAPI void clear(bool clear_meta_data = true);
266
279 template <typename Type>
280 Size applyMemberFunction(Size (Type::* member_function)())
281 {
282 Size assignments = 0;
283 assignments += ((*this).*member_function)();
284 for (Iterator iter = this->begin(); iter != this->end(); ++iter)
285 {
286 assignments += iter->applyMemberFunction(member_function);
287 }
288 return assignments;
289 }
290
292 template <typename Type>
293 Size applyMemberFunction(Size (Type::* member_function)() const) const
294 {
295 Size assignments = 0;
296 assignments += ((*this).*member_function)();
297 for (ConstIterator iter = this->begin(); iter != this->end(); ++iter)
298 {
299 assignments += iter->applyMemberFunction(member_function);
300 }
301 return assignments;
302 }
303
304 OPENMS_DLLAPI AnnotationStatistics getAnnotationStatistics() const;
305
306 protected:
307
309 std::vector<ProteinIdentification> protein_identifications_;
310
312 std::vector<PeptideIdentification> unassigned_peptide_identifications_;
313
315 std::vector<DataProcessing> data_processing_;
316 };
317
318 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const FeatureMap& map);
319
320 } // namespace OpenMS
321
OpenMS::Feature
An LC-MS feature.
Definition: Feature.h:70
OpenMS::AnnotationStatistics
Definition: FeatureMap.h:62
OpenMS::FeatureMap::applyMemberFunction
Size applyMemberFunction(Size(Type::*member_function)() const) const
The "const" variant.
Definition: FeatureMap.h:293
OpenMS::FeatureMap::clear
void clear(bool clear_meta_data=true)
Clears all data and meta data.
DocumentIdentifier.h
OpenMS::FeatureMap::sortByRT
void sortByRT()
Sort features by RT position.
OpenMS::FeatureMap::Base
std::vector< FeatureType > Base
Definition: FeatureMap.h:138
OpenMS::RangeManager
Handles the management of a position and intensity range.
Definition: RangeManager.h:47
Feature.h
OpenMS::FeatureMap::setDataProcessing
void setDataProcessing(const std::vector< DataProcessing > &processing_method)
sets the description of the applied data processing
UniqueIdIndexer.h
OpenMS::FeatureMap::sortByMZ
void sortByMZ()
Sort features by m/z position.
OpenMS::FeatureMap::FeatureMap
FeatureMap()
Default constructor.
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
UniqueIdInterface.h
OpenMS::FeatureMap::ConstReference
const FeatureType & ConstReference
Definition: FeatureMap.h:144
OpenMS::FeatureMap::data_processing_
std::vector< DataProcessing > data_processing_
applied data processing
Definition: FeatureMap.h:315
OpenMS::FeatureMap::applyMemberFunction
Size applyMemberFunction(Size(Type::*member_function)())
Applies a member function of Type to the container itself and all features (including subordinates)...
Definition: FeatureMap.h:280
OpenMS::FeatureMap::Iterator
Base::iterator Iterator
Definition: FeatureMap.h:139
OpenMS::FeatureMap
A container for features.
Definition: FeatureMap.h:95
OpenMS::FeatureMap::getDataProcessing
const std::vector< DataProcessing > & getDataProcessing() const
returns a const reference to the description of the applied data processing
OpenMS::FeatureMap::updateRanges
void updateRanges() override
Updates minimum and maximum position/intensity.
Types.h
OpenMS::FeatureMap::operator+
FeatureMap operator+(const FeatureMap &rhs) const
Joins two feature maps.
OpenMS::FeatureMap::~FeatureMap
~FeatureMap() override
Destructor.
OpenMS::DocumentIdentifier
Manage source document information.
Definition: DocumentIdentifier.h:55
OpenMS::FeatureMap::Reference
FeatureType & Reference
Definition: FeatureMap.h:143
OpenMS::FeatureMap::unassigned_peptide_identifications_
std::vector< PeptideIdentification > unassigned_peptide_identifications_
peptide identifications not matched to a specific feature
Definition: FeatureMap.h:312
OpenMS::FeatureMap::ConstIterator
Base::const_iterator ConstIterator
Definition: FeatureMap.h:140
OpenMS::FeatureMap::getAnnotationStatistics
AnnotationStatistics getAnnotationStatistics() const
OpenMS::FeatureMap::setUnassignedPeptideIdentifications
void setUnassignedPeptideIdentifications(const std::vector< PeptideIdentification > &unassigned_peptide_identifications)
sets the unassigned peptide identifications
OpenMS::UniqueIdInterface
A base class defining a common interface for all classes having a unique id.
Definition: UniqueIdInterface.h:51
OpenMS::FeatureMap::setProteinIdentifications
void setProteinIdentifications(const std::vector< ProteinIdentification > &protein_identifications)
sets the protein identifications
OpenMS::operator<<
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::FeatureMap::sortByIntensity
void sortByIntensity(bool reverse=false)
Sorts the peaks according to ascending intensity.
MSExperiment.h
OpenMS::FeatureMap::swap
void swap(FeatureMap &from)
OpenMS::FeatureMap::ReverseIterator
Base::reverse_iterator ReverseIterator
Definition: FeatureMap.h:141
OpenMS::FeatureMap::FeatureType
Feature FeatureType
Definition: FeatureMap.h:136
OpenMS::FeatureMap::operator==
bool operator==(const FeatureMap &rhs) const
Equality operator.
OpenMS::UniqueIdIndexer
A base class for random access containers for classes derived from UniqueIdInterface that adds functi...
Definition: UniqueIdIndexer.h:63
RangeManager.h
OpenMS::FeatureMap::operator!=
bool operator!=(const FeatureMap &rhs) const
Equality operator.
OpenMS::AnnotationStatistics::states
std::vector< Size > states
count each state, indexing by BaseFeature::AnnotationState
Definition: FeatureMap.h:64
OpenMS::StringList
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
OpenMS::FeatureMap::operator=
FeatureMap & operator=(const FeatureMap &rhs)
Assignment operator.
OpenMS::FeatureMap::sortByOverallQuality
void sortByOverallQuality(bool reverse=false)
Sort features by ascending overall quality.
OpenMS::FeatureMap::setPrimaryMSRunPath
void setPrimaryMSRunPath(const StringList &s)
set the file path to the primary MS run (usually the mzML file obtained after data conversion from ra...
OpenMS::FeatureMap::getUnassignedPeptideIdentifications
const std::vector< PeptideIdentification > & getUnassignedPeptideIdentifications() const
non-mutable access to the unassigned peptide identifications
MetaInfoInterface.h
BaseFeature.h
OpenMS::FeatureMap::RangeManagerType
RangeManager< 2 > RangeManagerType
Definition: FeatureMap.h:137
OpenMS::FeatureMap::getPrimaryMSRunPath
void getPrimaryMSRunPath(StringList &toFill) const
get the file path to the first MS run
OpenMS::FeatureMap::privvec
std::vector< Feature > privvec
Definition: FeatureMap.h:107
OpenMS::FeatureMap::operator+=
FeatureMap & operator+=(const FeatureMap &rhs)
Add one feature map to another.
OpenMS::BaseFeature::AnnotationState
AnnotationState
state of identification, use getIDState() to query it
Definition: BaseFeature.h:70
OpenMS::FeatureMap::sortByPosition
void sortByPosition()
Sort features by position. Lexicographical comparison (first RT then m/z) is done.
OpenMS::MetaInfoInterface
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:60
OpenMS::FeatureMap::ConstReverseIterator
Base::const_reverse_iterator ConstReverseIterator
Definition: FeatureMap.h:142
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::FeatureMap::protein_identifications_
std::vector< ProteinIdentification > protein_identifications_
protein identifications
Definition: FeatureMap.h:309
OpenMS::FeatureMap::getProteinIdentifications
const std::vector< ProteinIdentification > & getProteinIdentifications() const
non-mutable access to the protein identifications
KDTree::operator==
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806
OpenMS::FeatureMap::swapFeaturesOnly
void swapFeaturesOnly(FeatureMap &from)
Swaps the feature content (plus its range information) of this map with the content of from...