pappsomspp
Library for mass spectrometry
filtertandemremovec13.cpp
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/filers/filtertandemremovec13.h
3  * \date 26/04/2019
4  * \author Olivier Langella
5  * \brief new implementation of the X!Tandem filter to remove isotopes in an MS2
6  * signal
7  */
8 
9 /*******************************************************************************
10  * Copyright (c) 2019 Olivier Langella <Olivier.Langella@u-psud.fr>.
11  *
12  * This file is part of the PAPPSOms++ library.
13  *
14  * PAPPSOms++ is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation, either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * PAPPSOms++ is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
26  *
27  ******************************************************************************/
28 
29 #include "filtertandemremovec13.h"
30 
31 #include "../../massspectrum/massspectrum.h"
32 #include <algorithm>
33 
34 using namespace pappso;
35 
37 {
38 }
39 
40 
42 {
43 }
44 
47 {
48 
49  // Reverse-sort the data points (in y decreasing order) so that we get the
50  // greatest to the front of the vector and we'll then copy the first n data
51  // points to the returned vector. See that return (b < a) ?
52 
53  MassSpectrum massSpectrum;
54  if(data_points.size() > 0)
55  {
56  auto it = data_points.begin();
57  auto itNext = data_points.begin() + 1;
58  auto itEnd = data_points.end();
59 
60  pappso_double prevMz = it->x;
61 
62  while(itNext != itEnd)
63  {
64  if((itNext->x - prevMz) >= m_arbitrary_range_between_isotopes ||
65  itNext->x < m_arbitrary_minimum_mz)
66  {
67  massSpectrum.push_back(*it);
68  it = itNext;
69  prevMz = it->x;
70  }
71  else if(itNext->y > it->y)
72  {
73  it = itNext;
74  }
75 
76  itNext++;
77  }
78  massSpectrum.push_back(*it);
79  }
80 
81  data_points = std::move(massSpectrum);
82  return data_points;
83 }
84 
85 
87 {
88 }
89 
90 
92 {
93 }
94 
97 {
98 
99  MassSpectrum massSpectrum;
100 
101  if(data_points.size() > 0)
102  {
103  auto it = data_points.begin() + 1;
104  auto itEnd = data_points.end();
105 
106  DataPoint dataPoint = data_points.at(0);
107 
108  while(it != itEnd)
109  {
110  if((it->x < m_arbitrary_minimum_mz) ||
111  ((it->x - dataPoint.x) >= m_arbitrary_range_between_isotopes))
112  {
113  massSpectrum.push_back(dataPoint);
114  dataPoint = *it;
115  }
116  else if(it->y > dataPoint.y)
117  {
118  dataPoint = *it;
119  }
120 
121  it++;
122  }
123  }
124 
125  data_points = std::move(massSpectrum);
126  return data_points;
127 }
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition: types.h:67
filtertandemremovec13.h
pappso::FilterTandemDeisotope::m_arbitrary_range_between_isotopes
double m_arbitrary_range_between_isotopes
Definition: filtertandemremovec13.h:87
pappso::FilterTandemRemoveC13::filter
MassSpectrum & filter(MassSpectrum &data_points) const override
Definition: filtertandemremovec13.cpp:46
pappso::DataPoint::y
pappso_double y
Definition: datapoint.h:23
pappso
Definition: aa.cpp:38
pappso::MassSpectrum
Class to represent a mass spectrum.
Definition: massspectrum.h:89
pappso::DataPoint
Definition: datapoint.h:20
pappso::FilterTandemRemoveC13::FilterTandemRemoveC13
FilterTandemRemoveC13()
Definition: filtertandemremovec13.cpp:36
pappso::FilterTandemDeisotope::m_arbitrary_minimum_mz
double m_arbitrary_minimum_mz
Definition: filtertandemremovec13.h:88
pappso::FilterTandemRemoveC13
clean probable C13 isotopes as in X!Tandem algorithm
Definition: filtertandemremovec13.h:56
pappso::FilterTandemRemoveC13::m_arbitrary_minimum_mz
double m_arbitrary_minimum_mz
Definition: filtertandemremovec13.h:77
pappso::DataPoint::x
pappso_double x
Definition: datapoint.h:22
pappso::FilterTandemDeisotope::filter
MassSpectrum & filter(MassSpectrum &data_points) const override
Definition: filtertandemremovec13.cpp:96
pappso::FilterTandemDeisotope::FilterTandemDeisotope
FilterTandemDeisotope()
Definition: filtertandemremovec13.cpp:86
pappso::FilterTandemRemoveC13::m_arbitrary_range_between_isotopes
double m_arbitrary_range_between_isotopes
Definition: filtertandemremovec13.h:76
pappso::FilterTandemDeisotope
Deisotope the mass spectrum this mass spectrum is iterated over and according to a data point-based m...
Definition: filtertandemremovec13.h:84