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
43#include "../../exception/exceptionnotrecognized.h"
44#include "../../exception/exceptionnotpossible.h"
45
46namespace pappso
47{
48
49
51 : m_newYMax(new_max_y_value)
52{
53}
54
55
57 const QString &parameters)
58{
59 buildFilterFromString(parameters);
60}
61
62
68
69
73
74
77{
78 if(&other == this)
79 return *this;
80
81 m_newYMax = other.m_newYMax;
82
83 return *this;
84}
85
86
87void
89{
90 // Typical string: "FloorAmplitudePercentage|15"
91 if(parameters.startsWith(QString("%1|").arg(name())))
92 {
93 QStringList params = parameters.split("|").back().split(";");
94
95 m_newYMax = params.at(0).toDouble();
96 }
97 else
98 {
100 QString("Building of FilterNormalizeIntensities from string %1 failed")
101 .arg(parameters));
102 }
103}
104
105
106Trace &
108{
109 // Start by looking at the most intense data point (greatest y value of the
110 // whole trace)
111
112 auto max_dp_iter = maxYDataPoint(trace.cbegin(), trace.cend());
113
114 if(max_dp_iter == trace.cend())
116 QString("Failed to find the max intensity data point in the trace."));
117
118 if(!max_dp_iter->y)
120 QString("The max intensity data point in the trace has intensity 0."));
121
122 double ratio = m_newYMax / max_dp_iter->y;
123
124 for(DataPoint &dp : trace)
125 {
126 dp.y *= ratio;
127 }
128
129 // #if 0
130 max_dp_iter = maxYDataPoint(trace.cbegin(), trace.cend());
131 qDebug() << "Now max int:" << max_dp_iter->y;
132
133 // #endif
134
135 return trace;
136}
137
138
139//! Return a string with the textual representation of the configuration data.
140QString
142{
143 return QString("%1").arg(name()).arg(QString::number(m_newYMax, 'f', 2));
144}
145
146
147QString
149{
150 return "FilterNormalizeIntensities";
151}
152
153} // 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:148
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:180