Loading...
Searching...
No Matches
pappso::FilterChargeDeconvolution Class Reference

`#include <filterchargedeconvolution.h>`

Inheritance diagram for pappso::FilterChargeDeconvolution:

## Classes

struct | DataPointInfo

## Public Member Functions

| FilterChargeDeconvolution (PrecisionPtr precision_ptr)
| FilterChargeDeconvolution (const QString &strBuildParams)
| FilterChargeDeconvolution (const FilterChargeDeconvolution &other)
virtual | ~FilterChargeDeconvolution ()
Trace & | filter (Trace &data_points) const override
| get all the datapoints and remove different isotope and add their intensity and change to charge = 1 when the charge is known
virtual QString | name () const override
QString | toString () const override
Public Member Functions inherited from pappso::FilterNameInterface
virtual | ~FilterNameInterface ()
Public Member Functions inherited from pappso::FilterInterface
virtual | ~FilterInterface ()

## Protected Member Functions

void | buildFilterFromString (const QString &strBuildParams) override
| build this filter using a string

## Private Types

typedef std::shared_ptr< DataPointInfo > | DataPointInfoSp

## Private Member Functions

void | addDataPointToList (std::vector< FilterChargeDeconvolution::DataPointInfoSp > &points, DataPoint &data_point) const
| Add each datapoint to a vector of structure describe above.
void | addDataPointRefByExclusion (std::vector< FilterChargeDeconvolution::DataPointInfoSp > &points, FilterChargeDeconvolution::DataPointInfoSp &new_dpi) const
| For each datapointInfo add the datapoint to the lists by their exclusion range.
void | computeBestChargeOfDataPoint (std::vector< FilterChargeDeconvolution::DataPointInfoSp > &data_points_info) const
| Compare both list (z1 and z2) and add the right level of charge.
void | computeIsotopeDeconvolution (std::vector< FilterChargeDeconvolution::DataPointInfoSp > &data_points_info) const
| For eache datapointInfo whith no parent copy info in new vector with the intensity of the monoistipics peaks added.
void | transformToMonoChargedForAllDataPoint (std::vector< FilterChargeDeconvolution::DataPointInfoSp > &data_points_info) const
| For eache datapointInfo with a charge = 2 transform the peak to a charge = 1 by multiplying the mz by 2 and remove 1 H.

## Private Attributes

double | m_diffC12C13_z1
double | m_diffC12C13_z2
PrecisionPtr | m_precisionPtrZ1
PrecisionPtr | m_precisionPtrZ2

## Detailed Description

Definition at line 42 of file filterchargedeconvolution.h.

## Member Typedef Documentation

## DataPointInfoSp

typedef std::shared_ptr<DataPointInfo> pappso::FilterChargeDeconvolution::DataPointInfoSp

private

Definition at line 46 of file filterchargedeconvolution.h.

## Constructor & Destructor Documentation

## FilterChargeDeconvolution() [1/3]

FilterChargeDeconvolution::FilterChargeDeconvolution | ( | PrecisionPtr | precision_ptr | ) |

Default constructor

Definition at line 41 of file filterchargedeconvolution.cpp.

: m_precisionPtrZ1(precision_ptr)
{
m_diffC12C13_z1 = DIFFC12C13;
m_diffC12C13_z2 = DIFFC12C13 / 2;
m_precisionPtrZ1 = precision_ptr;
m_precisionPtrZ2 =
pappso::PrecisionFactory::getPrecisionPtrFractionInstance(m_precisionPtrZ1, 0.5);
// pappso::PrecisionFactory::getPrecisionDividedBy(m_precisionPtrZ1, 2):
// qInfo() << m_precisionPtrZ2->getNominal();
}
pappso::FilterChargeDeconvolution::m_diffC12C13_z1
double m_diffC12C13_z1
Definition filterchargedeconvolution.h:148
pappso::FilterChargeDeconvolution::m_precisionPtrZ2
PrecisionPtr m_precisionPtrZ2
Definition filterchargedeconvolution.h:151
pappso::FilterChargeDeconvolution::m_diffC12C13_z2
double m_diffC12C13_z2
Definition filterchargedeconvolution.h:149
pappso::FilterChargeDeconvolution::m_precisionPtrZ1
PrecisionPtr m_precisionPtrZ1
Definition filterchargedeconvolution.h:150
pappso::PrecisionFactory::getPrecisionPtrFractionInstance
static PrecisionPtr getPrecisionPtrFractionInstance(PrecisionPtr origin, double fraction)
get the fraction of an existing precision pointer
Definition precision.cpp:209
pappso::DIFFC12C13
const pappso_double DIFFC12C13(1.0033548378)

