Loading...
Searching...
No Matches
filtercomplementionenhancer.cpp
Go to the documentation of this file.
/**
* \file pappsomspp/processing/filters/filtercomplementionenhancer.cpp
* \date 21/08/2020
* \author Olivier Langella
* \brief enhance ion intensity of ion fragment complement
*/
/*******************************************************************************
* Copyright (c) 2020 Olivier Langella <Olivier.Langella@u-psud.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/>.
*
******************************************************************************/
#include "filtercomplementionenhancer.h"
#include "../../exception/exceptionnotrecognized.h"
using namespace pappso;
FilterComplementIonEnhancer::FilterComplementIonEnhancer(
double target_mz, PrecisionPtr precision_ptr)
: m_targetMzSum(target_mz), m_precisionPtr(precision_ptr)
{
}
FilterComplementIonEnhancer::FilterComplementIonEnhancer(
const FilterComplementIonEnhancer &other)
: m_targetMzSum(other.m_targetMzSum), m_precisionPtr(other.m_precisionPtr)
{
}
pappso::FilterComplementIonEnhancer::FilterComplementIonEnhancer(
const pappso::QualifiedMassSpectrum &qmass_spectrum,
pappso::PrecisionPtr precision_ptr)
: m_targetMzSum(((qmass_spectrum.getPrecursorMz() -
(qmass_spectrum.getPrecursorCharge() * MHPLUS /
qmass_spectrum.getPrecursorCharge())) *
qmass_spectrum.getPrecursorCharge() +
(MHPLUS + MHPLUS))),
m_precisionPtr(precision_ptr)
{
}
pappso::FilterComplementIonEnhancer::FilterComplementIonEnhancer(
const QString &strBuildParams)
{
buildFilterFromString(strBuildParams);
}
void
pappso::FilterComplementIonEnhancer::buildFilterFromString(
const QString &strBuildParams)
{
//"complementIonEnhancer|456.567;0.02dalton"
if(strBuildParams.startsWith("complementIonEnhancer|"))
{
QStringList params = strBuildParams.split("|").back().split(";");
m_targetMzSum = params.at(0).toDouble();
QString precision = params.at(1);
m_precisionPtr =
PrecisionFactory::fromString(precision.replace("dalton", " dalton")
.replace("ppm", " ppm")
.replace("res", " res"));
}
else
{
throw pappso::ExceptionNotRecognized(
QString(
"building FilterComplementIonEnhancer from string %1 is not possible")
.arg(strBuildParams));
}
}
QString
pappso::FilterComplementIonEnhancer::name() const
{
return "complementIonEnhancer";
}
QString
pappso::FilterComplementIonEnhancer::toString() const
{
QString strCode = QString("%1|%2;%3")
.arg(name())
.arg(QString::number(m_targetMzSum, 'g', 15))
.arg(m_precisionPtr->toString());
strCode.replace(" ", "");
return strCode;
}
FilterComplementIonEnhancer::~FilterComplementIonEnhancer()
{
}
pappso::Trace &
pappso::FilterComplementIonEnhancer::filter(pappso::Trace &data_points) const
{
auto it_end = data_points.end();
std::sort(data_points.begin(),
it_end,
[](const DataPoint &a, const DataPoint &b) { return (a.y > b.y); });
for(auto it = data_points.begin(); it != it_end; it++)
{
double mz_complement = m_targetMzSum - it->x;
if(mz_complement > 0)
{
MzRange mz_range(mz_complement, m_precisionPtr);
enhanceComplementMassInRange(
it->y, mz_range.lower(), mz_range.upper(), it, it_end);
}
}
data_points.sortX();
return data_points;
}
void
pappso::FilterComplementIonEnhancer::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
{
for(std::vector<DataPoint>::iterator it = it_begin; it != it_end; it++)
{
if((it->x >= mz_lower_bound) && (it->x <= mz_upper_bound))
{
if(it->y < new_intensity)
{
it->y = new_intensity;
}
}
}
}
pappso::ExceptionNotRecognized
excetion to use when an item type is not recognized
Definition exceptionnotrecognized.h:42
pappso::FilterComplementIonEnhancer
try to detect complementary ions and assign maximum intensity of both elements
Definition filtercomplementionenhancer.h:47
pappso::FilterComplementIonEnhancer::buildFilterFromString
void buildFilterFromString(const QString &strBuildParams) override
build this filter using a string
Definition filtercomplementionenhancer.cpp:64
pappso::FilterComplementIonEnhancer::~FilterComplementIonEnhancer
virtual ~FilterComplementIonEnhancer()
Definition filtercomplementionenhancer.cpp:108
pappso::FilterComplementIonEnhancer::toString
QString toString() const override
Definition filtercomplementionenhancer.cpp:97
pappso::FilterComplementIonEnhancer::filter
Trace & filter(Trace &data_points) const override
Definition filtercomplementionenhancer.cpp:113
pappso::FilterComplementIonEnhancer::FilterComplementIonEnhancer
FilterComplementIonEnhancer(double target_mz, PrecisionPtr precision_ptr)
Definition filtercomplementionenhancer.cpp:33
pappso::FilterComplementIonEnhancer::name
QString name() const override
Definition filtercomplementionenhancer.cpp:90
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:138
pappso::MzRange
Definition mzrange.h:46
pappso::MzRange::lower
pappso_double lower() const
Definition mzrange.h:71
pappso::MzRange::upper
pappso_double upper() const
Definition mzrange.h:77
pappso::PrecisionBase
Definition precision.h:44
pappso::PrecisionFactory::fromString
static PrecisionPtr fromString(const QString &str)
get a precision pointer from a string
Definition precision.cpp:72
pappso::QualifiedMassSpectrum
Class representing a fully specified mass spectrum.
Definition qualifiedmassspectrum.h:93
pappso::Trace
A simple container of DataPoint instances.
Definition trace.h:148
pappso::Trace::sortX
void sortX(SortOrder sort_order=SortOrder::ascending)
Definition trace.cpp:1086
filtercomplementionenhancer.h
enhance ion intensity of ion fragment complement
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::PeptideIonNter::a
@ a
pappso::PeptideIonNter::b
@ b
pappso::MHPLUS
const pappso_double MHPLUS(1.007276466879)
pappso::DataPoint
Definition datapoint.h:22