libpappsomspp
Library for mass spectrometry
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 
29 
30 using namespace pappso;
31 
33  double target_mz, PrecisionPtr precision_ptr)
34  : m_targetMzSum(target_mz), m_precisionPtr(precision_ptr)
35 {
36 }
37 
39  const FilterComplementIonEnhancer &other)
40  : m_targetMzSum(other.m_targetMzSum), m_precisionPtr(other.m_precisionPtr)
41 {
42 }
43 
45  const pappso::QualifiedMassSpectrum &qmass_spectrum,
46  pappso::PrecisionPtr precision_ptr)
47  : m_targetMzSum(((qmass_spectrum.getPrecursorMz() -
48  (qmass_spectrum.getPrecursorCharge() * MHPLUS /
49  qmass_spectrum.getPrecursorCharge())) *
50  qmass_spectrum.getPrecursorCharge() +
51  (MHPLUS + MHPLUS))),
52  m_precisionPtr(precision_ptr)
53 {
54 }
55 
57 {
58 }
59 
62 {
63 
64  auto it_end = data_points.end();
65  std::sort(data_points.begin(),
66  it_end,
67  [](const DataPoint &a, const DataPoint &b) { return (a.y > b.y); });
68 
69  for(auto it = data_points.begin(); it != it_end; it++)
70  {
71  double mz_complement = m_targetMzSum - it->x;
72  if(mz_complement > 0)
73  {
74  MzRange mz_range(mz_complement, m_precisionPtr);
75  enhanceComplementMassInRange(
76  it->y, mz_range.lower(), mz_range.upper(), it, it_end);
77  }
78  }
79 
80  data_points.sortX();
81  return data_points;
82 }
83 
84 
85 void
87  double new_intensity,
88  double mz_lower_bound,
89  double mz_upper_bound,
90  std::vector<DataPoint>::iterator it_begin,
91  std::vector<DataPoint>::iterator it_end) const
92 {
93  for(std::vector<DataPoint>::iterator it = it_begin; it != it_end; it++)
94  {
95  if((it->x >= mz_lower_bound) && (it->x <= mz_upper_bound))
96  {
97  if(it->y < new_intensity)
98  {
99  it->y = new_intensity;
100  }
101  }
102  }
103 }
pappso::MzRange::lower
pappso_double lower() const
Definition: mzrange.h:114
pappso::FilterComplementIonEnhancer::enhanceComplementMassInRange
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
Definition: filtercomplementionenhancer.cpp:86
pappso::MHPLUS
const pappso_double MHPLUS(1.007276466879)
pappso::MzRange::upper
pappso_double upper() const
Definition: mzrange.h:120
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks
Definition: aa.cpp:39
pappso::PeptideIonNter::a
@ a
pappso::FilterComplementIonEnhancer
try to detect complementary ions and assign maximum intensity of both elements
Definition: filtercomplementionenhancer.h:64
pappso::DataPoint
Definition: datapoint.h:21
pappso::FilterComplementIonEnhancer::~FilterComplementIonEnhancer
virtual ~FilterComplementIonEnhancer()
Definition: filtercomplementionenhancer.cpp:56
pappso::MzRange
Definition: mzrange.h:67
pappso::Trace
A simple container of DataPoint instances.
Definition: trace.h:132
pappso::QualifiedMassSpectrum
Class representing a fully specified mass spectrum.
Definition: qualifiedmassspectrum.h:86
pappso::FilterComplementIonEnhancer::filter
Trace & filter(Trace &data_points) const override
Definition: filtercomplementionenhancer.cpp:61
pappso::Trace::sortX
void sortX()
Definition: trace.cpp:748
pappso::PrecisionBase
Definition: precision.h:65
filtercomplementionenhancer.h
enhance ion intensity of ion fragment complement
pappso::PeptideIonNter::b
@ b
pappso::FilterComplementIonEnhancer::FilterComplementIonEnhancer
FilterComplementIonEnhancer(double target_mz, PrecisionPtr precision_ptr)
Definition: filtercomplementionenhancer.cpp:32