References pappso::DIFFC12C13(), pappso::PrecisionFactory::getPrecisionPtrFractionInstance(), m_diffC12C13_z1, m_diffC12C13_z2, m_precisionPtrZ1, and m_precisionPtrZ2.

Referenced by FilterChargeDeconvolution().

## FilterChargeDeconvolution() [2/3]

pappso::FilterChargeDeconvolution::FilterChargeDeconvolution | ( | const QString & | strBuildParams | ) |

Parameters

  strBuildParams | string to build the filter "chargeDeconvolution|0.02dalton"

Definition at line 34 of file filterchargedeconvolution.cpp.

{
buildFilterFromString(strBuildParams);
// qInfo() << "ChargeDeconvolution created";
}
pappso::FilterChargeDeconvolution::buildFilterFromString
void buildFilterFromString(const QString &strBuildParams) override
build this filter using a string
Definition filterchargedeconvolution.cpp:69

References buildFilterFromString().

## FilterChargeDeconvolution() [3/3]

FilterChargeDeconvolution::FilterChargeDeconvolution | ( | const FilterChargeDeconvolution & | other | ) |

Copy constructor

Parameters

  other | TODO

Definition at line 55 of file filterchargedeconvolution.cpp.

: m_precisionPtrZ1(other.m_precisionPtrZ1), m_precisionPtrZ2(other.m_precisionPtrZ2)
{
m_diffC12C13_z1 = DIFFC12C13;
m_diffC12C13_z2 = DIFFC12C13 / 2;
}

References FilterChargeDeconvolution(), pappso::DIFFC12C13(), m_diffC12C13_z1, m_diffC12C13_z2, m_precisionPtrZ1, and m_precisionPtrZ2.

## ~FilterChargeDeconvolution()

FilterChargeDeconvolution::~FilterChargeDeconvolution | ( |  | ) |

virtual

Destructor

Definition at line 62 of file filterchargedeconvolution.cpp.

{
qDebug() << "ChargeDeconvolution destroyed";
}

## Member Function Documentation

## addDataPointRefByExclusion()

void pappso::FilterChargeDeconvolution::addDataPointRefByExclusion | ( | std::vector< FilterChargeDeconvolution::DataPointInfoSp > & | points,
|  | FilterChargeDeconvolution::DataPointInfoSp & | new_dpi ) const

private

For each datapointInfo add the datapoint to the lists by their exclusion range.

Returns
  the vecotr of datapointInfo with their lists of isotopics peaks

Definition at line 163 of file filterchargedeconvolution.cpp.

{
// add datapoint which match the mz_range = 1 to z1_list
auto i_z1 = points.begin(), end = points.end();
while(i_z1 != end)
{
// get the datapoint which match the range
i_z1 = std::find_if(i_z1, end, [&new_dpi](DataPointInfoSp dpi) {
return (new_dpi->data_point.x >= dpi->z1_range.first &&
new_dpi->data_point.x <= dpi->z1_range.second);
});
if(i_z1 != end)
{
// add the datapoint to the list and add the parent pointer
i_z1->get()->z1_vect.push_back(new_dpi);
new_dpi->parent = *i_z1;
DataPointInfoSp parent_z1 = i_z1->get()->parent.lock();
while(parent_z1 != nullptr)
{
parent_z1.get()->z1_vect.push_back(new_dpi);
parent_z1 = parent_z1->parent.lock();
}
i_z1++;
}
}
// add datapoint which match the mz_range = 2 to z2_list
auto i_z2 = points.begin();
while(i_z2 != end)
{
// get the datapoint which match the range
i_z2 = std::find_if(i_z2, end, [&new_dpi](DataPointInfoSp dpi) {
return (new_dpi->data_point.x >= dpi->z2_range.first &&
new_dpi->data_point.x <= dpi->z2_range.second);
});
if(i_z2 != end)
{
// add the datapoint to the list and add the parent pointer
i_z2->get()->z2_vect.push_back(new_dpi);
new_dpi->parent = *i_z2;
DataPointInfoSp parent_z2 = i_z2->get()->parent.lock();
while(parent_z2 != nullptr)
{
parent_z2.get()->z2_vect.push_back(new_dpi);
parent_z2 = parent_z2->parent.lock();
}
i_z2++;
}
}
}
pappso::FilterChargeDeconvolution::DataPointInfoSp
std::shared_ptr< DataPointInfo > DataPointInfoSp
Definition filterchargedeconvolution.h:46
pappso::DataPoint::x
pappso_double x
Definition datapoint.h:24
pappso::FilterChargeDeconvolution::DataPointInfo::parent
std::weak_ptr< DataPointInfo > parent
Definition filterchargedeconvolution.h:60
pappso::FilterChargeDeconvolution::DataPointInfo::data_point
DataPoint data_point
Definition filterchargedeconvolution.h:52

