libpappsomspp
Library for mass spectrometry
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 
30 using namespace pappso;
31 
33  : m_precisionPtr(precision_ptr)
34 {
37 }
38 
40  : m_precisionPtr(other.m_precisionPtr)
41 {
44 }
45 
47 {
48 }
49 
50 Trace &
51 FilterRemoveC13::filter(Trace &data_points) const
52 {
53 
54  std::vector<std::pair<double, double>> exclusionMassMap;
55  // qDebug() << data_points.size();
56  std::sort(data_points.begin(),
57  data_points.end(),
58  [](const DataPoint &a, const DataPoint &b) { return (a.y > b.y); });
59 
60  Trace new_trace;
61 
62  for(auto &data_point : data_points)
63  {
64  if(notExcluded(exclusionMassMap, data_point.x))
65  {
66  new_trace.push_back(data_point);
67  }
68  addExclusionMap(exclusionMassMap, data_point.x);
69  }
70  new_trace.sortX();
71  // qDebug() << new_trace.size();
72  data_points = std::move(new_trace);
73  // qDebug() << data_points.size();
74  return data_points;
75 }
76 
77 bool
79  std::vector<std::pair<double, double>> &exclusionMassMap, double mass) const
80 {
81  for(auto &mass_range : exclusionMassMap)
82  {
83  if((mass_range.first <= mass) && (mass_range.second >= mass))
84  {
85  return false;
86  }
87  }
88  return true;
89 }
90 
91 void
93  std::vector<std::pair<double, double>> &exclusionMassMap, double mass) const
94 {
95  MzRange range1(mass + m_diffC12C13_z1, m_precisionPtr);
96 
97  exclusionMassMap.push_back(
98  std::pair<double, double>(range1.lower(), range1.upper()));
99 
100 
101  MzRange range2(mass + m_diffC12C13_z2, m_precisionPtr);
102 
103  exclusionMassMap.push_back(
104  std::pair<double, double>(range2.lower(), range2.upper()));
105 }
void addExclusionMap(std::vector< std::pair< double, double >> &exclusionMassMap, double mass) const
bool notExcluded(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()
Definition: trace.cpp:956
sum peaks under a triangle base
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
const pappso_double DIFFC12C13(1.0033548378)