libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
filtercomplement.cpp
Go to the documentation of this file.
1/**
2 * \file core/filter/filtercomplement.cpp
3 * \date 24/09/2026
4 * \author Olivier Langella
5 * \brief filter for complement ions
6 */
7
8
9/*
10 * PeptidOMS, Spectra to protein alignment tool
11 * Copyright (C) 2026 Olivier Langella
12 * <olivier.langella@cnrs.fr>
13 *
14 * This program is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 *
27 */
28#include "filtercomplement.h"
30#include <qlogging.h>
31#include <utility>
32
34 : m_targetMzSum(target_mz), m_precisionPtr(precision_ptr)
35{
36}
37
38
39/**
40 * Copy constructor
41 *
42 * @param other TODO
43 */
48
52
55{
56 pappso::Trace new_trace;
57 if(data_points.size() < 2)
58 return data_points;
60
61
62 auto it = data_points.begin();
63 auto it_reverse = data_points.rbegin();
64 while(it->x < it_reverse->x)
65 {
66
67 if((it->x + it_reverse->x) < target_sum.lower())
68 {
69 it++;
70 }
71 else if((it->x + it_reverse->x) > target_sum.upper())
72 {
73 it_reverse++;
74 }
75 else
76 {
77 new_trace.push_back(*it);
78 qDebug() << "itx=" << it->x;
79 do
80 {
81 new_trace.push_back(*it_reverse);
82 qDebug() << "itrevx=" << it_reverse->x;
83 it_reverse++;
84 }
85 while(target_sum.contains(it->x + it_reverse->x));
86 }
87 }
88
89 data_points = std::move(new_trace);
90 data_points.sortX();
91 return data_points;
92}
pappso::Trace & filter(pappso::Trace &data_points) const override
pappso::PrecisionPtr m_precisionPtr
FilterComplement(double target_mz, pappso::PrecisionPtr precision_ptr)
pappso_double lower() const
Definition mzrange.h:71
pappso_double upper() const
Definition mzrange.h:77
bool contains(pappso_double) const
Definition mzrange.cpp:115
A simple container of DataPoint instances.
Definition trace.h:152
void sortX(Enums::SortOrder sort_order=Enums::SortOrder::ascending)
Definition trace.cpp:1070
const PrecisionBase * PrecisionPtr
Definition precision.h:122