Referenced by addDataPointToList().

## addDataPointToList()

void pappso::FilterChargeDeconvolution::addDataPointToList | ( | std::vector< FilterChargeDeconvolution::DataPointInfoSp > & | points,
|  | pappso::DataPoint & | data_point ) const

private

Add each datapoint to a vector of structure describe above.

Returns
  the vecotr of datapointInfo with their datapoint and their exclusion mass range

Definition at line 147 of file filterchargedeconvolution.cpp.

{
DataPointInfoSp new_dpi(std::make_shared<DataPointInfo>());
new_dpi->data_point = data_point;
MzRange range1(data_point.x + m_diffC12C13_z1, m_precisionPtrZ1);
new_dpi->z1_range = std::pair<double, double>(range1.lower(), range1.upper());
MzRange range2(data_point.x + m_diffC12C13_z2, m_precisionPtrZ2);
new_dpi->z2_range = std::pair<double, double>(range2.lower(), range2.upper());
addDataPointRefByExclusion(points, new_dpi);
points.push_back(new_dpi);
}
pappso::FilterChargeDeconvolution::addDataPointRefByExclusion
void addDataPointRefByExclusion(std::vector< FilterChargeDeconvolution::DataPointInfoSp > &points, FilterChargeDeconvolution::DataPointInfoSp &new_dpi) const
For each datapointInfo add the datapoint to the lists by their exclusion range.
Definition filterchargedeconvolution.cpp:163

References addDataPointRefByExclusion(), pappso::MzRange::lower(), m_diffC12C13_z1, m_diffC12C13_z2, m_precisionPtrZ1, m_precisionPtrZ2, pappso::MzRange::upper(), and pappso::DataPoint::x.

Referenced by filter().

## buildFilterFromString()

void pappso::FilterChargeDeconvolution::buildFilterFromString | ( | const QString & | strBuildParams | ) |

override protected virtual

build this filter using a string

Parameters

  strBuildParams | a string coding the filter and its parameters "filterName|param1;param2;param3"

Implements pappso::FilterNameInterface.

Definition at line 69 of file filterchargedeconvolution.cpp.

{
//"chargeDeconvolution|0.02dalton"
qDebug();
if(strBuildParams.startsWith("chargeDeconvolution|"))
{
QStringList params = strBuildParams.split("|").back().split(";", Qt::SkipEmptyParts);
QString precision = params.at(0);
m_precisionPtrZ1 = PrecisionFactory::fromString(
precision.replace("dalton", " dalton").replace("ppm", " ppm").replace("res", " res"));
qDebug();
m_precisionPtrZ2 =
pappso::PrecisionFactory::getPrecisionPtrFractionInstance(m_precisionPtrZ1, 0.5);
m_diffC12C13_z1 = DIFFC12C13;
m_diffC12C13_z2 = DIFFC12C13 / 2;
}
else
{
throw pappso::ExceptionNotRecognized(
QString("building chargeDeconvolution from string %1 is not possible").arg(strBuildParams));
}
qDebug();
}
pappso::PrecisionFactory::fromString
static PrecisionPtr fromString(const QString &str)
get a precision pointer from a string
Definition precision.cpp:80

References pappso::DIFFC12C13(), pappso::PrecisionFactory::fromString(), pappso::PrecisionFactory::getPrecisionPtrFractionInstance(), m_diffC12C13_z1, m_diffC12C13_z2, m_precisionPtrZ1, and m_precisionPtrZ2.

Referenced by FilterChargeDeconvolution().

## computeBestChargeOfDataPoint()

void pappso::FilterChargeDeconvolution::computeBestChargeOfDataPoint | ( | std::vector< FilterChargeDeconvolution::DataPointInfoSp > & | data_points_info | ) | const

private

Compare both list (z1 and z2) and add the right level of charge.

Returns
  the vecotr of datapointInfo with their charge

Definition at line 217 of file filterchargedeconvolution.cpp.

