libpappsomspp
Library for mass spectrometry
tracedetectionmoulon.cpp
Go to the documentation of this file.
1 
2 /*******************************************************************************
3  * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
4  *
5  * This file is part of the PAPPSOms++ library.
6  *
7  * PAPPSOms++ is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * PAPPSOms++ is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
19  *
20  * Contributors:
21  * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
22  *implementation
23  ******************************************************************************/
24 #include "tracedetectionmoulon.h"
25 
26 namespace pappso
27 {
29  unsigned int smoothing_half_window_length,
30  pappso_double tic_start,
31  pappso_double tic_stop)
32  : m_xicFilterSmoothing(smoothing_half_window_length)
33 {
34  m_ticStart = tic_start;
35  m_ticStop = tic_stop;
36 }
37 
39  : m_xicFilterSmoothing(other.m_xicFilterSmoothing)
40 {
41  m_ticStart = other.m_ticStart;
42  m_ticStop = other.m_ticStop;
43 }
44 
46 {
47 }
48 
49 
50 void
52 {
53  m_xicFilterSmoothing = smooth;
54 }
55 
56 void
58 {
59  m_ticStart = tic_start;
60 }
61 void
63 {
64  m_ticStop = tic_stop;
65 }
66 
67 unsigned int
69 {
71 }
72 
75 {
76  return m_ticStart;
77 }
78 
81 {
82  return m_ticStop;
83 }
84 
85 void
87  TraceDetectionSinkInterface &sink) const
88 {
89 
90  Trace xic_smoothed(xic);
91 
92  m_xicFilterSmoothing.filter(xic_smoothed);
93 
94  // detect peaks :
95  bool banked(false);
96  unsigned int nb_tic_start(0);
97 
98  std::vector<DataPoint>::const_iterator it_smoothed;
99  std::vector<DataPoint>::const_iterator it, it_begin;
100 
101  // TracePeak *p_current_peak = nullptr;
102 
103  for(it_smoothed = xic_smoothed.begin(), it = xic.begin();
104  it_smoothed != xic_smoothed.end();
105  ++it_smoothed, ++it)
106  {
107 
108  if((nb_tic_start == 0) && (it_begin != xic.end()) && (banked == false))
109  {
110  // delete(p_current_peak);
111  // p_current_peak = nullptr;
112  it_begin = xic.end();
113  }
114 
115  if(it_smoothed->y >= m_ticStart)
116  {
117  nb_tic_start++;
118  if(it_begin == xic.end())
119  {
120  // p_current_peak = new TracePeak;
121  // p_current_peak->setLeftBoundary(*it_smoothed);
122  it_begin = it;
123  banked = false;
124  }
125  if((nb_tic_start == 2) && (banked == false))
126  {
127  banked = true;
128  }
129  }
130  else
131  {
132  nb_tic_start = 0;
133  }
134  if(it_smoothed->y <= m_ticStop)
135  {
136  if(it_begin != xic.end())
137  {
138 
139  if(banked)
140  {
141  TracePeak peak(it_begin, it + 1);
142  sink.setTracePeak(peak);
143  }
144  banked = false;
145  }
146  }
147  }
148 }
149 } // namespace pappso
mean filter apply mean of y values inside the window : this results in a kind of smoothing
Definition: filtermorpho.h:204
std::size_t getMeanHalfEdgeWindows() const
virtual Trace & filter(Trace &data_points) const override
void setTicStart(double tic_start)
void detect(const Trace &xic, TraceDetectionSinkInterface &sink) const override
void setFilterMorphoMean(const FilterMorphoMean &smooth)
unsigned int getSmoothingHalfEdgeWindows() const
TraceDetectionMoulon(unsigned int smoothing_half_window_length, pappso_double tic_start, pappso_double tic_stop)
virtual void setTracePeak(TracePeak &xic_peak)=0
A simple container of DataPoint instances.
Definition: trace.h:132
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
double pappso_double
A type definition for doubles.
Definition: types.h:48