Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
ConsensusMap.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: Timo Sachsenberg $
32 // $Authors: $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
43 
44 #include <OpenMS/CONCEPT/Types.h>
46 #include <OpenMS/OpenMSConfig.h>
47 
48 #include <map>
49 #include <vector>
50 
51 namespace OpenMS
52 {
53  class ProteinIdentification;
54  class DataProcessing;
55  namespace Logger
56  {
57  class LogStream;
58  }
59 
71  class ConsensusMap : // no OPENMS_DLLAPI here, since the class is derived from an STL class - we do not want parts of the STL lib in OpenMS.lib, since it will cause linker errors
72  private std::vector<ConsensusFeature>,
73  public MetaInfoInterface,
74  public RangeManager<2>,
75  public DocumentIdentifier,
76  public UniqueIdInterface,
77  public UniqueIdIndexer<ConsensusMap>
78  {
79 
80 public:
81  typedef std::vector<ConsensusFeature> privvec;
82 
83  // types
84  using privvec::value_type;
85  using privvec::iterator;
86  using privvec::const_iterator;
87  using privvec::size_type;
88  using privvec::pointer; // ConstRefVector
89  using privvec::reference; // ConstRefVector
90  using privvec::const_reference; // ConstRefVector
91  using privvec::difference_type; // ConstRefVector
92 
93  // functions
94  using privvec::begin;
95  using privvec::end;
96 
97  using privvec::size;
98  using privvec::resize;
99  using privvec::empty;
100  using privvec::reserve;
101  using privvec::operator[];
102  using privvec::at; // UniqueIdIndexer
103  using privvec::back; // source/ANALYSIS/DECHARGING/FeatureDeconvolution.cpp:977:
104 
105  using privvec::push_back;
106 
108  struct OPENMS_DLLAPI FileDescription :
109  public MetaInfoInterface
110  {
112  FileDescription();
113 
116 
126  };
127 
129 
130  typedef std::vector<ConsensusFeature> Base;
132  typedef std::map<UInt64, FileDescription> FileDescriptions;
134  typedef std::vector<ConsensusFeature>::iterator Iterator;
136  typedef std::vector<ConsensusFeature>::const_iterator ConstIterator;
138  typedef std::vector<ConsensusFeature>::reverse_iterator ReverseIterator;
140  typedef std::vector<ConsensusFeature>::const_reverse_iterator ConstReverseIterator;
142 
144  OPENMS_DLLAPI ConsensusMap();
145 
147  OPENMS_DLLAPI ConsensusMap(const ConsensusMap& source);
148 
150  OPENMS_DLLAPI ~ConsensusMap() override;
151 
153  OPENMS_DLLAPI explicit ConsensusMap(Base::size_type n);
154 
156  OPENMS_DLLAPI ConsensusMap& operator=(const ConsensusMap& source);
157 
167  OPENMS_DLLAPI ConsensusMap& operator+=(const ConsensusMap& rhs);
168 
174  OPENMS_DLLAPI void clear(bool clear_meta_data = true);
175 
177  OPENMS_DLLAPI const FileDescriptions& getFileDescriptions() const;
178 
180  OPENMS_DLLAPI FileDescriptions& getFileDescriptions();
181 
183  OPENMS_DLLAPI void setFileDescriptions(const FileDescriptions& file_description);
184 
186  OPENMS_DLLAPI const String& getExperimentType() const;
187 
189  OPENMS_DLLAPI void setExperimentType(const String& experiment_type);
190 
198  OPENMS_DLLAPI void sortByIntensity(bool reverse = false);
200 
202  OPENMS_DLLAPI void sortByRT();
203 
205  OPENMS_DLLAPI void sortByMZ();
206 
208  OPENMS_DLLAPI void sortByPosition();
209 
211  OPENMS_DLLAPI void sortByQuality(bool reverse = false);
212 
214  OPENMS_DLLAPI void sortBySize();
215 
217  OPENMS_DLLAPI void sortByMaps();
218 
220  OPENMS_DLLAPI void sortPeptideIdentificationsByMapIndex();
222 
223  // Docu in base class
224  OPENMS_DLLAPI void updateRanges() override;
225 
227  OPENMS_DLLAPI void swap(ConsensusMap& from);
228 
230  OPENMS_DLLAPI const std::vector<ProteinIdentification>& getProteinIdentifications() const;
231 
233  OPENMS_DLLAPI std::vector<ProteinIdentification>& getProteinIdentifications();
234 
236  OPENMS_DLLAPI void setProteinIdentifications(const std::vector<ProteinIdentification>& protein_identifications);
237 
239  OPENMS_DLLAPI const std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications() const;
240 
242  OPENMS_DLLAPI std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications();
243 
245  OPENMS_DLLAPI void setUnassignedPeptideIdentifications(const std::vector<PeptideIdentification>& unassigned_peptide_identifications);
246 
248  OPENMS_DLLAPI const std::vector<DataProcessing>& getDataProcessing() const;
249 
251  OPENMS_DLLAPI std::vector<DataProcessing>& getDataProcessing();
252 
254  OPENMS_DLLAPI void setDataProcessing(const std::vector<DataProcessing>& processing_method);
255 
257  OPENMS_DLLAPI void setPrimaryMSRunPath(const StringList& s);
258 
261  OPENMS_DLLAPI void getPrimaryMSRunPath(StringList& toFill) const;
262 
264  OPENMS_DLLAPI bool operator==(const ConsensusMap& rhs) const;
265 
267  OPENMS_DLLAPI bool operator!=(const ConsensusMap& rhs) const;
268 
282  template <typename Type>
283  Size applyMemberFunction(Size (Type::* member_function)())
284  {
285  Size assignments = 0;
286  assignments += ((*this).*member_function)();
287  for (Iterator iter = this->begin(); iter != this->end(); ++iter)
288  {
289  assignments += ((*iter).*member_function)();
290  }
291  return assignments;
292  }
293 
295  template <typename Type>
296  Size applyMemberFunction(Size (Type::* member_function)() const) const
297  {
298  Size assignments = 0;
299  assignments += ((*this).*member_function)();
300  for (ConstIterator iter = this->begin(); iter != this->end(); ++iter)
301  {
302  assignments += ((*iter).*member_function)();
303  }
304  return assignments;
305  }
306 
319  bool isMapConsistent(Logger::LogStream* stream = nullptr) const;
320 
321 protected:
322 
325 
328 
330  std::vector<ProteinIdentification> protein_identifications_;
331 
333  std::vector<PeptideIdentification> unassigned_peptide_identifications_;
334 
336  std::vector<DataProcessing> data_processing_;
337  };
338 
340  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const ConsensusMap& cons_map);
341 
342 } // namespace OpenMS
343 
void setDataProcessing(const std::vector< DataProcessing > &processing_method)
sets the description of the applied data processing
~ConsensusMap() override
Destructor.
std::vector< ConsensusFeature >::iterator Iterator
Mutable iterator.
Definition: ConsensusMap.h:134
void sortPeptideIdentificationsByMapIndex()
Sorts PeptideIdentifications of consensus features with respect to their map index.
void sortByMZ()
Sorts the peaks to m/z position.
A more convenient string class.
Definition: String.h:57
void clear(bool clear_meta_data=true)
Clears all data and meta data.
String label
Label e.g. &#39;heavy&#39; and &#39;light&#39; for ICAT, or &#39;sample1&#39; and &#39;sample2&#39; for label-free quantitation...
Definition: ConsensusMap.h:120
std::vector< ConsensusFeature >::const_reverse_iterator ConstReverseIterator
Non-mutable reverse iterator.
Definition: ConsensusMap.h:140
Source file description for input files.
Definition: ConsensusMap.h:108
std::vector< PeptideIdentification > unassigned_peptide_identifications_
protein identifications
Definition: ConsensusMap.h:333
UInt64 unique_id
Unique id of the file.
Definition: ConsensusMap.h:125
A container for consensus elements.
Definition: ConsensusMap.h:71
void sortByQuality(bool reverse=false)
Sorts the peaks according to ascending quality.
Size applyMemberFunction(Size(Type::*member_function)())
Applies a member function of Type to the container itself and all consensus features. The returned values are accumulated.
Definition: ConsensusMap.h:283
bool operator==(const ConsensusMap &rhs) const
Equality operator.
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
std::vector< DataProcessing > data_processing_
applied data processing
Definition: ConsensusMap.h:336
void setExperimentType(const String &experiment_type)
Mutable access to the experiment type.
ConsensusMap()
Default constructor.
Log Stream Class.
Definition: LogStream.h:302
FileDescriptions file_description_
Map from index to file description.
Definition: ConsensusMap.h:324
std::vector< ConsensusFeature >::reverse_iterator ReverseIterator
Mutable reverse iterator.
Definition: ConsensusMap.h:138
const std::vector< DataProcessing > & getDataProcessing() const
returns a const reference to the description of the applied data processing
void getPrimaryMSRunPath(StringList &toFill) const
String experiment_type_
type of experiment (label-free, itraq, ...); see xsd schema
Definition: ConsensusMap.h:327
std::vector< ConsensusFeature > Base
Definition: ConsensusMap.h:130
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
void sortByMaps()
Sorts with respect to the sets of maps covered by the consensus features (lexicographically).
A base class for random access containers for classes derived from UniqueIdInterface that adds functi...
Definition: UniqueIdIndexer.h:63
void setFileDescriptions(const FileDescriptions &file_description)
Mutable access to the file descriptions.
void setPrimaryMSRunPath(const StringList &s)
set the file path to the primary MS run (usually the mzML file obtained after data conversion from ra...
bool isMapConsistent(Logger::LogStream *stream=nullptr) const
checks if the given maps are unique and all FeatureHandles actually refer to a registered map ...
RangeManager< 2 > RangeManagerType
Definition: ConsensusMap.h:131
void setUnassignedPeptideIdentifications(const std::vector< PeptideIdentification > &unassigned_peptide_identifications)
sets the unassigned peptide identifications
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:55
std::map< UInt64, FileDescription > FileDescriptions
Definition: ConsensusMap.h:132
A base class defining a common interface for all classes having a unique id.
Definition: UniqueIdInterface.h:51
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:73
bool operator!=(const ConsensusMap &rhs) const
Equality operator.
std::vector< ProteinIdentification > protein_identifications_
protein identifications
Definition: ConsensusMap.h:330
ConsensusMap & operator=(const ConsensusMap &source)
Assignment operator.
void sortBySize()
Sorts with respect to the size (number of elements)
const std::vector< ProteinIdentification > & getProteinIdentifications() const
non-mutable access to the protein identifications
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
std::vector< ConsensusFeature > privvec
Definition: ConsensusMap.h:81
void swap(ConsensusMap &from)
Swaps the content of this map with the content of from.
Size applyMemberFunction(Size(Type::*member_function)() const) const
The "const" variant.
Definition: ConsensusMap.h:296
const FileDescriptions & getFileDescriptions() const
Non-mutable access to the file descriptions.
const String & getExperimentType() const
Non-mutable access to the experiment type.
void sortByPosition()
Lexicographically sorts the peaks by their position (First RT then m/z).
Handles the management of a position and intensity range.
Definition: RangeManager.h:47
void updateRanges() override
Updates minimum and maximum position/intensity.
std::vector< ConsensusFeature >::const_iterator ConstIterator
Non-mutable iterator.
Definition: ConsensusMap.h:136
String filename
File name of the file.
Definition: ConsensusMap.h:118
Size size
Number of elements (features, peaks, ...). This is e.g. used to check for correct element indices whe...
Definition: ConsensusMap.h:123
void setProteinIdentifications(const std::vector< ProteinIdentification > &protein_identifications)
sets the protein identifications
void sortByRT()
Sorts the peaks to RT position.
const std::vector< PeptideIdentification > & getUnassignedPeptideIdentifications() const
non-mutable access to the unassigned peptide identifications
ConsensusMap & operator+=(const ConsensusMap &rhs)
Add one consensus map to another.
Manage source document information.
Definition: DocumentIdentifier.h:55
void sortByIntensity(bool reverse=false)
Sorts the peaks according to ascending intensity.

OpenMS / TOPP release 2.3.0 Documentation generated on Wed Apr 18 2018 19:29:04 using doxygen 1.8.14