{
for(DataPointInfoSp &data_point_info : data_points_info)
{
if(data_point_info.get()->z1_vect.size() >= 1 && data_point_info.get()->z2_vect.size() == 0)
{
for(std::weak_ptr<DataPointInfo> other : data_point_info.get()->z1_vect)
{
other.lock()->z_charge = 1;
}
data_point_info.get()->z_charge = 1;
}
else if(data_point_info.get()->z1_vect.size() == 0 &&
data_point_info.get()->z2_vect.size() >= 1)
{
for(std::weak_ptr<DataPointInfo> other : data_point_info.get()->z2_vect)
{
other.lock()->z_charge = 2;
}
data_point_info.get()->z_charge = 2;
}
else if(data_point_info.get()->z1_vect.size() >= 1 &&
data_point_info.get()->z2_vect.size() >= 1)
{
for(std::weak_ptr<DataPointInfo> other : data_point_info.get()->z2_vect)
{
other.lock()->z_charge = 2;
}
data_point_info.get()->z_charge = 2;
}
else
{
if(data_point_info.get()->z_charge == -1)
{
data_point_info.get()->z_charge = 0;
}
}
}
}

Referenced by filter().

## computeIsotopeDeconvolution()

void pappso::FilterChargeDeconvolution::computeIsotopeDeconvolution | ( | std::vector< FilterChargeDeconvolution::DataPointInfoSp > & | data_points_info | ) | const

private

For eache datapointInfo whith no parent copy info in new vector with the intensity of the monoistipics peaks added.

Returns
  the vecotr of datapointInfo with their intensity merged

Definition at line 259 of file filterchargedeconvolution.cpp.

{
std::vector<FilterChargeDeconvolution::DataPointInfoSp> deconvoluted_points_info;
for(DataPointInfoSp &data_point_info : data_points_info)
{
if(data_point_info->parent.lock() == nullptr)
{
DataPointInfoSp deconvoluted_point(std::make_shared<DataPointInfo>());
deconvoluted_point->z_charge = data_point_info->z_charge;
deconvoluted_point->new_mono_charge_data_point = data_point_info->data_point;
if(data_point_info->z_charge == 1)
{
for(std::weak_ptr<DataPointInfo> data : data_point_info->z1_vect)
{
deconvoluted_point->new_mono_charge_data_point.y += data.lock()->data_point.y;
}
}
else if(data_point_info->z_charge == 2)
{
for(std::weak_ptr<DataPointInfo> data : data_point_info->z2_vect)
{
deconvoluted_point->new_mono_charge_data_point.y += data.lock()->data_point.y;
}
}
else // if z.charge == 0
{
deconvoluted_point->new_mono_charge_data_point = data_point_info->data_point;
}
deconvoluted_points_info.push_back(deconvoluted_point);
}
}
data_points_info = deconvoluted_points_info;
}

Referenced by filter().

## filter()

Trace & FilterChargeDeconvolution::filter | ( | Trace & | data_points | ) | const

override virtual

get all the datapoints and remove different isotope and add their intensity and change to charge = 1 when the charge is known

Returns
  a list of datapoint

Implements pappso::FilterInterface.

Definition at line 115 of file filterchargedeconvolution.cpp.

{
qDebug();
std::vector<FilterChargeDeconvolution::DataPointInfoSp> data_points_info;
data_points.sortY(Enums::SortOrder::descending);
qDebug() << data_points.size();
Trace new_trace;
for(auto &data_point : data_points)
{
addDataPointToList(data_points_info, data_point);
}
computeBestChargeOfDataPoint(data_points_info);
// qDebug() << data_points_info.size();
computeIsotopeDeconvolution(data_points_info);
// qDebug() << data_points_info.size();
transformToMonoChargedForAllDataPoint(data_points_info);
for(DataPointInfoSp &dpi : data_points_info)
{
// qDebug() << dpi->new_mono_charge_data_point.x << dpi->z_charge;
new_trace.push_back(dpi->new_mono_charge_data_point);
}
new_trace.sortX();
data_points = std::move(new_trace);
qDebug() << data_points.size();
qDebug();
return data_points;
}
pappso::FilterChargeDeconvolution::computeBestChargeOfDataPoint
void computeBestChargeOfDataPoint(std::vector< FilterChargeDeconvolution::DataPointInfoSp > &data_points_info) const
Compare both list (z1 and z2) and add the right level of charge.
Definition filterchargedeconvolution.cpp:217
pappso::FilterChargeDeconvolution::transformToMonoChargedForAllDataPoint
void transformToMonoChargedForAllDataPoint(std::vector< FilterChargeDeconvolution::DataPointInfoSp > &data_points_info) const
For eache datapointInfo with a charge = 2 transform the peak to a charge = 1 by multiplying the mz by...
Definition filterchargedeconvolution.cpp:299
pappso::FilterChargeDeconvolution::addDataPointToList
void addDataPointToList(std::vector< FilterChargeDeconvolution::DataPointInfoSp > &points, DataPoint &data_point) const
Add each datapoint to a vector of structure describe above.
Definition filterchargedeconvolution.cpp:147
pappso::FilterChargeDeconvolution::computeIsotopeDeconvolution
void computeIsotopeDeconvolution(std::vector< FilterChargeDeconvolution::DataPointInfoSp > &data_points_info) const
For eache datapointInfo whith no parent copy info in new vector with the intensity of the monoistipic...
Definition filterchargedeconvolution.cpp:259
pappso::Trace::sortY
void sortY(Enums::SortOrder sort_order=Enums::SortOrder::ascending)
Definition trace.cpp:1081
pappso::Trace::sortX
void sortX(Enums::SortOrder sort_order=Enums::SortOrder::ascending)
Definition trace.cpp:1071
pappso::Enums::SortOrder::descending
@ descending
Definition types.h:233

