libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
filternormalizeintensities.cpp
Go to the documentation of this file.
1/* BEGIN software license
2 *
3 * msXpertSuite - mass spectrometry software suite
4 * -----------------------------------------------
5 * Copyright(C) 2009,...,2021 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#include <qmath.h>
35
36#include <limits>
37#include <iterator>
38
39#include <QVector>
40#include <QDebug>
41
45
46namespace pappso
47{
48
49
51 : m_newYMax(new_max_y_value)
52{
53}
54
55
57{
58 buildFilterFromString(parameters);
59}
60
61
66
67
71
72
75{
76 if(&other == this)
77 return *this;
78
79 m_newYMax = other.m_newYMax;
80
81 return *this;
82}
83
84
85void
87{
88 // Typical string: "FloorAmplitudePercentage|15"
89 if(parameters.startsWith(QString("%1|").arg(name())))
90 {
91 QStringList params = parameters.split("|").back().split(";");
92
93 m_newYMax = params.at(0).toDouble();
94 }
95 else
96 {
98 QString("Building of FilterNormalizeIntensities from string %1 failed").arg(parameters));
99 }
100}
101
102
103Trace &
105{
106 // Start by looking at the most intense data point (greatest y value of the
107 // whole trace)
108
109 auto max_dp_iter = maxYDataPoint(trace.cbegin(), trace.cend());
110
111 if(max_dp_iter == trace.cend())
113 QString("Failed to find the max intensity data point in the trace."));
114
115 if(!max_dp_iter->y)
117 QString("The max intensity data point in the trace has intensity 0."));
118
119 double ratio = m_newYMax / max_dp_iter->y;
120
121 for(DataPoint &dp : trace)
122 {
123 dp.y *= ratio;
124 }
125
126 // #if 0
127 max_dp_iter = maxYDataPoint(trace.cbegin(), trace.cend());
128 qDebug() << "Now max int:" << max_dp_iter->y;
129
130 // #endif
131
132 return trace;
133}
134
135
136//! Return a string with the textual representation of the configuration data.
137QString
139{
140 return QString("%1").arg(name()).arg(QString::number(m_newYMax, 'f', 2));
141}
142
143
144QString
146{
147 return "FilterNormalizeIntensities";
148}
149
150} // namespace pappso
excetion to use when an item type is not recognized
Sets the maximum intensity of the trace to the provided value.
QString toString() const override
Return a string with the textual representation of the configuration data.
void buildFilterFromString(const QString &strBuildParams) override
build this filter using a string
Trace & filter(Trace &data_points) const override
FilterNormalizeIntensities & operator=(const FilterNormalizeIntensities &other)
A simple container of DataPoint instances.
Definition trace.h:152
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
std::vector< DataPoint >::const_iterator maxYDataPoint(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
Definition trace.cpp:169