libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
filtercomplementionenhancer.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/filters/filtercomplementionenhancer.cpp
3 * \date 21/08/2020
4 * \author Olivier Langella
5 * \brief enhance ion intensity of ion fragment complement
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2020 Olivier Langella <Olivier.Langella@u-psud.fr>.
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
30
31using namespace pappso;
32
34 PrecisionPtr precision_ptr)
35 : m_targetMzSum(target_mz), m_precisionPtr(precision_ptr)
36{
37}
38
43
45 const pappso::QualifiedMassSpectrum &qmass_spectrum, pappso::PrecisionPtr precision_ptr)
47 ((qmass_spectrum.getPrecursorMz() -
48 (qmass_spectrum.getPrecursorCharge() * MHPLUS / qmass_spectrum.getPrecursorCharge())) *
49 qmass_spectrum.getPrecursorCharge() +
50 (MHPLUS + MHPLUS))),
51 m_precisionPtr(precision_ptr)
52{
53}
54
56{
57 buildFilterFromString(strBuildParams);
58}
59
60void
62{
63 //"complementIonEnhancer|456.567;0.02dalton"
64 if(strBuildParams.startsWith("complementIonEnhancer|"))
65 {
66 QStringList params = strBuildParams.split("|").back().split(";");
67
68 m_targetMzSum = params.at(0).toDouble();
69 QString precision = params.at(1);
71 precision.replace("dalton", " dalton").replace("ppm", " ppm").replace("res", " res"));
72 }
73 else
74 {
76 QString("building FilterComplementIonEnhancer from string %1 is not possible")
77 .arg(strBuildParams));
78 }
79}
80
81
82QString
84{
85 return "complementIonEnhancer";
86}
87
88
89QString
91{
92 QString strCode = QString("%1|%2;%3")
93 .arg(name())
94 .arg(QString::number(m_targetMzSum, 'g', 15))
95 .arg(m_precisionPtr->toString());
96 strCode.replace(" ", "");
97
98 return strCode;
99}
100
104
107{
108
109 auto it_end = data_points.end();
110 std::sort(data_points.begin(), it_end, [](const DataPoint &a, const DataPoint &b) {
111 return (a.y > b.y);
112 });
113
114 for(auto it = data_points.begin(); it != it_end; it++)
115 {
116 double mz_complement = m_targetMzSum - it->x;
117 if(mz_complement > 0)
118 {
119 MzRange mz_range(mz_complement, m_precisionPtr);
120 enhanceComplementMassInRange(it->y, mz_range.lower(), mz_range.upper(), it, it_end);
121 }
122 }
123
124 data_points.sortX();
125 return data_points;
126}
127
128
129void
131 double new_intensity,
132 double mz_lower_bound,
133 double mz_upper_bound,
134 std::vector<DataPoint>::iterator it_begin,
135 std::vector<DataPoint>::iterator it_end) const
136{
137 for(std::vector<DataPoint>::iterator it = it_begin; it != it_end; it++)
138 {
139 if((it->x >= mz_lower_bound) && (it->x <= mz_upper_bound))
140 {
141 if(it->y < new_intensity)
142 {
143 it->y = new_intensity;
144 }
145 }
146 }
147}
excetion to use when an item type is not recognized
void buildFilterFromString(const QString &strBuildParams) override
build this filter using a string
Trace & filter(Trace &data_points) const override
FilterComplementIonEnhancer(double target_mz, PrecisionPtr precision_ptr)
void enhanceComplementMassInRange(double new_intensity, double mz_lower_bound, double mz_upper_bound, std::vector< DataPoint >::iterator it_begin, std::vector< DataPoint >::iterator it_end) const
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
Class representing a fully specified mass spectrum.
A simple container of DataPoint instances.
Definition trace.h:152
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 pappso_double MHPLUS(1.007276466879)
const PrecisionBase * PrecisionPtr
Definition precision.h:122