References addDataPointToList(), computeBestChargeOfDataPoint(), computeIsotopeDeconvolution(), pappso::Enums::descending, pappso::Trace::sortX(), pappso::Trace::sortY(), and transformToMonoChargedForAllDataPoint().

Referenced by pappso::cbor::psm::PsmSpecGlob::filterMassSpectrum(), and pappso::cbor::psm::PsmSpecPeptidOms::filterMassSpectrum().

## name()

QString pappso::FilterChargeDeconvolution::name | ( |  | ) | const

override virtual

Implements pappso::FilterNameInterface.

Definition at line 98 of file filterchargedeconvolution.cpp.

{
return "chargeDeconvolution";
}

Referenced by toString().

## toString()

QString pappso::FilterChargeDeconvolution::toString | ( |  | ) | const

override virtual

Implements pappso::FilterNameInterface.

Definition at line 105 of file filterchargedeconvolution.cpp.

{
QString strCode = QString("%1|%2").arg(name()).arg(m_precisionPtrZ1->toString());
strCode.replace(" ", "");
return strCode;
}
pappso::FilterChargeDeconvolution::name
virtual QString name() const override
Definition filterchargedeconvolution.cpp:98

References m_precisionPtrZ1, and name().

## transformToMonoChargedForAllDataPoint()

void pappso::FilterChargeDeconvolution::transformToMonoChargedForAllDataPoint | ( | std::vector< FilterChargeDeconvolution::DataPointInfoSp > & | data_points_info | ) | const

private

For eache datapointInfo with a charge = 2 transform the peak to a charge = 1 by multiplying the mz by 2 and remove 1 H.

Returns
  the vecotr of datapointInfo their z corrected

Definition at line 299 of file filterchargedeconvolution.cpp.

{
for(DataPointInfoSp &dpi : data_points_info)
{
if(dpi->z_charge == 2)
{
dpi->new_mono_charge_data_point.x += dpi->new_mono_charge_data_point.x - MHPLUS;
}
}
}
pappso::MHPLUS
const pappso_double MHPLUS(1.007276466879)

References pappso::MHPLUS().

Referenced by filter().

## Member Data Documentation

## m_diffC12C13_z1

double pappso::FilterChargeDeconvolution::m_diffC12C13_z1

private

Definition at line 148 of file filterchargedeconvolution.h.

Referenced by FilterChargeDeconvolution(), FilterChargeDeconvolution(), addDataPointToList(), and buildFilterFromString().

## m_diffC12C13_z2

double pappso::FilterChargeDeconvolution::m_diffC12C13_z2

private

Definition at line 149 of file filterchargedeconvolution.h.

Referenced by FilterChargeDeconvolution(), FilterChargeDeconvolution(), addDataPointToList(), and buildFilterFromString().

## m_precisionPtrZ1

PrecisionPtr pappso::FilterChargeDeconvolution::m_precisionPtrZ1

private

Definition at line 150 of file filterchargedeconvolution.h.

Referenced by FilterChargeDeconvolution(), FilterChargeDeconvolution(), addDataPointToList(), buildFilterFromString(), and toString().

## m_precisionPtrZ2

PrecisionPtr pappso::FilterChargeDeconvolution::m_precisionPtrZ2

private

Definition at line 151 of file filterchargedeconvolution.h.

Referenced by FilterChargeDeconvolution(), FilterChargeDeconvolution(), addDataPointToList(), and buildFilterFromString().

The documentation for this class was generated from the following files:

- pappsomspp/core/processing/filters/filterchargedeconvolution.h
- pappsomspp/core/processing/filters/filterchargedeconvolution.cpp