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>
32
33using namespace pappso;
34
35FilterMzExclusion::FilterMzExclusion(const QString &strBuildParams)
36{
37 buildFilterFromString(strBuildParams);
38}
39
44
49
53
54void
56{
57 qDebug();
58 if(strBuildParams.startsWith("mzExclusion|"))
59 {
60 QStringList params = strBuildParams.split("|").back().split(";", Qt::SkipEmptyParts);
61
62 QString precision = params.at(0);
64 precision.replace("dalton", " dalton").replace("ppm", " ppm").replace("res", " res"));
65 }
66 else
67 {
69 QString("building mzExclusion from string %1 is not possible").arg(strBuildParams));
70 }
71 qDebug();
72}
73
76{
77 qDebug();
78 qDebug() << "before" << data_points.size();
80
81 Trace new_trace = removeTraceInExclusionMargin(data_points);
82 new_trace.sortX();
83 data_points = std::move(new_trace);
84 qDebug() << "after" << data_points.size();
85 qDebug();
86 return data_points;
87}
88
89QString
91{
92 return "mzExclusion";
93}
94
95
96QString
98{
99 QString strCode = QString("%1|%2").arg(name()).arg(m_exclusionPrecision->toString());
100
101 strCode.replace(" ", "");
102
103 return strCode;
104}
105
108{
109 Trace new_trace;
110 std::vector<MzRange> excluded_ranges;
111
112 for(auto &data_point : points)
113 {
114 auto exclude_index = excluded_ranges.begin(), end = excluded_ranges.end();
115
116 exclude_index = std::find_if(exclude_index, end, [&data_point](MzRange range) {
117 return (data_point.x >= range.lower() && data_point.x <= range.upper());
118 });
119 if(exclude_index == end)
120 {
121 new_trace.push_back(data_point);
122 MzRange new_range(data_point.x, m_exclusionPrecision);
123 excluded_ranges.push_back(new_range);
124 }
125 }
126
127 return new_trace;
128}
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:152
void sortY(Enums::SortOrder sort_order=Enums::SortOrder::ascending)
Definition trace.cpp:1081
void sortX(Enums::SortOrder sort_order=Enums::SortOrder::ascending)
Definition trace.cpp:1071
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