libpappsomspp
Library for mass spectrometry
massspectrum.h
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/massspectrum/massspectrum.h
3  * \date 15/3/2015
4  * \author Olivier Langella
5  * \brief basic mass spectrum
6  */
7 
8 /*******************************************************************************
9  * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
10  *
11  * This file is part of the PAPPSOms++ library.
12  *
13  * PAPPSOms++ is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation, either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * PAPPSOms++ is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
25  *
26  * Contributors:
27  * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
28  *implementation
29  ******************************************************************************/
30 
31 #pragma once
32 
33 #include <vector>
34 #include <memory>
35 #include <limits>
36 
37 #include <QDataStream>
38 
39 #include "../exportinmportconfig.h"
40 
41 #include "../mzrange.h"
42 #include "../trace/trace.h"
43 
44 
45 namespace pappso
46 {
47 
48 // Forward declaration.
49 class MassSpectrum;
50 
51 QDataStream &operator<<(QDataStream &out, const MassSpectrum &spectrum);
52 QDataStream &operator>>(QDataStream &out, MassSpectrum &spectrum);
53 
54 typedef std::shared_ptr<MassSpectrum> MassSpectrumSPtr;
55 typedef std::shared_ptr<const MassSpectrum> MassSpectrumCstSPtr;
56 
57 class MassSpectrumCombinerInterface;
58 
59 
60 //! Class to represent a mass spectrum.
61 /*!
62  * A mass spectrum is a collection of DataPoint instances. Moreover, it has
63  * internal data that represent the context of the acquisition of the data:
64  * retention time and drift time (if the experiment was an ion mobility mass
65  * spectrometry experiment).
66  *
67  * A MassSpectrum cannot perform combinations. For combination of mass
68  * spectra, the class to use is MassSpectrumCombinator.
69  */
70 class PMSPP_LIB_DECL MassSpectrum : public Trace
71 {
72 
73  public:
74  MassSpectrum();
75  MassSpectrum(std::vector<std::pair<pappso_double, pappso_double>> &vector);
76 
77  MassSpectrum(const MapTrace &other);
78  MassSpectrum(const Trace &other);
79  MassSpectrum(Trace &&other); // move constructor
80 
81  MassSpectrum(const MassSpectrum &other);
82  MassSpectrum(MassSpectrum &&other); // move constructor
83 
84  virtual ~MassSpectrum();
85 
86  virtual MassSpectrum &operator=(const MassSpectrum &other);
87  virtual MassSpectrum &operator=(MassSpectrum &&other);
88 
89  MassSpectrumSPtr makeMassSpectrumSPtr() const;
90  MassSpectrumCstSPtr makeMassSpectrumCstSPtr() const;
91 
92  /** @brief apply a filter on this MassSpectrum
93  * @param filter to process the MassSpectrum
94  * @return reference on the modified MassSpectrum
95  */
96  virtual MassSpectrum &
97  massSpectrumFilter(const MassSpectrumFilterInterface &filter) final;
98 
99  pappso_double totalIonCurrent() const;
100  // Alias for totalIonCurrent().
101  pappso_double tic() const;
102  pappso_double tic(double mzStart, double mzEnd);
103 
104  const DataPoint &maxIntensityDataPoint() const;
105 
106  const DataPoint &lowestIntensityDataPoint() const;
107 
108  void sortMz();
109 
110  bool equals(const MassSpectrum &other, PrecisionPtr precision) const;
111 
112  MassSpectrum filterSum(const MzRange &mass_range) const;
113 
114 
115  // friend QDataStream& operator<<(QDataStream& out, const MassSpectrum&
116  // massSpectrum);
117  // friend QDataStream& operator>>(QDataStream& out, MassSpectrum&
118  // massSpectrum);
119 
120  void debugPrintValues() const;
121 };
122 
123 
124 } // namespace pappso
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition: types.h:69
pappso::MassSpectrumCstSPtr
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
Definition: massspectrum.h:76
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition: exportinmportconfig.h:14
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks
Definition: aa.cpp:39
pappso::MassSpectrum
Class to represent a mass spectrum.
Definition: massspectrum.h:92
pappso::DataPoint
Definition: datapoint.h:21
pappso::MapTrace
Definition: maptrace.h:33
pappso::MzRange
Definition: mzrange.h:67
pappso::Trace
A simple container of DataPoint instances.
Definition: trace.h:132
pappso::operator>>
QDataStream & operator>>(QDataStream &instream, MassSpectrum &massSpectrum)
Definition: massspectrum.cpp:373
pappso::operator<<
QDataStream & operator<<(QDataStream &outstream, const MassSpectrum &massSpectrum)
Definition: massspectrum.cpp:359
pappso::MassSpectrumFilterInterface
generic interface to apply a filter on a MassSpectrum This is the same as FilterInterface,...
Definition: filterinterface.h:73
pappso::PrecisionBase
Definition: precision.h:65
pappso::MassSpectrumSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition: massspectrum.h:75