libpappsomspp
Library for mass spectrometry
tracepeak.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 
25 #include <cmath>
26 #include "tracepeak.h"
27 #include "../../trace/trace.h"
28 
29 namespace pappso
30 {
32 {
33 }
34 
35 TracePeak::TracePeak(std::vector<DataPoint>::const_iterator it_begin,
36  std::vector<DataPoint>::const_iterator it_end)
37 {
38 
39  m_left = *it_begin;
40  m_right = *(it_end - 1);
41  m_max = *maxYDataPoint(it_begin, it_end);
42  m_area = areaTrace(it_begin, it_end);
43 }
44 
45 TracePeak::TracePeak(std::vector<DataPoint>::const_iterator it_begin,
46  std::vector<DataPoint>::const_iterator it_end,
47  bool remove_base)
48 {
49 
50  m_left = *it_begin;
51  m_right = *(it_end - 1);
52  m_max = *maxYDataPoint(it_begin, it_end);
53  m_area = areaTrace(it_begin, it_end);
54  if(remove_base)
55  {
56  // remove the base of this peak
57  m_area -= std::min(m_left.y, m_right.y) * (m_right.x - m_left.x);
58  if(m_area < 0)
59  m_area = 0;
60  }
61 }
62 
64 {
65  m_area = other.m_area;
66  m_left = other.m_left;
67  m_right = other.m_right;
68  m_max = other.m_max;
69 }
70 
72 {
73 }
74 
75 
78 {
79  return std::make_shared<const TracePeak>(*this);
80 }
81 
82 DataPoint &
84 {
85  return m_max;
86 };
87 void
89 {
90  m_max = max;
91 };
92 DataPoint &
94 {
95  return m_left;
96 };
97 void
99 {
100  m_left = left;
101 };
102 
103 DataPoint &
105 {
106  return m_right;
107 };
108 const DataPoint &
110 {
111  return m_right;
112 };
113 void
115 {
116  m_right = right;
117 };
120 {
121  return m_area;
122 };
123 void
125 {
126  m_area = area;
127 };
128 
129 bool
131 {
132  if((rt >= m_left.x) && (rt <= m_right.x))
133  {
134  return (true);
135  }
136  return (false);
137 }
138 
139 
140 const DataPoint &
142 {
143  return m_max;
144 }
145 
146 const DataPoint &
148 {
149  return m_left;
150 }
151 
152 
153 bool
154 TracePeak::operator==(const TracePeak &other) const
155 {
156  return ((m_area == other.m_area) && (m_max == other.m_max) &&
157  (m_left == other.m_left) && (m_right == other.m_right));
158 }
159 
160 TracePeak &
162 {
163  if(this == &other)
164  return *this;
165 
166  m_area = other.m_area;
167  m_max = other.m_max;
168  m_left = other.m_left;
169  m_right = other.m_right;
170 
171  return *this;
172 }
173 } // namespace pappso
DataPoint & getLeftBoundary()
Definition: tracepeak.cpp:93
void setLeftBoundary(const DataPoint &left)
Definition: tracepeak.cpp:98
pappso_double getArea() const
Definition: tracepeak.cpp:119
bool operator==(const TracePeak &other) const
Definition: tracepeak.cpp:154
TracePeak & operator=(const TracePeak &other)
Definition: tracepeak.cpp:161
void setArea(pappso_double area)
Definition: tracepeak.cpp:124
DataPoint m_left
Definition: tracepeak.h:90
TracePeakCstSPtr makeTracePeakCstSPtr() const
Definition: tracepeak.cpp:77
void setRightBoundary(const DataPoint &right)
Definition: tracepeak.cpp:114
DataPoint m_max
Definition: tracepeak.h:89
DataPoint m_right
Definition: tracepeak.h:91
pappso_double m_area
Definition: tracepeak.h:88
bool containsRt(pappso::pappso_double rt) const
Definition: tracepeak.cpp:130
DataPoint & getMaxXicElement()
Definition: tracepeak.cpp:83
DataPoint & getRightBoundary()
Definition: tracepeak.cpp:104
void setMaxXicElement(const DataPoint &max)
Definition: tracepeak.cpp:88
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
std::vector< DataPoint >::const_iterator maxYDataPoint(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
Definition: trace.cpp:180
double areaTrace(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
calculate the area of a trace
Definition: trace.cpp:309
double pappso_double
A type definition for doubles.
Definition: types.h:49
@ rt
Retention time.
std::shared_ptr< const TracePeak > TracePeakCstSPtr
Definition: tracepeak.h:34
@ max
maximum of intensities
pappso_double x
Definition: datapoint.h:23
pappso_double y
Definition: datapoint.h:24