libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::FilterChargeDeconvolution Class Reference

#include <filterchargedeconvolution.h>

Inheritance diagram for pappso::FilterChargeDeconvolution:
pappso::FilterNameInterface pappso::FilterInterface

Classes

struct  DataPointInfo
 

Public Member Functions

 FilterChargeDeconvolution (PrecisionPtr precision_ptr)
 
 FilterChargeDeconvolution (const QString &strBuildParams)
 
 FilterChargeDeconvolution (const FilterChargeDeconvolution &other)
 
virtual ~FilterChargeDeconvolution ()
 
Tracefilter (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< DataPointInfoDataPointInfoSp
 

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

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.

42 : m_precisionPtrZ1(precision_ptr)
43{
46 m_precisionPtrZ1 = precision_ptr;
48 m_precisionPtrZ1, 0.5);
49
50 // pappso::PrecisionFactory::getPrecisionDividedBy(m_precisionPtrZ1, 2):
51
52 // qInfo() << m_precisionPtrZ2->getNominal();
53}
static PrecisionPtr getPrecisionPtrFractionInstance(PrecisionPtr origin, double fraction)
get the fraction of an existing precision pointer
const pappso_double DIFFC12C13(1.0033548378)

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

◆ FilterChargeDeconvolution() [2/3]

pappso::FilterChargeDeconvolution::FilterChargeDeconvolution ( const QString &  strBuildParams)
Parameters
strBuildParamsstring to build the filter "chargeDeconvolution|0.02dalton"

Definition at line 33 of file filterchargedeconvolution.cpp.

35{
36 buildFilterFromString(strBuildParams);
37 // qInfo() << "ChargeDeconvolution created";
38}
void buildFilterFromString(const QString &strBuildParams) override
build this filter using a string

References buildFilterFromString().

◆ FilterChargeDeconvolution() [3/3]

FilterChargeDeconvolution::FilterChargeDeconvolution ( const FilterChargeDeconvolution other)

Copy constructor

Parameters
otherTODO

Definition at line 55 of file filterchargedeconvolution.cpp.

References pappso::DIFFC12C13(), m_diffC12C13_z1, and m_diffC12C13_z2.

◆ ~FilterChargeDeconvolution()

FilterChargeDeconvolution::~FilterChargeDeconvolution ( )
virtual

Destructor

Definition at line 64 of file filterchargedeconvolution.cpp.

65{
66 qDebug() << "ChargeDeconvolution destroyed";
67}

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 172 of file filterchargedeconvolution.cpp.

175{
176 // add datapoint which match the mz_range = 1 to z1_list
177 auto i_z1 = points.begin(), end = points.end();
178 while(i_z1 != end)
179 {
180 // get the datapoint which match the range
181 i_z1 = std::find_if(i_z1, end, [&new_dpi](DataPointInfoSp dpi) {
182 return (new_dpi->data_point.x >= dpi->z1_range.first &&
183 new_dpi->data_point.x <= dpi->z1_range.second);
184 });
185 if(i_z1 != end)
186 {
187 // add the datapoint to the list and add the parent pointer
188 i_z1->get()->z1_vect.push_back(new_dpi);
189 new_dpi->parent = *i_z1;
190 DataPointInfoSp parent_z1 = i_z1->get()->parent.lock();
191 while(parent_z1 != nullptr)
192 {
193 parent_z1.get()->z1_vect.push_back(new_dpi);
194 parent_z1 = parent_z1->parent.lock();
195 }
196 i_z1++;
197 }
198 }
199
200 // add datapoint which match the mz_range = 2 to z2_list
201 auto i_z2 = points.begin();
202 while(i_z2 != end)
203 {
204 // get the datapoint which match the range
205 i_z2 = std::find_if(i_z2, end, [&new_dpi](DataPointInfoSp dpi) {
206 return (new_dpi->data_point.x >= dpi->z2_range.first &&
207 new_dpi->data_point.x <= dpi->z2_range.second);
208 });
209 if(i_z2 != end)
210 {
211 // add the datapoint to the list and add the parent pointer
212 i_z2->get()->z2_vect.push_back(new_dpi);
213 new_dpi->parent = *i_z2;
214 DataPointInfoSp parent_z2 = i_z2->get()->parent.lock();
215 while(parent_z2 != nullptr)
216 {
217 parent_z2.get()->z2_vect.push_back(new_dpi);
218 parent_z2 = parent_z2->parent.lock();
219 }
220 i_z2++;
221 }
222 }
223}
std::shared_ptr< DataPointInfo > DataPointInfoSp

