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-2017.
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>
42 
43 #include <OpenMS/CONCEPT/Types.h>
47 #include <OpenMS/OpenMSConfig.h>
48 
49 #include <algorithm>
50 #include <exception>
51 #include <vector>
52 
53 namespace OpenMS
54 {
55  class ProteinIdentification;
56  class PeptideIdentification;
57  class DataProcessing;
58 
61  struct OPENMS_DLLAPI AnnotationStatistics
62  {
63  std::vector<Size> states; //< count each state, indexing by BaseFeature::AnnotationState
64 
66 
68 
69  AnnotationStatistics& operator=(const AnnotationStatistics& rhs);
70 
71  bool operator==(const AnnotationStatistics& rhs) const;
72 
74  };
75 
76 
78  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const AnnotationStatistics& ann);
79 
94  class FeatureMap :
95  private std::vector<Feature>,
96  public MetaInfoInterface,
97  public RangeManager<2>,
98  public DocumentIdentifier,
99  public UniqueIdInterface,
100  public UniqueIdIndexer<FeatureMap>
101  {
102 public:
106  typedef std::vector<Feature> privvec;
107 
108  // types
109  using privvec::value_type;
110  using privvec::iterator;
111  using privvec::const_iterator;
112  using privvec::size_type;
113  using privvec::pointer; // ConstRefVector
114  using privvec::reference; // ConstRefVector
115  using privvec::const_reference; // ConstRefVector
116  using privvec::difference_type; // ConstRefVector
117 
118  // functions
119  using privvec::begin;
120  using privvec::end;
121 
122  using privvec::size;
123  using privvec::resize; // ConsensusMap, FeatureXMLFile
124  using privvec::empty;
125  using privvec::reserve;
126  using privvec::operator[];
127  using privvec::at; // UniqueIdIndexer
128  using privvec::back; // FeatureXMLFile
129 
130  using privvec::push_back;
131  using privvec::pop_back; // FeatureXMLFile
132  using privvec::erase; // source/VISUAL/Spectrum2DCanvas.cpp 2871, FeatureMap_test 599
133 
137  typedef std::vector<FeatureType> Base;
138  typedef Base::iterator Iterator;
139  typedef Base::const_iterator ConstIterator;
140  typedef Base::reverse_iterator ReverseIterator;
141  typedef Base::const_reverse_iterator ConstReverseIterator;
142  typedef FeatureType& Reference;
143  typedef const FeatureType& ConstReference;
145 
150 
152  OPENMS_DLLAPI FeatureMap();
153 
155  OPENMS_DLLAPI FeatureMap(const FeatureMap& source);
156 
158  OPENMS_DLLAPI virtual ~FeatureMap();
160 
162  OPENMS_DLLAPI FeatureMap& operator=(const FeatureMap& rhs);
163 
165  OPENMS_DLLAPI bool operator==(const FeatureMap& rhs) const;
166 
168  OPENMS_DLLAPI bool operator!=(const FeatureMap& rhs) const;
169 
175  OPENMS_DLLAPI FeatureMap operator+(const FeatureMap& rhs) const;
176 
189  OPENMS_DLLAPI FeatureMap& operator+=(const FeatureMap& rhs);
190 
197  OPENMS_DLLAPI void sortByIntensity(bool reverse = false);
199 
201  OPENMS_DLLAPI void sortByPosition();
202 
204  OPENMS_DLLAPI void sortByRT();
205 
207  OPENMS_DLLAPI void sortByMZ();
208 
210  OPENMS_DLLAPI void sortByOverallQuality(bool reverse = false);
211 
213 
214  // Docu in base class
215  OPENMS_DLLAPI void updateRanges();
216 
218  OPENMS_DLLAPI void swapFeaturesOnly(FeatureMap& from);
219 
220  OPENMS_DLLAPI void swap(FeatureMap& from);
221 
223  OPENMS_DLLAPI const std::vector<ProteinIdentification>& getProteinIdentifications() const;
224 
226  OPENMS_DLLAPI std::vector<ProteinIdentification>& getProteinIdentifications();
227 
229  OPENMS_DLLAPI void setProteinIdentifications(const std::vector<ProteinIdentification>& protein_identifications);
230 
232  OPENMS_DLLAPI const std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications() const;
233 
235  OPENMS_DLLAPI std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications();
236 
238  OPENMS_DLLAPI void setUnassignedPeptideIdentifications(const std::vector<PeptideIdentification>& unassigned_peptide_identifications);
239 
241  OPENMS_DLLAPI const std::vector<DataProcessing>& getDataProcessing() const;
242 
244  OPENMS_DLLAPI std::vector<DataProcessing>& getDataProcessing();
245 
247  OPENMS_DLLAPI void setDataProcessing(const std::vector<DataProcessing>& processing_method);
248 
250  OPENMS_DLLAPI void setPrimaryMSRunPath(const StringList& s);
251 
253  OPENMS_DLLAPI void getPrimaryMSRunPath(StringList& toFill) const;
254 
260  OPENMS_DLLAPI void clear(bool clear_meta_data = true);
261 
274  template <typename Type>
275  Size applyMemberFunction(Size (Type::* member_function)())
276  {
277  Size assignments = 0;
278  assignments += ((*this).*member_function)();
279  for (Iterator iter = this->begin(); iter != this->end(); ++iter)
280  {
281  assignments += iter->applyMemberFunction(member_function);
282  }
283  return assignments;
284  }
285 
287  template <typename Type>
288  Size applyMemberFunction(Size (Type::* member_function)() const) const
289  {
290  Size assignments = 0;
291  assignments += ((*this).*member_function)();
292  for (ConstIterator iter = this->begin(); iter != this->end(); ++iter)
293  {
294  assignments += iter->applyMemberFunction(member_function);
295  }
296  return assignments;
297  }
298 
299  OPENMS_DLLAPI AnnotationStatistics getAnnotationStatistics() const;
300 
301 protected:
302 
304  std::vector<ProteinIdentification> protein_identifications_;
305 
307  std::vector<PeptideIdentification> unassigned_peptide_identifications_;
308 
310  std::vector<DataProcessing> data_processing_;
311  };
312 
313  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const FeatureMap& map);
314 
315 } // namespace OpenMS
316 
317 #endif // OPENMS_KERNEL_DFEATUREMAP_H
Base::const_iterator ConstIterator
Definition: FeatureMap.h:139
std::vector< Size > states
Definition: FeatureMap.h:63
Size applyMemberFunction(Size(Type::*member_function)() const) const
The "const" variant.
Definition: FeatureMap.h:288
A container for features.
Definition: FeatureMap.h:94
Base::reverse_iterator ReverseIterator
Definition: FeatureMap.h:140
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806
FeatureType & Reference
Definition: FeatureMap.h:142
Feature FeatureType
Definition: FeatureMap.h:135
Size applyMemberFunction(Size(Type::*member_function)())
Applies a member function of Type to the container itself and all features (including subordinates)...
Definition: FeatureMap.h:275
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Base::const_reverse_iterator ConstReverseIterator
Definition: FeatureMap.h:141
const FeatureType & ConstReference
Definition: FeatureMap.h:143
RangeManager< 2 > RangeManagerType
Definition: FeatureMap.h:136
std::vector< ProteinIdentification > protein_identifications_
protein identifications
Definition: FeatureMap.h:304
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:138
An LC-MS feature.
Definition: Feature.h:70
std::vector< Feature > privvec
Definition: FeatureMap.h:106
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:56
std::vector< PeptideIdentification > unassigned_peptide_identifications_
peptide identifications not matched to a specific feature
Definition: FeatureMap.h:307
A base class defining a common interface for all classes having a unique id.
Definition: UniqueIdInterface.h:52
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:74
std::vector< FeatureType > Base
Definition: FeatureMap.h:137
std::vector< DataProcessing > data_processing_
applied data processing
Definition: FeatureMap.h:310
bool operator!=(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:824
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
AnnotationState
state of identification, use getIDState() to query it
Definition: BaseFeature.h:70
Definition: FeatureMap.h:61
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.3.0 Documentation generated on Tue Jan 9 2018 18:22:00 using doxygen 1.8.13