libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
filterremovec13.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/filters/filterremovec13.h
3 * \date 19/08/2020
4 * \author Olivier Langella
5 * \brief sum peaks under a triangle base
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2020 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 "filterremovec13.h"
29
30using namespace pappso;
31
37
44
48
49Trace &
50FilterRemoveC13::filter(Trace &data_points) const
51{
52
53 std::vector<std::pair<double, double>> exclusionMassMap;
54 // qDebug() << data_points.size();
55 std::sort(data_points.begin(), data_points.end(), [](const DataPoint &a, const DataPoint &b) {
56 return (a.y > b.y);
57 });
58
59 Trace new_trace;
60
61 for(auto &data_point : data_points)
62 {
63 if(notExcluded(exclusionMassMap, data_point.x))
64 {
65 new_trace.push_back(data_point);
66 }
67 addExclusionMap(exclusionMassMap, data_point.x);
68 }
69 new_trace.sortX();
70 // qDebug() << new_trace.size();
71 data_points = std::move(new_trace);
72 // qDebug() << data_points.size();
73 return data_points;
74}
75
76bool
77pappso::FilterRemoveC13::notExcluded(std::vector<std::pair<double, double>> &exclusionMassMap,
78 double mass) const
79{
80 for(auto &mass_range : exclusionMassMap)
81 {
82 if((mass_range.first <= mass) && (mass_range.second >= mass))
83 {
84 return false;
85 }
86 }
87 return true;
88}
89
90void
91pappso::FilterRemoveC13::addExclusionMap(std::vector<std::pair<double, double>> &exclusionMassMap,
92 double mass) const
93{
95
96 exclusionMassMap.push_back(std::pair<double, double>(range1.lower(), range1.upper()));
97
98
100
101 exclusionMassMap.push_back(std::pair<double, double>(range2.lower(), range2.upper()));
102}
bool notExcluded(std::vector< std::pair< double, double > > &exclusionMassMap, double mass) const
void addExclusionMap(std::vector< std::pair< double, double > > &exclusionMassMap, double mass) const
Trace & filter(Trace &data_points) const override
FilterRemoveC13(PrecisionPtr precision_ptr)
pappso_double lower() const
Definition mzrange.h:71
pappso_double upper() const
Definition mzrange.h:77
A simple container of DataPoint instances.
Definition trace.h:148
void sortX(Enums::SortOrder sort_order=Enums::SortOrder::ascending)
Definition trace.cpp:1039
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
const PrecisionBase * PrecisionPtr
Definition precision.h:122
const pappso_double DIFFC12C13(1.0033548378)