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 pappso::PrecisionPtr precision_ptr)
35 : m_targetMzSum(target_mz), m_precisionPtr(precision_ptr)
36{
37}
38
39
40/**
41 * Copy constructor
42 *
43 * @param other TODO
44 */
49
53
56{
57 pappso::Trace new_trace;
59
60
61 auto it = data_points.begin();
62 auto it_reverse = data_points.rbegin();
63 while(it->x < it_reverse->x)
64 {
65
66 if((it->x + it_reverse->x) < target_sum.lower())
67 {
68 it++;
69 }
70 else if((it->x + it_reverse->x) > target_sum.upper())
71 {
72 it_reverse++;
73 }
74 else
75 {
76 new_trace.push_back(*it);
77 qDebug() << "itx=" << it->x;
78 do
79 {
80 new_trace.push_back(*it_reverse);
81 qDebug() << "itrevx=" << it_reverse->x;
82 it_reverse++;
83 }
84 while(target_sum.contains(it->x + it_reverse->x));
85 }
86 }
87
88 data_points = std::move(new_trace);
89 data_points.sortX();
90 return data_points;
91}
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