◆ 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 156 of file filterchargedeconvolution.cpp.

159{
160 DataPointInfoSp new_dpi(std::make_shared<DataPointInfo>());
161
162 new_dpi->data_point = data_point;
163 MzRange range1(data_point.x + m_diffC12C13_z1, m_precisionPtrZ1);
164 new_dpi->z1_range = std::pair<double, double>(range1.lower(), range1.upper());
165 MzRange range2(data_point.x + m_diffC12C13_z2, m_precisionPtrZ2);
166 new_dpi->z2_range = std::pair<double, double>(range2.lower(), range2.upper());
167 addDataPointRefByExclusion(points, new_dpi);
168 points.push_back(new_dpi);
169}
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.
pappso_double x
Definition datapoint.h:23

References pappso::MzRange::lower(), pappso::MzRange::upper(), and pappso::DataPoint::x.

Referenced by filter().

◆ buildFilterFromString()

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

build this filter using a string

Parameters
strBuildParamsa string coding the filter and its parameters "filterName|param1;param2;param3"

Implements pappso::FilterNameInterface.

Definition at line 71 of file filterchargedeconvolution.cpp.

73{
74 //"chargeDeconvolution|0.02dalton"
75 qDebug();
76 if(strBuildParams.startsWith("chargeDeconvolution|"))
77 {
78 QStringList params =
79 strBuildParams.split("|").back().split(";", Qt::SkipEmptyParts);
80
81 QString precision = params.at(0);
83 PrecisionFactory::fromString(precision.replace("dalton", " dalton")
84 .replace("ppm", " ppm")
85 .replace("res", " res"));
86 qDebug();
89 m_precisionPtrZ1, 0.5);
90
91
94 }
95 else
96 {
98 QString("building chargeDeconvolution from string %1 is not possible")
99 .arg(strBuildParams));
100 }
101 qDebug();
102}
excetion to use when an item type is not recognized
static PrecisionPtr fromString(const QString &str)
get a precision pointer from a string
Definition precision.cpp:72

References pappso::DIFFC12C13(), pappso::PrecisionFactory::fromString(), and pappso::PrecisionFactory::getPrecisionPtrFractionInstance().

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 226 of file filterchargedeconvolution.cpp.

229{
230 for(DataPointInfoSp &data_point_info : data_points_info)
231 {
232 if(data_point_info.get()->z1_vect.size() >= 1 &&
233 data_point_info.get()->z2_vect.size() == 0)
234 {
235 for(std::weak_ptr<DataPointInfo> other :
236 data_point_info.get()->z1_vect)
237 {
238 other.lock()->z_charge = 1;
239 }
240 data_point_info.get()->z_charge = 1;
241 }
242 else if(data_point_info.get()->z1_vect.size() == 0 &&
243 data_point_info.get()->z2_vect.size() >= 1)
244 {
245 for(std::weak_ptr<DataPointInfo> other :
246 data_point_info.get()->z2_vect)
247 {
248 other.lock()->z_charge = 2;
249 }
250 data_point_info.get()->z_charge = 2;
251 }
252 else if(data_point_info.get()->z1_vect.size() >= 1 &&
253 data_point_info.get()->z2_vect.size() >= 1)
254 {
255 for(std::weak_ptr<DataPointInfo> other :
256 data_point_info.get()->z2_vect)
257 {
258 other.lock()->z_charge = 2;
259 }
260 data_point_info.get()->z_charge = 2;
261 }
262 else
263 {
264 if(data_point_info.get()->z_charge == -1)
265 {
266 data_point_info.get()->z_charge = 0;
267 }
268 }
269 }
270}

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 273 of file filterchargedeconvolution.cpp.

