Line |
Branch |
Exec |
Source |
1 |
|
|
/* BEGIN software license |
2 |
|
|
* |
3 |
|
|
* MsXpertSuite - mass spectrometry software suite |
4 |
|
|
* ----------------------------------------------- |
5 |
|
|
* Copyright(C) 2009,...,2018 Filippo Rusconi |
6 |
|
|
* |
7 |
|
|
* http://www.msxpertsuite.org |
8 |
|
|
* |
9 |
|
|
* This file is part of the MsXpertSuite project. |
10 |
|
|
* |
11 |
|
|
* The MsXpertSuite project is the successor of the massXpert project. This |
12 |
|
|
* project now includes various independent modules: |
13 |
|
|
* |
14 |
|
|
* - massXpert, model polymer chemistries and simulate mass spectrometric data; |
15 |
|
|
* - mineXpert, a powerful TIC chromatogram/mass spectrum viewer/miner; |
16 |
|
|
* |
17 |
|
|
* This program is free software: you can redistribute it and/or modify |
18 |
|
|
* it under the terms of the GNU General Public License as published by |
19 |
|
|
* the Free Software Foundation, either version 3 of the License, or |
20 |
|
|
* (at your option) any later version. |
21 |
|
|
* |
22 |
|
|
* This program is distributed in the hope that it will be useful, |
23 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 |
|
|
* GNU General Public License for more details. |
26 |
|
|
* |
27 |
|
|
* You should have received a copy of the GNU General Public License |
28 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
29 |
|
|
* |
30 |
|
|
* END software license |
31 |
|
|
*/ |
32 |
|
|
|
33 |
|
|
|
34 |
|
|
/////////////////////// Local includes |
35 |
|
|
#include "PeakCentroid.hpp" |
36 |
|
|
#include <ctime> |
37 |
|
|
|
38 |
|
|
|
39 |
|
|
namespace MsXpS |
40 |
|
|
{ |
41 |
|
|
|
42 |
|
|
namespace libXpertMass |
43 |
|
|
{ |
44 |
|
|
|
45 |
|
|
|
46 |
|
✗ |
PeakCentroid::PeakCentroid(double mz, double intensity) |
47 |
|
|
{ |
48 |
|
✗ |
Q_ASSERT(mz >= 0); |
49 |
|
✗ |
Q_ASSERT(intensity >= 0); |
50 |
|
|
|
51 |
|
✗ |
m_mz = mz; |
52 |
|
✗ |
m_intensity = intensity; |
53 |
|
✗ |
} |
54 |
|
|
|
55 |
|
✗ |
PeakCentroid::PeakCentroid() : m_mz(0), m_intensity(0) |
56 |
|
|
{ |
57 |
|
✗ |
} |
58 |
|
|
|
59 |
|
|
|
60 |
|
✗ |
PeakCentroid::PeakCentroid(const PeakCentroid &other) |
61 |
|
✗ |
: m_mz(other.m_mz), m_intensity(other.m_intensity) |
62 |
|
|
{ |
63 |
|
✗ |
} |
64 |
|
|
|
65 |
|
|
|
66 |
|
✗ |
PeakCentroid::~PeakCentroid() |
67 |
|
|
{ |
68 |
|
✗ |
} |
69 |
|
|
|
70 |
|
|
|
71 |
|
|
PeakCentroid & |
72 |
|
✗ |
PeakCentroid::operator=(const PeakCentroid &other) |
73 |
|
|
{ |
74 |
|
✗ |
if(&other == this) |
75 |
|
✗ |
return *this; |
76 |
|
|
|
77 |
|
✗ |
m_mz = other.m_mz; |
78 |
|
✗ |
m_intensity = other.m_intensity; |
79 |
|
|
|
80 |
|
✗ |
return *this; |
81 |
|
|
} |
82 |
|
|
|
83 |
|
|
bool |
84 |
|
✗ |
PeakCentroid::operator==(const PeakCentroid &other) |
85 |
|
|
{ |
86 |
|
✗ |
return (m_mz == other.m_mz && m_intensity == other.m_intensity); |
87 |
|
|
} |
88 |
|
|
|
89 |
|
|
bool |
90 |
|
✗ |
PeakCentroid::operator!=(const PeakCentroid &other) |
91 |
|
|
{ |
92 |
|
✗ |
return (m_mz != other.m_mz || m_intensity != other.m_intensity); |
93 |
|
|
} |
94 |
|
|
|
95 |
|
|
void |
96 |
|
✗ |
PeakCentroid::setMz(double value) |
97 |
|
|
{ |
98 |
|
✗ |
m_mz = value; |
99 |
|
✗ |
} |
100 |
|
|
|
101 |
|
|
|
102 |
|
|
double |
103 |
|
✗ |
PeakCentroid::mz() const |
104 |
|
|
{ |
105 |
|
✗ |
return m_mz; |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
|
109 |
|
|
void |
110 |
|
✗ |
PeakCentroid::setIntensity(double value) |
111 |
|
|
{ |
112 |
|
✗ |
Q_ASSERT(value >= 0); |
113 |
|
|
|
114 |
|
✗ |
m_intensity = value; |
115 |
|
✗ |
} |
116 |
|
|
|
117 |
|
|
|
118 |
|
|
void |
119 |
|
✗ |
PeakCentroid::incrementIntensity(double value) |
120 |
|
|
{ |
121 |
|
✗ |
Q_ASSERT(value >= 0); |
122 |
|
|
|
123 |
|
✗ |
m_intensity += value; |
124 |
|
✗ |
} |
125 |
|
|
|
126 |
|
|
|
127 |
|
|
double |
128 |
|
✗ |
PeakCentroid::intensity() const |
129 |
|
|
{ |
130 |
|
✗ |
return m_intensity; |
131 |
|
|
} |
132 |
|
|
|
133 |
|
|
|
134 |
|
|
QString |
135 |
|
✗ |
PeakCentroid::intensity(int decimalPlaces) const |
136 |
|
|
{ |
137 |
|
✗ |
if(decimalPlaces < 0) |
138 |
|
✗ |
decimalPlaces = 0; |
139 |
|
|
|
140 |
|
✗ |
QString prob; |
141 |
|
|
|
142 |
|
✗ |
prob.setNum(m_intensity, 'f', decimalPlaces); |
143 |
|
|
|
144 |
|
✗ |
return prob; |
145 |
|
✗ |
} |
146 |
|
|
|
147 |
|
|
|
148 |
|
|
QString |
149 |
|
✗ |
PeakCentroid::toString() const |
150 |
|
|
{ |
151 |
|
✗ |
QString text = QString("m/z: %1, int: %2)\n").arg(m_mz).arg(m_intensity); |
152 |
|
|
|
153 |
|
✗ |
return text; |
154 |
|
|
} |
155 |
|
|
|
156 |
|
|
|
157 |
|
|
} // namespace libXpertMass |
158 |
|
|
|
159 |
|
|
} // namespace MsXpS |
160 |
|
|
|