Loading...
Searching...
No Matches
tracepeak.cpp
Go to the documentation of this file.
/*******************************************************************************
* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
*
* This file is part of the PAPPSOms++ library.
*
* PAPPSOms++ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAPPSOms++ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
*implementation
******************************************************************************/
#include <cmath>
#include "tracepeak.h"
#include "../../trace/trace.h"
namespace pappso
{
TracePeak::TracePeak()
{
}
TracePeak::TracePeak(std::vector<DataPoint>::const_iterator it_begin,
std::vector<DataPoint>::const_iterator it_end)
{
m_left = *it_begin;
m_right = *(it_end - 1);
m_max = *maxYDataPoint(it_begin, it_end);
m_area = areaTrace(it_begin, it_end);
}
TracePeak::TracePeak(std::vector<DataPoint>::const_iterator it_begin,
std::vector<DataPoint>::const_iterator it_end,
bool remove_base)
{
m_left = *it_begin;
m_right = *(it_end - 1);
m_max = *maxYDataPoint(it_begin, it_end);
m_area = areaTrace(it_begin, it_end);
if(remove_base)
{
// remove the base of this peak
m_area -= std::min(m_left.y, m_right.y) * (m_right.x - m_left.x);
if(m_area < 0)
m_area = 0;
}
}
TracePeak::TracePeak(const TracePeak &other)
{
m_area = other.m_area;
m_left = other.m_left;
m_right = other.m_right;
m_max = other.m_max;
}
TracePeak::~TracePeak()
{
}
TracePeakCstSPtr
TracePeak::makeTracePeakCstSPtr() const
{
return std::make_shared<const TracePeak>(*this);
}
DataPoint &
TracePeak::getMaxXicElement()
{
return m_max;
};
void
TracePeak::setMaxXicElement(const DataPoint &max)
{
m_max = max;
};
DataPoint &
TracePeak::getLeftBoundary()
{
return m_left;
};
void
TracePeak::setLeftBoundary(const DataPoint &left)
{
m_left = left;
};
DataPoint &
TracePeak::getRightBoundary()
{
return m_right;
};
const DataPoint &
TracePeak::getRightBoundary() const
{
return m_right;
};
void
TracePeak::setRightBoundary(const DataPoint &right)
{
m_right = right;
};
pappso_double
TracePeak::getArea() const
{
return m_area;
};
void
TracePeak::setArea(pappso_double area)
{
m_area = area;
};
bool
TracePeak::containsRt(pappso::pappso_double rt) const
{
if((rt >= m_left.x) && (rt <= m_right.x))
{
return (true);
}
return (false);
}
const DataPoint &
TracePeak::getMaxXicElement() const
{
return m_max;
}
const DataPoint &
TracePeak::getLeftBoundary() const
{
return m_left;
}
bool
TracePeak::operator==(const TracePeak &other) const
{
return ((m_area == other.m_area) && (m_max == other.m_max) &&
(m_left == other.m_left) && (m_right == other.m_right));
}
TracePeak &
TracePeak::operator=(const TracePeak &other)
{
if(this == &other)
return *this;
m_area = other.m_area;
m_max = other.m_max;
m_left = other.m_left;
m_right = other.m_right;
return *this;
}
} // namespace pappso
pappso::TracePeak
Definition tracepeak.h:40
pappso::TracePeak::TracePeak
TracePeak()
Definition tracepeak.cpp:31
pappso::TracePeak::getLeftBoundary
DataPoint & getLeftBoundary()
Definition tracepeak.cpp:93
pappso::TracePeak::setLeftBoundary
void setLeftBoundary(const DataPoint &left)
Definition tracepeak.cpp:98
pappso::TracePeak::getArea
pappso_double getArea() const
Definition tracepeak.cpp:119
pappso::TracePeak::operator==
bool operator==(const TracePeak &other) const
Definition tracepeak.cpp:154
pappso::TracePeak::operator=
TracePeak & operator=(const TracePeak &other)
Definition tracepeak.cpp:161
pappso::TracePeak::setArea
void setArea(pappso_double area)
Definition tracepeak.cpp:124
pappso::TracePeak::m_left
DataPoint m_left
Definition tracepeak.h:90
pappso::TracePeak::makeTracePeakCstSPtr
TracePeakCstSPtr makeTracePeakCstSPtr() const
Definition tracepeak.cpp:77
pappso::TracePeak::setRightBoundary
void setRightBoundary(const DataPoint &right)
Definition tracepeak.cpp:114
pappso::TracePeak::m_max
DataPoint m_max
Definition tracepeak.h:89
pappso::TracePeak::~TracePeak
~TracePeak()
Definition tracepeak.cpp:71
pappso::TracePeak::m_right
DataPoint m_right
Definition tracepeak.h:91
pappso::TracePeak::m_area
pappso_double m_area
Definition tracepeak.h:88
pappso::TracePeak::containsRt
bool containsRt(pappso::pappso_double rt) const
Definition tracepeak.cpp:130
pappso::TracePeak::getMaxXicElement
DataPoint & getMaxXicElement()
Definition tracepeak.cpp:83
pappso::TracePeak::getRightBoundary
DataPoint & getRightBoundary()
Definition tracepeak.cpp:104
pappso::TracePeak::setMaxXicElement
void setMaxXicElement(const DataPoint &max)
Definition tracepeak.cpp:88
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::maxYDataPoint
std::vector< DataPoint >::const_iterator maxYDataPoint(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
Definition trace.cpp:180
pappso::areaTrace
double areaTrace(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
calculate the area of a trace
Definition trace.cpp:309
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition types.h:50
pappso::DataKind::rt
@ rt
Retention time.
pappso::TracePeakCstSPtr
std::shared_ptr< const TracePeak > TracePeakCstSPtr
Definition tracepeak.h:35
pappso::XicExtractMethod::max
@ max
maximum of intensities
pappso::DataPoint
Definition datapoint.h:22
pappso::DataPoint::x
pappso_double x
Definition datapoint.h:23
pappso::DataPoint::y
pappso_double y
Definition datapoint.h:24
tracepeak.h