276{
277 std::vector<FilterChargeDeconvolution::DataPointInfoSp>
278 deconvoluted_points_info;
279
280 for(DataPointInfoSp &data_point_info : data_points_info)
281 {
282 if(data_point_info->parent.lock() == nullptr)
283 {
284 DataPointInfoSp deconvoluted_point(std::make_shared<DataPointInfo>());
285
286 deconvoluted_point->z_charge = data_point_info->z_charge;
287 deconvoluted_point->new_mono_charge_data_point =
288 data_point_info->data_point;
289
290 if(data_point_info->z_charge == 1)
291 {
292
293 for(std::weak_ptr<DataPointInfo> data : data_point_info->z1_vect)
294 {
295 deconvoluted_point->new_mono_charge_data_point.y +=
296 data.lock()->data_point.y;
297 }
298 }
299 else if(data_point_info->z_charge == 2)
300 {
301 for(std::weak_ptr<DataPointInfo> data : data_point_info->z2_vect)
302 {
303 deconvoluted_point->new_mono_charge_data_point.y +=
304 data.lock()->data_point.y;
305 }
306 }
307 else // if z.charge == 0
308 {
309 deconvoluted_point->new_mono_charge_data_point =
310 data_point_info->data_point;
311 }
312 deconvoluted_points_info.push_back(deconvoluted_point);
313 }
314 }
315 data_points_info = deconvoluted_points_info;
316}

Referenced by filter().

◆ filter()

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

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 124 of file filterchargedeconvolution.cpp.

125{
126 qDebug();
127 std::vector<FilterChargeDeconvolution::DataPointInfoSp> data_points_info;
128 data_points.sortY(SortOrder::descending);
129 qDebug() << data_points.size();
130 Trace new_trace;
131
132 for(auto &data_point : data_points)
133 {
134 addDataPointToList(data_points_info, data_point);
135 }
136 computeBestChargeOfDataPoint(data_points_info);
137
138 // qDebug() << data_points_info.size();
139 computeIsotopeDeconvolution(data_points_info);
140 // qDebug() << data_points_info.size();
142 for(DataPointInfoSp &dpi : data_points_info)
143 {
144 // qDebug() << dpi->new_mono_charge_data_point.x << dpi->z_charge;
145 new_trace.push_back(dpi->new_mono_charge_data_point);
146 }
147
148 new_trace.sortX();
149 data_points = std::move(new_trace);
150 qDebug() << data_points.size();
151 qDebug();
152 return data_points;
153}
void computeBestChargeOfDataPoint(std::vector< FilterChargeDeconvolution::DataPointInfoSp > &data_points_info) const
Compare both list (z1 and z2) and add the right level of charge.
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...
void addDataPointToList(std::vector< FilterChargeDeconvolution::DataPointInfoSp > &points, DataPoint &data_point) const
Add each datapoint to a vector of structure describe above.
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...
A simple container of DataPoint instances.
Definition trace.h:148
void sortX(SortOrder sort_order=SortOrder::ascending)
Definition trace.cpp:1086
void sortY(SortOrder sort_order=SortOrder::ascending)
Definition trace.cpp:1100

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

◆ name()

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

Implements pappso::FilterNameInterface.

Definition at line 106 of file filterchargedeconvolution.cpp.

107{
108 return "chargeDeconvolution";
109}

◆ toString()

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

Implements pappso::FilterNameInterface.

Definition at line 113 of file filterchargedeconvolution.cpp.

114{
115 QString strCode =
116 QString("%1|%2").arg(name()).arg(m_precisionPtrZ1->toString());
117
118 strCode.replace(" ", "");
119
120 return strCode;
121}
virtual QString name() const override
virtual QString toString() const =0

◆ 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 319 of file filterchargedeconvolution.cpp.

322{
323 for(DataPointInfoSp &dpi : data_points_info)
324 {
325 if(dpi->z_charge == 2)
326 {
327 dpi->new_mono_charge_data_point.x +=
328 dpi->new_mono_charge_data_point.x - MHPLUS;
329 }
330 }
331}
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

◆ m_diffC12C13_z2

double pappso::FilterChargeDeconvolution::m_diffC12C13_z2
private

◆ m_precisionPtrZ1

PrecisionPtr pappso::FilterChargeDeconvolution::m_precisionPtrZ1
private

Definition at line 150 of file filterchargedeconvolution.h.

Referenced by FilterChargeDeconvolution().

◆ m_precisionPtrZ2

PrecisionPtr pappso::FilterChargeDeconvolution::m_precisionPtrZ2
private

Definition at line 151 of file filterchargedeconvolution.h.

Referenced by FilterChargeDeconvolution().


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