libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
filterexclusionmz.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/filters/filterexclusionmz.cpp
3 * \date 09/02/2021
4 * \author Thomas Renne
5 * \brief Delete small peaks in the exclusion range
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2021 Thomas Renne <thomas.renne@e.email>.
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 "filterexclusionmz.h"
29#include <QDebug>
31
32using namespace pappso;
33
34FilterMzExclusion::FilterMzExclusion(const QString &strBuildParams)
35{
36 buildFilterFromString(strBuildParams);
37}
38
43
48
52
53void
55{
56 qDebug();
57 if(strBuildParams.startsWith("mzExclusion|"))
58 {
59 QStringList params = strBuildParams.split("|").back().split(";", Qt::SkipEmptyParts);
60
61 QString precision = params.at(0);
63 precision.replace("dalton", " dalton").replace("ppm", " ppm").replace("res", " res"));
64 }
65 else
66 {
68 QString("building mzExclusion from string %1 is not possible").arg(strBuildParams));
69 }
70 qDebug();
71}
72
75{
76 qDebug();
77 qDebug() << "before" << data_points.size();
79
80 Trace new_trace = removeTraceInExclusionMargin(data_points);
81 new_trace.sortX();
82 data_points = std::move(new_trace);
83 qDebug() << "after" << data_points.size();
84 qDebug();
85 return data_points;
86}
87
88QString
90{
91 return "mzExclusion";
92}
93
94
95QString
97{
98 QString strCode = QString("%1|%2").arg(name()).arg(m_exclusionPrecision->toString());
99
100 strCode.replace(" ", "");
101
102 return strCode;
103}
104
107{
108 Trace new_trace;
109 std::vector<MzRange> excluded_ranges;
110
111 for(auto &data_point : points)
112 {
113 auto exclude_index = excluded_ranges.begin(), end = excluded_ranges.end();
114
115 exclude_index = std::find_if(exclude_index, end, [&data_point](MzRange range) {
116 return (data_point.x >= range.lower() && data_point.x <= range.upper());
117 });
118 if(exclude_index == end)
119 {
120 new_trace.push_back(data_point);
121 MzRange new_range(data_point.x, m_exclusionPrecision);
122 excluded_ranges.push_back(new_range);
123 }
124 }
125
126 return new_trace;
127}
excetion to use when an item type is not recognized
void buildFilterFromString(const QString &strBuildParams) override
build this filter using a string
QString toString() const override
Trace & filter(Trace &data_points) const override
get all the datapoints and remove different isotope and add their intensity and change to charge = 1 ...
Trace removeTraceInExclusionMargin(Trace &points) const
FilterMzExclusion(PrecisionPtr precision_ptr)
QString name() const override
pappso_double lower() const
Definition mzrange.h:71
pappso_double upper() const
Definition mzrange.h:77
static PrecisionPtr fromString(const QString &str)
get a precision pointer from a string
Definition precision.cpp:80
A simple container of DataPoint instances.
Definition trace.h:148
void sortY(Enums::SortOrder sort_order=Enums::SortOrder::ascending)
Definition trace.cpp:1049
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