OpenMS  3.0.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-2022.
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>
40 
45 
46 #include <OpenMS/CONCEPT/Types.h>
50 
52 #include <OpenMS/OpenMSConfig.h>
53 
54 #include <exception>
55 #include <vector>
56 
57 namespace OpenMS
58 {
59  class ProteinIdentification;
60  class PeptideIdentification;
61  class DataProcessing;
62 
65  struct OPENMS_DLLAPI AnnotationStatistics
66  {
67  std::vector<Size> states;
68 
70 
72 
73  AnnotationStatistics& operator=(const AnnotationStatistics& rhs);
74 
75  bool operator==(const AnnotationStatistics& rhs) const;
76 
78  };
79 
80 
82  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const AnnotationStatistics& ann);
83 
98  class FeatureMap :
99  private std::vector<Feature>,
100  public MetaInfoInterface,
101  public RangeManagerContainer<RangeRT, RangeMZ, RangeIntensity>,
102  public DocumentIdentifier,
103  public UniqueIdInterface,
104  public UniqueIdIndexer<FeatureMap>,
105  public MapUtilities<FeatureMap>
106  {
107 public:
111  typedef std::vector<Feature> Base;
112 
113  // types
114  using Base::value_type;
115  using Base::iterator;
116  using Base::const_iterator;
117  using Base::size_type;
118  using Base::pointer; // ConstRefVector
119  using Base::reference; // ConstRefVector
120  using Base::const_reference; // ConstRefVector
121  using Base::difference_type; // ConstRefVector
122 
123  // functions
124  using Base::begin;
125  using Base::end;
126  using Base::cbegin;
127  using Base::cend;
128  using Base::size;
129  using Base::resize; // ConsensusMap, FeatureXMLFile
130  using Base::empty;
131  using Base::reserve;
132  using Base::operator[];
133  using Base::at; // UniqueIdIndexer
134  using Base::back; // FeatureXMLFile
135 
136  using Base::push_back;
137  using Base::emplace_back;
138  using Base::pop_back; // FeatureXMLFile
139  using Base::erase; // source/VISUAL/Plot2DCanvas.cpp 2871, FeatureMap_test 599
140 
144  typedef Base::iterator Iterator;
145  typedef Base::const_iterator ConstIterator;
146  typedef Base::reverse_iterator ReverseIterator;
147  typedef Base::const_reverse_iterator ConstReverseIterator;
149 
154 
156  OPENMS_DLLAPI FeatureMap();
157 
159  OPENMS_DLLAPI FeatureMap(const FeatureMap& source);
160 
162  OPENMS_DLLAPI FeatureMap(FeatureMap&& source);
163 
165  OPENMS_DLLAPI ~FeatureMap() override;
167 
169  OPENMS_DLLAPI FeatureMap& operator=(const FeatureMap& rhs);
170 
172  OPENMS_DLLAPI bool operator==(const FeatureMap& rhs) const;
173 
175  OPENMS_DLLAPI bool operator!=(const FeatureMap& rhs) const;
176 
182  OPENMS_DLLAPI FeatureMap operator+(const FeatureMap& rhs) const;
183 
196  OPENMS_DLLAPI FeatureMap& operator+=(const FeatureMap& rhs);
197 
204  OPENMS_DLLAPI void sortByIntensity(bool reverse = false);
206 
208  OPENMS_DLLAPI void sortByPosition();
209 
211  OPENMS_DLLAPI void sortByRT();
212 
214  OPENMS_DLLAPI void sortByMZ();
215 
217  OPENMS_DLLAPI void sortByOverallQuality(bool reverse = false);
218 
220 
221  // Docu in base class
222  OPENMS_DLLAPI void updateRanges() override;
223 
225  OPENMS_DLLAPI void swapFeaturesOnly(FeatureMap& from);
226 
227  OPENMS_DLLAPI void swap(FeatureMap& from);
228 
232  OPENMS_DLLAPI const std::vector<ProteinIdentification>& getProteinIdentifications() const;
233 
235  OPENMS_DLLAPI std::vector<ProteinIdentification>& getProteinIdentifications();
236 
238  OPENMS_DLLAPI void setProteinIdentifications(const std::vector<ProteinIdentification>& protein_identifications);
239 
241  OPENMS_DLLAPI const std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications() const;
242 
244  OPENMS_DLLAPI std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications();
245 
247  OPENMS_DLLAPI void setUnassignedPeptideIdentifications(const std::vector<PeptideIdentification>& unassigned_peptide_identifications);
249 
251  OPENMS_DLLAPI const std::vector<DataProcessing>& getDataProcessing() const;
252 
254  OPENMS_DLLAPI std::vector<DataProcessing>& getDataProcessing();
255 
257  OPENMS_DLLAPI void setDataProcessing(const std::vector<DataProcessing>& processing_method);
258 
260  OPENMS_DLLAPI void setPrimaryMSRunPath(const StringList& s);
261 
264  OPENMS_DLLAPI void setPrimaryMSRunPath(const StringList& s, MSExperiment & e);
265 
267  OPENMS_DLLAPI void getPrimaryMSRunPath(StringList& toFill) const;
268 
274  OPENMS_DLLAPI void clear(bool clear_meta_data = true);
275 
288  template <typename Type>
289  Size applyMemberFunction(Size (Type::* member_function)())
290  {
291  Size assignments = 0;
292  assignments += ((*this).*member_function)();
293  for (Iterator iter = this->begin(); iter != this->end(); ++iter)
294  {
295  assignments += iter->applyMemberFunction(member_function);
296  }
297  return assignments;
298  }
299 
301  template <typename Type>
302  Size applyMemberFunction(Size (Type::* member_function)() const) const
303  {
304  Size assignments = 0;
305  assignments += ((*this).*member_function)();
306  for (ConstIterator iter = this->begin(); iter != this->end(); ++iter)
307  {
308  assignments += iter->applyMemberFunction(member_function);
309  }
310  return assignments;
311  }
312 
313  OPENMS_DLLAPI AnnotationStatistics getAnnotationStatistics() const;
314 
317 
324  OPENMS_DLLAPI std::set<IdentificationData::ObservationMatchRef> getUnassignedIDMatches() const;
325 
327  OPENMS_DLLAPI const IdentificationData& getIdentificationData() const;
328 
330  OPENMS_DLLAPI IdentificationData& getIdentificationData();
332 
333 protected:
335  std::vector<ProteinIdentification> protein_identifications_;
336 
338  std::vector<PeptideIdentification> unassigned_peptide_identifications_;
339 
341  std::vector<DataProcessing> data_processing_;
342 
345  };
346 
347  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const FeatureMap& map);
348 
349 } // namespace OpenMS
Base::const_iterator ConstIterator
Definition: FeatureMap.h:145
void sortByMZ()
Sort features by m/z position.
void sortByRT()
Sort features by RT position.
~FeatureMap() override
Destructor.
std::vector< Size > states
count each state, indexing by BaseFeature::AnnotationState
Definition: FeatureMap.h:67
FeatureMap()
Default constructor.
void getPrimaryMSRunPath(StringList &toFill) const
get the file path to the first MS run
Size applyMemberFunction(Size(Type::*member_function)() const) const
The "const" variant.
Definition: FeatureMap.h:302
FeatureMap & operator+=(const FeatureMap &rhs)
Add one feature map to another.
void swap(FeatureMap &from)
A container for features.
Definition: FeatureMap.h:98
void setPrimaryMSRunPath(const StringList &s)
set the file path to the primary MS run (usually the mzML file obtained after data conversion from ra...
std::vector< Feature > Base
Definition: FeatureMap.h:111
Base::reverse_iterator ReverseIterator
Definition: FeatureMap.h:146
Definition: IdentificationData.h:112
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
Size applyMemberFunction(Size(Type::*member_function)())
Applies a member function of Type to the container itself and all features (including subordinates)...
Definition: FeatureMap.h:289
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
const std::vector< PeptideIdentification > & getUnassignedPeptideIdentifications() const
non-mutable access to the unassigned peptide identifications
Base::const_reverse_iterator ConstReverseIterator
Definition: FeatureMap.h:147
void setDataProcessing(const std::vector< DataProcessing > &processing_method)
sets the description of the applied data processing
Utilities for Feature and ConsensusMap.
Definition: MapUtilities.h:49
const IdentificationData & getIdentificationData() const
Immutable access to the contained identification data.
void setProteinIdentifications(const std::vector< ProteinIdentification > &protein_identifications)
sets the protein identifications
bool operator!=(const FeatureMap &rhs) const
Equality operator.
FeatureMap & operator=(const FeatureMap &rhs)
Assignment operator.
bool operator==(const FeatureMap &rhs) const
Equality operator.
std::vector< ProteinIdentification > protein_identifications_
protein identifications
Definition: FeatureMap.h:335
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
void sortByPosition()
Sort features by position. Lexicographical comparison (first RT then m/z) is done.
A base class for random access containers for classes derived from UniqueIdInterface that adds functi...
Definition: UniqueIdIndexer.h:63
Base::iterator Iterator
Definition: FeatureMap.h:144
static String & reverse(String &this_s)
Definition: StringUtilsSimple.h:355
IdentificationData id_data_
general identification results (peptides/proteins, RNA, compounds)
Definition: FeatureMap.h:344
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:60
std::vector< PeptideIdentification > unassigned_peptide_identifications_
peptide identifications not matched to a specific feature
Definition: FeatureMap.h:338
A base class defining a common interface for all classes having a unique id.
Definition: UniqueIdInterface.h:50
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:70
void swapFeaturesOnly(FeatureMap &from)
Swaps the feature content (plus its range information) of this map with the content of from...
std::vector< DataProcessing > data_processing_
applied data processing
Definition: FeatureMap.h:341
void updateRanges() override
const std::vector< DataProcessing > & getDataProcessing() const
returns a const reference to the description of the applied data processing
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
AnnotationState
state of identification, use getAnnotationState() to query it
Definition: BaseFeature.h:71
void sortByOverallQuality(bool reverse=false)
Sort features by ascending overall quality.
RangeManager< RangeRT, RangeMZ, RangeIntensity > RangeManagerType
Definition: FeatureMap.h:143
Definition: FeatureMap.h:65
RangeManagerContainer< RangeRT, RangeMZ, RangeIntensity > RangeManagerContainerType
Definition: FeatureMap.h:142
Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra...
Definition: RangeManager.h:565
Definition: RangeManager.h:896
const std::vector< ProteinIdentification > & getProteinIdentifications() const
void sortByIntensity(bool reverse=false)
Sorts the peaks according to ascending intensity.
AnnotationStatistics getAnnotationStatistics() const
void clear(bool clear_meta_data=true)
Clears all data and meta data.
Manage source document information.
Definition: DocumentIdentifier.h:55
FeatureMap operator+(const FeatureMap &rhs) const
Joins two feature maps.
void setUnassignedPeptideIdentifications(const std::vector< PeptideIdentification > &unassigned_peptide_identifications)
sets the unassigned peptide identifications
std::set< IdentificationData::ObservationMatchRef > getUnassignedIDMatches() const
Return observation matches (e.g. PSMs) from the identification data that are not assigned to any feat...