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
40 : m_exclusionPrecision(precision_ptr)
41{
42}
43
45 : m_exclusionPrecision(other.m_exclusionPrecision)
46{
47}
48
52
53void
55{
56 qDebug();
57 if(strBuildParams.startsWith("mzExclusion|"))
58 {
59 QStringList params =
60 strBuildParams.split("|").back().split(";", Qt::SkipEmptyParts);
61
62 QString precision = params.at(0);
63 m_exclusionPrecision =
64 PrecisionFactory::fromString(precision.replace("dalton", " dalton")
65 .replace("ppm", " ppm")
66 .replace("res", " res"));
67 }
68 else
69 {
71 QString("building mzExclusion from string %1 is not possible")
72 .arg(strBuildParams));
73 }
74 qDebug();
75}
76
79{
80 qDebug();
81 qDebug() << "before" << data_points.size();
82 data_points.sortY(SortOrder::descending);
83
84 Trace new_trace = removeTraceInExclusionMargin(data_points);
85 new_trace.sortX();
86 data_points = std::move(new_trace);
87 qDebug() << "after" << data_points.size();
88 qDebug();
89 return data_points;
90}
91
92QString
94{
95 return "mzExclusion";
96}
97
98
99QString
101{
102 QString strCode =
103 QString("%1|%2").arg(name()).arg(m_exclusionPrecision->toString());
104
105 strCode.replace(" ", "");
106
107 return strCode;
108}
109
112 pappso::Trace &points) const
113{
114 Trace new_trace;
115 std::vector<MzRange> excluded_ranges;
116
117 for(auto &data_point : points)
118 {
119 auto exclude_index = excluded_ranges.begin(), end = excluded_ranges.end();
120
121 exclude_index =
122 std::find_if(exclude_index, end, [&data_point](MzRange range) {
123 return (data_point.x >= range.lower() &&
124 data_point.x <= range.upper());
125 });
126 if(exclude_index == end)
127 {
128 new_trace.push_back(data_point);
129 MzRange new_range(data_point.x, m_exclusionPrecision);
130 excluded_ranges.push_back(new_range);
131 }
132 }
133
134 return new_trace;
135}
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:72
A simple container of DataPoint instances.
Definition trace.h:148
void sortX(SortOrder sort_order=SortOrder::ascending)
Definition trace.cpp:1086
void sortY(SortOrder sort_order=SortOrder::ascending)
Definition trace.cpp:1100
excetion to use when an item type is not recognized (file format, object type...)
Delete small peaks in the exclusion range.
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39