Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
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-2015.
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 #ifndef OPENMS_KERNEL_FEATUREMAP_H
36 #define OPENMS_KERNEL_FEATUREMAP_H
37 
38 #include <OpenMS/KERNEL/Feature.h>
41 
42 #include <OpenMS/CONCEPT/Types.h>
46 #include <OpenMS/OpenMSConfig.h>
47 
48 #include <algorithm>
49 #include <exception>
50 #include <vector>
51 
52 namespace OpenMS
53 {
54  class ProteinIdentification;
55  class PeptideIdentification;
56  class DataProcessing;
57 
60  struct OPENMS_DLLAPI AnnotationStatistics
61  {
62  std::vector<Size> states; //< count each state, indexing by BaseFeature::AnnotationState
63 
65 
67 
68  AnnotationStatistics& operator=(const AnnotationStatistics& rhs);
69 
70  bool operator==(const AnnotationStatistics& rhs) const;
71 
73  };
74 
75 
77  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const AnnotationStatistics& ann);
78 
93  class FeatureMap :
94  private std::vector<Feature>,
95  public RangeManager<2>,
96  public DocumentIdentifier,
97  public UniqueIdInterface,
98  public UniqueIdIndexer<FeatureMap>
99  {
100 public:
104  typedef std::vector<Feature> privvec;
105 
106  // types
107  using privvec::value_type;
108  using privvec::iterator;
109  using privvec::const_iterator;
110  using privvec::size_type;
111  using privvec::pointer; // ConstRefVector
112  using privvec::reference; // ConstRefVector
113  using privvec::const_reference; // ConstRefVector
114  using privvec::difference_type; // ConstRefVector
115 
116  // functions
117  using privvec::begin;
118  using privvec::end;
119 
120  using privvec::size;
121  using privvec::resize; // ConsensusMap, FeatureXMLFile
122  using privvec::empty;
123  using privvec::reserve;
124  using privvec::operator[];
125  using privvec::at; // UniqueIdIndexer
126  using privvec::back; // FeatureXMLFile
127 
128  using privvec::push_back;
129  using privvec::pop_back; // FeatureXMLFile
130  using privvec::erase; // source/VISUAL/Spectrum2DCanvas.cpp 2871, FeatureMap_test 599
131 
135  typedef std::vector<FeatureType> Base;
136  typedef Base::iterator Iterator;
137  typedef Base::const_iterator ConstIterator;
138  typedef Base::reverse_iterator ReverseIterator;
139  typedef Base::const_reverse_iterator ConstReverseIterator;
140  typedef FeatureType& Reference;
141  typedef const FeatureType& ConstReference;
143 
148 
150  OPENMS_DLLAPI FeatureMap();
151 
153  OPENMS_DLLAPI FeatureMap(const FeatureMap& source);
154 
156  OPENMS_DLLAPI virtual ~FeatureMap();
158 
160  OPENMS_DLLAPI FeatureMap& operator=(const FeatureMap& rhs);
161 
163  OPENMS_DLLAPI bool operator==(const FeatureMap& rhs) const;
164 
166  OPENMS_DLLAPI bool operator!=(const FeatureMap& rhs) const;
167 
173  OPENMS_DLLAPI FeatureMap operator+(const FeatureMap& rhs) const;
174 
187  OPENMS_DLLAPI FeatureMap& operator+=(const FeatureMap& rhs);
188 
195  OPENMS_DLLAPI void sortByIntensity(bool reverse = false);
197 
199  OPENMS_DLLAPI void sortByPosition();
200 
202  OPENMS_DLLAPI void sortByRT();
203 
205  OPENMS_DLLAPI void sortByMZ();
206 
208  OPENMS_DLLAPI void sortByOverallQuality(bool reverse = false);
209 
211 
212  // Docu in base class
213  OPENMS_DLLAPI void updateRanges();
214 
216  OPENMS_DLLAPI void swapFeaturesOnly(FeatureMap& from);
217 
218  OPENMS_DLLAPI void swap(FeatureMap& from);
219 
221  OPENMS_DLLAPI const std::vector<ProteinIdentification>& getProteinIdentifications() const;
222 
224  OPENMS_DLLAPI std::vector<ProteinIdentification>& getProteinIdentifications();
225 
227  OPENMS_DLLAPI void setProteinIdentifications(const std::vector<ProteinIdentification>& protein_identifications);
228 
230  OPENMS_DLLAPI const std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications() const;
231 
233  OPENMS_DLLAPI std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications();
234 
236  OPENMS_DLLAPI void setUnassignedPeptideIdentifications(const std::vector<PeptideIdentification>& unassigned_peptide_identifications);
237 
239  OPENMS_DLLAPI const std::vector<DataProcessing>& getDataProcessing() const;
240 
242  OPENMS_DLLAPI std::vector<DataProcessing>& getDataProcessing();
243 
245  OPENMS_DLLAPI void setDataProcessing(const std::vector<DataProcessing>& processing_method);
246 
252  OPENMS_DLLAPI void clear(bool clear_meta_data = true);
253 
266  template <typename Type>
267  Size applyMemberFunction(Size (Type::* member_function)())
268  {
269  Size assignments = 0;
270  assignments += ((*this).*member_function)();
271  for (Iterator iter = this->begin(); iter != this->end(); ++iter)
272  {
273  assignments += iter->applyMemberFunction(member_function);
274  }
275  return assignments;
276  }
277 
279  template <typename Type>
280  Size applyMemberFunction(Size (Type::* member_function)() const) const
281  {
282  Size assignments = 0;
283  assignments += ((*this).*member_function)();
284  for (ConstIterator iter = this->begin(); iter != this->end(); ++iter)
285  {
286  assignments += iter->applyMemberFunction(member_function);
287  }
288  return assignments;
289  }
290 
291  OPENMS_DLLAPI AnnotationStatistics getAnnotationStatistics() const;
292 
293 protected:
294 
296  std::vector<ProteinIdentification> protein_identifications_;
297 
299  std::vector<PeptideIdentification> unassigned_peptide_identifications_;
300 
302  std::vector<DataProcessing> data_processing_;
303  };
304 
305  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const FeatureMap& map);
306 
307 } // namespace OpenMS
308 
309 #endif // OPENMS_KERNEL_DFEATUREMAP_H
Base::const_iterator ConstIterator
Definition: FeatureMap.h:137
std::vector< Size > states
Definition: FeatureMap.h:62
A container for features.
Definition: FeatureMap.h:93
Base::reverse_iterator ReverseIterator
Definition: FeatureMap.h:138
FeatureType & Reference
Definition: FeatureMap.h:140
Feature FeatureType
Definition: FeatureMap.h:133
Size applyMemberFunction(Size(Type::*member_function)())
Applies a member function of Type to the container itself and all features (including subordinates)...
Definition: FeatureMap.h:267
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Base::const_reverse_iterator ConstReverseIterator
Definition: FeatureMap.h:139
const FeatureType & ConstReference
Definition: FeatureMap.h:141
RangeManager< 2 > RangeManagerType
Definition: FeatureMap.h:134
std::vector< ProteinIdentification > protein_identifications_
protein identifications
Definition: FeatureMap.h:296
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
A base class for random access containers for classes derived from UniqueIdInterface that adds functi...
Definition: UniqueIdIndexer.h:64
Base::iterator Iterator
Definition: FeatureMap.h:136
An LC-MS feature.
Definition: Feature.h:70
std::vector< Feature > privvec
Definition: FeatureMap.h:104
std::vector< PeptideIdentification > unassigned_peptide_identifications_
peptide identifications not matched to a specific feature
Definition: FeatureMap.h:299
A base class defining a common interface for all classes having a unique id.
Definition: UniqueIdInterface.h:52
std::vector< FeatureType > Base
Definition: FeatureMap.h:135
std::vector< DataProcessing > data_processing_
applied data processing
Definition: FeatureMap.h:302
AnnotationState
state of identification, use getIDState() to query it
Definition: BaseFeature.h:70
Definition: FeatureMap.h:60
Size applyMemberFunction(Size(Type::*member_function)() const) const
The "const" variant.
Definition: FeatureMap.h:280
Handles the management of a position and intensity range.
Definition: RangeManager.h:48
Manage source document information.
Definition: DocumentIdentifier.h:56

OpenMS / TOPP release 2.0.0 Documentation generated on Tue Nov 1 2016 16:34:46 using doxygen 1.8.11