libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
filtertriangle.cpp
Go to the documentation of this file.
1
/**
2
* \file pappsomspp/filers/filtertriangle.h
3
* \date 27/10/2019
4
* \author Olivier Langella
5
* \brief sum peaks under a triangle base
6
*/
7
8
/*******************************************************************************
9
* Copyright (c) 2019 Olivier Langella <Olivier.Langella@u-psud.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
******************************************************************************/
27
28
#include "
filtertriangle.h
"
29
#include <QDebug>
30
31
using namespace
pappso
;
32
33
FilterTriangle::FilterTriangle
()
34
{
35
}
36
37
FilterTriangle::FilterTriangle
(
const
FilterTriangle
&other)
38
{
39
m_triangleSlope
= other.
m_triangleSlope
;
40
}
41
42
FilterTriangle::~FilterTriangle
()
43
{
44
}
45
46
double
47
FilterTriangle::setTriangleSlope
(
double
intensity,
double
mz)
48
{
49
m_maxMzRange
= mz;
50
m_triangleSlope
= mz / intensity;
51
return
m_triangleSlope
;
52
}
53
54
DataPoint
55
FilterTriangle::sumAndRemove
(
Trace
&trace,
const
DataPoint
&max_intensity)
const
56
{
57
58
// qDebug();
59
// double sum = max_intensity.y;
60
// double wmean = max_intensity.y * max_intensity.x;
61
double
mz_range = max_intensity.
y
*
m_triangleSlope
;
62
if
(mz_range >
m_maxMzRange
)
63
{
64
mz_range =
m_maxMzRange
;
65
}
66
double
min_range = max_intensity.
x
- mz_range;
67
double
max_range = max_intensity.
x
+ mz_range;
68
69
DataPoint
new_point;
70
new_point.
y
= 0;
71
new_point.
x
= 0;
72
// Trace new_trace;
73
74
for
(
DataPoint
&old_point : trace)
75
{
76
if
((old_point.x < min_range) || (old_point.x > max_range))
77
{
78
// new_trace.push_back(old_point);
79
}
80
else
81
{
82
new_point.
y
+= old_point.y;
83
new_point.
x
+= old_point.y * old_point.x;
84
old_point.y = 0;
85
}
86
}
87
88
// trace = std::move(new_trace);
89
new_point.
x
= new_point.
x
/ new_point.
y
;
// weighted mean on mz
90
return
new_point;
91
}
92
93
Trace
&
94
FilterTriangle::filter
(
Trace
&data_points)
const
95
{
96
// qDebug() << data_points.size();
97
Trace
new_trace;
98
99
std::vector<DataPoint>::iterator it_max =
maxYDataPoint
(data_points.begin(), data_points.end());
100
// qDebug();
101
while
((it_max != data_points.end()) && (it_max->y > 0))
102
{
103
// qDebug();
104
new_trace.push_back(
sumAndRemove
(data_points, *it_max));
105
// qDebug();
106
it_max =
maxYDataPoint
(data_points.begin(), data_points.end());
107
}
108
109
new_trace.
sortX
();
110
// qDebug() << new_trace.size();
111
data_points = std::move(new_trace);
112
// qDebug() << data_points.size();
113
return
data_points;
114
}
pappso::FilterTriangle::filter
Trace & filter(Trace &data_points) const override
Definition
filtertriangle.cpp:94
pappso::FilterTriangle::~FilterTriangle
~FilterTriangle()
Definition
filtertriangle.cpp:42
pappso::FilterTriangle::FilterTriangle
FilterTriangle()
Definition
filtertriangle.cpp:33
pappso::FilterTriangle::sumAndRemove
DataPoint sumAndRemove(Trace &trace, const DataPoint &max_intensity) const
Definition
filtertriangle.cpp:55
pappso::FilterTriangle::setTriangleSlope
double setTriangleSlope(double intensity, double mz)
Definition
filtertriangle.cpp:47
pappso::FilterTriangle::m_triangleSlope
double m_triangleSlope
Definition
filtertriangle.h:67
pappso::FilterTriangle::m_maxMzRange
double m_maxMzRange
Definition
filtertriangle.h:68
pappso::Trace
A simple container of DataPoint instances.
Definition
trace.h:152
pappso::Trace::sortX
void sortX(Enums::SortOrder sort_order=Enums::SortOrder::ascending)
Definition
trace.cpp:1070
filtertriangle.h
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::maxYDataPoint
std::vector< DataPoint >::const_iterator maxYDataPoint(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
Definition
trace.cpp:169
pappso::DataPoint
Definition
datapoint.h:22
pappso::DataPoint::x
pappso_double x
Definition
datapoint.h:24
pappso::DataPoint::y
pappso_double y
Definition
datapoint.h:25
pappsomspp
core
processing
filters
filtertriangle.cpp
Generated on
for libpappsomspp by
1.17.0