OpenMS  2.8.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-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: 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 
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 
127  using Base::size;
128  using Base::resize; // ConsensusMap, FeatureXMLFile
129  using Base::empty;
130  using Base::reserve;
131  using Base::operator[];
132  using Base::at; // UniqueIdIndexer
133  using Base::back; // FeatureXMLFile
134 
135  using Base::push_back;
136  using Base::emplace_back;
137  using Base::pop_back; // FeatureXMLFile
138  using Base::erase; // source/VISUAL/Plot2DCanvas.cpp 2871, FeatureMap_test 599
139 
143  typedef Base::iterator Iterator;
144  typedef Base::const_iterator ConstIterator;
145  typedef Base::reverse_iterator ReverseIterator;
146  typedef Base::const_reverse_iterator ConstReverseIterator;
148 
153 
155  OPENMS_DLLAPI FeatureMap();
156 
158  OPENMS_DLLAPI FeatureMap(const FeatureMap& source);
159 
161  OPENMS_DLLAPI FeatureMap(FeatureMap&& source);
162 
164  OPENMS_DLLAPI ~FeatureMap() override;
166 
168  OPENMS_DLLAPI FeatureMap& operator=(const FeatureMap& rhs);
169 
171  OPENMS_DLLAPI bool operator==(const FeatureMap& rhs) const;
172 
174  OPENMS_DLLAPI bool operator!=(const FeatureMap& rhs) const;
175 
181  OPENMS_DLLAPI FeatureMap operator+(const FeatureMap& rhs) const;
182 
195  OPENMS_DLLAPI FeatureMap& operator+=(const FeatureMap& rhs);
196 
204  OPENMS_DLLAPI void sortByIntensity(bool reverse = false);
205 
207  OPENMS_DLLAPI void sortByPosition();
208 
210  OPENMS_DLLAPI void sortByRT();
211 
213  OPENMS_DLLAPI void sortByMZ();
214 
216  OPENMS_DLLAPI void sortByOverallQuality(bool reverse = false);
217 
219 
220  // Docu in base class
221  OPENMS_DLLAPI void updateRanges() override;
222 
224  OPENMS_DLLAPI void swapFeaturesOnly(FeatureMap& from);
225 
226  OPENMS_DLLAPI void swap(FeatureMap& from);
227 
231  OPENMS_DLLAPI const std::vector<ProteinIdentification>& getProteinIdentifications() const;
232 
234  OPENMS_DLLAPI std::vector<ProteinIdentification>& getProteinIdentifications();
235 
237  OPENMS_DLLAPI void setProteinIdentifications(const std::vector<ProteinIdentification>& protein_identifications);
238 
240  OPENMS_DLLAPI const std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications() const;
241 
243  OPENMS_DLLAPI std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications();
244 
246  OPENMS_DLLAPI void setUnassignedPeptideIdentifications(const std::vector<PeptideIdentification>& unassigned_peptide_identifications);
248 
250  OPENMS_DLLAPI const std::vector<DataProcessing>& getDataProcessing() const;
251 
253  OPENMS_DLLAPI std::vector<DataProcessing>& getDataProcessing();
254 
256  OPENMS_DLLAPI void setDataProcessing(const std::vector<DataProcessing>& processing_method);
257 
259  OPENMS_DLLAPI void setPrimaryMSRunPath(const StringList& s);
260 
263  OPENMS_DLLAPI void setPrimaryMSRunPath(const StringList& s, MSExperiment & e);
264 
266  OPENMS_DLLAPI void getPrimaryMSRunPath(StringList& toFill) const;
267 
273  OPENMS_DLLAPI void clear(bool clear_meta_data = true);
274 
287  template <typename Type>
288  Size applyMemberFunction(Size (Type::* member_function)())
289  {
290  Size assignments = 0;
291  assignments += ((*this).*member_function)();
292  for (Iterator iter = this->begin(); iter != this->end(); ++iter)
293  {
294  assignments += iter->applyMemberFunction(member_function);
295  }
296  return assignments;
297  }
298 
300  template <typename Type>
301  Size applyMemberFunction(Size (Type::* member_function)() const) const
302  {
303  Size assignments = 0;
304  assignments += ((*this).*member_function)();
305  for (ConstIterator iter = this->begin(); iter != this->end(); ++iter)
306  {
307  assignments += iter->applyMemberFunction(member_function);
308  }
309  return assignments;
310  }
311 
313 
316 
323  OPENMS_DLLAPI std::set<IdentificationData::ObservationMatchRef> getUnassignedIDMatches() const;
324 
326  OPENMS_DLLAPI const IdentificationData& getIdentificationData() const;
327 
331 
332 protected:
334  std::vector<ProteinIdentification> protein_identifications_;
335 
337  std::vector<PeptideIdentification> unassigned_peptide_identifications_;
338 
340  std::vector<DataProcessing> data_processing_;
341 
344  };
345 
346  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const FeatureMap& map);
347 
348 } // namespace OpenMS
AnnotationState
state of identification, use getAnnotationState() to query it
Definition: BaseFeature.h:72
Manage source document information.
Definition: DocumentIdentifier.h:56
A container for features.
Definition: FeatureMap.h:106
void sortByOverallQuality(bool reverse=false)
Sort features by ascending overall quality.
void sortByRT()
Sort features by RT position.
FeatureMap & operator=(const FeatureMap &rhs)
Assignment operator.
const std::vector< DataProcessing > & getDataProcessing() const
returns a const reference to the description of the applied data processing
~FeatureMap() override
Destructor.
std::vector< PeptideIdentification > & getUnassignedPeptideIdentifications()
mutable access to the unassigned peptide identifications
RangeManager< RangeRT, RangeMZ, RangeIntensity > RangeManagerType
Definition: FeatureMap.h:142
Size applyMemberFunction(Size(Type::*member_function)())
Applies a member function of Type to the container itself and all features (including subordinates)....
Definition: FeatureMap.h:288
FeatureMap operator+(const FeatureMap &rhs) const
Joins two feature maps.
void swapFeaturesOnly(FeatureMap &from)
Swaps the feature content (plus its range information) of this map with the content of from.
void setUnassignedPeptideIdentifications(const std::vector< PeptideIdentification > &unassigned_peptide_identifications)
sets the unassigned peptide identifications
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< DataProcessing > data_processing_
applied data processing
Definition: FeatureMap.h:340
IdentificationData & getIdentificationData()
Mutable access to the contained identification data.
FeatureMap(FeatureMap &&source)
Move constructor.
void sortByMZ()
Sort features by m/z position.
std::vector< ProteinIdentification > & getProteinIdentifications()
mutable access to the protein identifications
bool operator!=(const FeatureMap &rhs) const
Equality operator.
void setProteinIdentifications(const std::vector< ProteinIdentification > &protein_identifications)
sets the protein identifications
FeatureMap & operator+=(const FeatureMap &rhs)
Add one feature map to another.
IdentificationData id_data_
general identification results (peptides/proteins, RNA, compounds)
Definition: FeatureMap.h:343
void swap(FeatureMap &from)
void clear(bool clear_meta_data=true)
Clears all data and meta data.
void sortByPosition()
Sort features by position. Lexicographical comparison (first RT then m/z) is done.
Base::const_reverse_iterator ConstReverseIterator
Definition: FeatureMap.h:146
void setDataProcessing(const std::vector< DataProcessing > &processing_method)
sets the description of the applied data processing
std::vector< Feature > Base
Definition: FeatureMap.h:111
FeatureMap()
Default constructor.
void sortByIntensity(bool reverse=false)
Sorts the peaks according to ascending intensity.
RangeManagerContainer< RangeRT, RangeMZ, RangeIntensity > RangeManagerContainerType
Definition: FeatureMap.h:141
std::vector< DataProcessing > & getDataProcessing()
returns a mutable reference to the description of the applied data processing
void getPrimaryMSRunPath(StringList &toFill) const
get the file path to the first MS run
FeatureMap(const FeatureMap &source)
Copy constructor.
AnnotationStatistics getAnnotationStatistics() const
std::vector< PeptideIdentification > unassigned_peptide_identifications_
peptide identifications not matched to a specific feature
Definition: FeatureMap.h:337
Base::const_iterator ConstIterator
Definition: FeatureMap.h:144
const std::vector< ProteinIdentification > & getProteinIdentifications() const
const std::vector< PeptideIdentification > & getUnassignedPeptideIdentifications() const
non-mutable access to the unassigned peptide identifications
Base::reverse_iterator ReverseIterator
Definition: FeatureMap.h:145
const IdentificationData & getIdentificationData() const
Immutable access to the contained identification data.
Base::iterator Iterator
Definition: FeatureMap.h:143
std::vector< ProteinIdentification > protein_identifications_
protein identifications
Definition: FeatureMap.h:334
std::set< IdentificationData::ObservationMatchRef > getUnassignedIDMatches() const
Return observation matches (e.g. PSMs) from the identification data that are not assigned to any feat...
void updateRanges() override
bool operator==(const FeatureMap &rhs) const
Equality operator.
void setPrimaryMSRunPath(const StringList &s, MSExperiment &e)
Size applyMemberFunction(Size(Type::*member_function)() const) const
The "const" variant.
Definition: FeatureMap.h:301
Representation of spectrum identification results and associated data.
Definition: IdentificationData.h:95
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:73
Utilities for Feature and ConsensusMap.
Definition: MapUtilities.h:50
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:61
Definition: RangeManager.h:652
Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra.
Definition: RangeManager.h:455
A base class for random access containers for classes derived from UniqueIdInterface that adds functi...
Definition: UniqueIdIndexer.h:64
A base class defining a common interface for all classes having a unique id.
Definition: UniqueIdInterface.h:52
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
static String & reverse(String &this_s)
Definition: StringUtilsSimple.h:350
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Definition: FeatureMap.h:66
AnnotationStatistics(const AnnotationStatistics &rhs)
std::vector< Size > states
count each state, indexing by BaseFeature::AnnotationState
Definition: FeatureMap.h:67
AnnotationStatistics & operator+=(BaseFeature::AnnotationState state)
AnnotationStatistics & operator=(const AnnotationStatistics &rhs)
bool operator==(const AnnotationStatistics &rhs) const