libpappsomspp
Library for mass spectrometry
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 More...
 
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 filer using a string More...
 

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. More...
 
void addDataPointRefByExclusion (std::vector< FilterChargeDeconvolution::DataPointInfoSp > &points, FilterChargeDeconvolution::DataPointInfoSp &new_dpi) const
 For eache datapointInfo add the datapoint to the lists by their exclusion range. More...
 
void computeBestChargeOfDataPoint (std::vector< FilterChargeDeconvolution::DataPointInfoSp > &data_points_info) const
 Compare both list (z1 and z2) and add the right level of charge. More...
 
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. More...
 
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. More...
 

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

41  : m_precisionPtrZ1(precision_ptr)
42 {
45  m_precisionPtrZ1 = precision_ptr;
47  m_precisionPtrZ1, 0.5);
48 
49  // pappso::PrecisionFactory::getPrecisionDividedBy(m_precisionPtrZ1, 2):
50 
51  qInfo() << m_precisionPtrZ2->getNominal();
52 }

References pappso::DIFFC12C13(), pappso::PrecisionBase::getNominal(), 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 }

◆ FilterChargeDeconvolution() [3/3]

FilterChargeDeconvolution::FilterChargeDeconvolution ( const FilterChargeDeconvolution other)

Copy constructor

Parameters
otherTODO

Definition at line 54 of file filterchargedeconvolution.cpp.

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

◆ ~FilterChargeDeconvolution()

FilterChargeDeconvolution::~FilterChargeDeconvolution ( )
virtual

Destructor

Definition at line 63 of file filterchargedeconvolution.cpp.

64 {
65 }

Member Function Documentation

◆ addDataPointRefByExclusion()

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

For eache 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.

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

◆ 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.

150 {
151  DataPointInfoSp new_dpi(std::make_shared<DataPointInfo>());
152 
153  new_dpi->data_point = data_point;
154  MzRange range1(data_point.x + m_diffC12C13_z1, m_precisionPtrZ1);
155  new_dpi->z1_range = std::pair<double, double>(range1.lower(), range1.upper());
156  MzRange range2(data_point.x + m_diffC12C13_z2, m_precisionPtrZ2);
157  new_dpi->z2_range = std::pair<double, double>(range2.lower(), range2.upper());
158  addDataPointRefByExclusion(points, new_dpi);
159  points.push_back(new_dpi);
160 }

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 filer using a string

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

Implements pappso::FilterNameInterface.

Definition at line 69 of file filterchargedeconvolution.cpp.

71 {
72  //"chargeDeconvolution|0.02dalton"
73  qDebug();
74  if(strBuildParams.startsWith("chargeDeconvolution|"))
75  {
76  QStringList params =
77  strBuildParams.split("|").back().split(";", QString::SkipEmptyParts);
78 
79  QString precision = params.at(0);
81  PrecisionFactory::fromString(precision.replace("dalton", " dalton")
82  .replace("ppm", " ppm")
83  .replace("res", " res"));
84 
85  qDebug();
88  m_precisionPtrZ1, 0.5);
89 
90 
93  }
94  else
95  {
97  QString("building chargeDeconvolution from string %1 is not possible")
98  .arg(strBuildParams));
99  }
100  qDebug();
101 }

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

◆ 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.

220 {
221  for(DataPointInfoSp &data_point_info : data_points_info)
222  {
223  if(data_point_info.get()->z1_vect.size() >= 1 &&
224  data_point_info.get()->z2_vect.size() == 0)
225  {
226  for(DataPointInfoSp other : data_point_info.get()->z1_vect)
227  {
228  other->z_charge = 1;
229  }
230  data_point_info.get()->z_charge = 1;
231  }
232  else if(data_point_info.get()->z1_vect.size() == 0 &&
233  data_point_info.get()->z2_vect.size() >= 1)
234  {
235  for(DataPointInfoSp other : data_point_info.get()->z2_vect)
236  {
237  other->z_charge = 2;
238  }
239  data_point_info.get()->z_charge = 2;
240  }
241  else if(data_point_info.get()->z1_vect.size() >= 1 &&
242  data_point_info.get()->z2_vect.size() >= 1)
243  {
244  for(DataPointInfoSp other : data_point_info.get()->z2_vect)
245  {
246  other->z_charge = 2;
247  }
248  data_point_info.get()->z_charge = 2;
249  }
250  else
251  {
252  if(data_point_info.get()->z_charge == -1)
253  {
254  data_point_info.get()->z_charge = 0;
255  }
256  }
257  }
258 }

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

264 {
265  std::vector<FilterChargeDeconvolution::DataPointInfoSp>
266  deconvoluted_points_info;
267 
268  for(DataPointInfoSp &data_point_info : data_points_info)
269  {
270  if(data_point_info->parent == nullptr)
271  {
272  DataPointInfoSp deconvoluted_point(std::make_shared<DataPointInfo>());
273 
274  deconvoluted_point->z_charge = data_point_info->z_charge;
275  deconvoluted_point->new_mono_charge_data_point =
276  data_point_info->data_point;
277 
278  if(data_point_info->z_charge == 1)
279  {
280 
281  for(DataPointInfoSp data : data_point_info->z1_vect)
282  {
283  deconvoluted_point->new_mono_charge_data_point.y +=
284  data->data_point.y;
285  }
286  }
287  else if(data_point_info->z_charge == 2)
288  {
289  for(DataPointInfoSp data : data_point_info->z2_vect)
290  {
291  deconvoluted_point->new_mono_charge_data_point.y +=
292  data->data_point.y;
293  }
294  }
295  else // if z.charge == 0
296  {
297  deconvoluted_point->new_mono_charge_data_point =
298  data_point_info->data_point;
299  }
300  deconvoluted_points_info.push_back(deconvoluted_point);
301  }
302  }
303  data_points_info = deconvoluted_points_info;
304 }

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

116 {
117  qDebug();
118  std::vector<FilterChargeDeconvolution::DataPointInfoSp> data_points_info;
119  data_points.sortY();
120 
121  Trace new_trace;
122 
123  for(auto &data_point : data_points)
124  {
125  addDataPointToList(data_points_info, data_point);
126  }
127  computeBestChargeOfDataPoint(data_points_info);
128 
129  qDebug() << data_points_info.size();
130  computeIsotopeDeconvolution(data_points_info);
131  qDebug() << data_points_info.size();
132  transformToMonoChargedForAllDataPoint(data_points_info);
133  for(DataPointInfoSp &dpi : data_points_info)
134  {
135  qDebug() << dpi->new_mono_charge_data_point.x << dpi->z_charge;
136  new_trace.push_back(dpi->new_mono_charge_data_point);
137  }
138 
139  new_trace.sortX();
140  data_points = std::move(new_trace);
141 
142  qDebug();
143  return data_points;
144 }

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

◆ toString()

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

Implements pappso::FilterNameInterface.

Definition at line 105 of file filterchargedeconvolution.cpp.

106 {
107  QString strCode =
108  QString("chargeDeconvolution|%1").arg(m_precisionPtrZ1->toString());
109  strCode.replace(" ", "");
110 
111  return strCode;
112 }

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

310 {
311  for(DataPointInfoSp &dpi : data_points_info)
312  {
313  if(dpi->z_charge == 2)
314  {
315  dpi->new_mono_charge_data_point.x +=
316  dpi->new_mono_charge_data_point.x - MHPLUS;
317  }
318  }
319 }

References pappso::MHPLUS().

Referenced by filter().

Member Data Documentation

◆ m_diffC12C13_z1

double pappso::FilterChargeDeconvolution::m_diffC12C13_z1
private

Definition at line 147 of file filterchargedeconvolution.h.

Referenced by FilterChargeDeconvolution().

◆ m_diffC12C13_z2

double pappso::FilterChargeDeconvolution::m_diffC12C13_z2
private

Definition at line 148 of file filterchargedeconvolution.h.

Referenced by FilterChargeDeconvolution().

◆ m_precisionPtrZ1

PrecisionPtr pappso::FilterChargeDeconvolution::m_precisionPtrZ1
private

Definition at line 149 of file filterchargedeconvolution.h.

Referenced by FilterChargeDeconvolution().

◆ m_precisionPtrZ2

PrecisionPtr pappso::FilterChargeDeconvolution::m_precisionPtrZ2
private

Definition at line 150 of file filterchargedeconvolution.h.

Referenced by FilterChargeDeconvolution().


The documentation for this class was generated from the following files:
pappso::FilterChargeDeconvolution::m_diffC12C13_z2
double m_diffC12C13_z2
Definition: filterchargedeconvolution.h:148
pappso::FilterChargeDeconvolution::DataPointInfoSp
std::shared_ptr< DataPointInfo > DataPointInfoSp
Definition: filterchargedeconvolution.h:45
pappso::MHPLUS
const pappso_double MHPLUS(1.007276466879)
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::PrecisionFactory::getPrecisionPtrFractionInstance
static PrecisionPtr getPrecisionPtrFractionInstance(PrecisionPtr origin, double fraction)
get the fraction of an existing precision pointer
Definition: precision.cpp:202
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:307
pappso::Trace::sortY
void sortY()
Definition: trace.cpp:800
pappso::FilterChargeDeconvolution::m_precisionPtrZ2
PrecisionPtr m_precisionPtrZ2
Definition: filterchargedeconvolution.h:150
pappso::MzRange
Definition: mzrange.h:46
pappso::Trace
A simple container of DataPoint instances.
Definition: trace.h:132
pappso::FilterChargeDeconvolution::m_precisionPtrZ1
PrecisionPtr m_precisionPtrZ1
Definition: filterchargedeconvolution.h:149
pappso::FilterChargeDeconvolution::m_diffC12C13_z1
double m_diffC12C13_z1
Definition: filterchargedeconvolution.h:147
pappso::ExceptionNotRecognized
excetion to use when an item type is not recognized
Definition: exceptionnotrecognized.h:42
pappso::DIFFC12C13
const pappso_double DIFFC12C13(1.0033548378)
pappso::PrecisionBase::getNominal
virtual pappso_double getNominal() const final
Definition: precision.cpp:64
pappso::DataPoint::x
pappso_double x
Definition: datapoint.h:22
pappso::Trace::sortX
void sortX()
Definition: trace.cpp:792
pappso::FilterChargeDeconvolution::buildFilterFromString
void buildFilterFromString(const QString &strBuildParams) override
build this filer using a string
Definition: filterchargedeconvolution.cpp:69
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::addDataPointRefByExclusion
void addDataPointRefByExclusion(std::vector< FilterChargeDeconvolution::DataPointInfoSp > &points, FilterChargeDeconvolution::DataPointInfoSp &new_dpi) const
For eache datapointInfo add the datapoint to the lists by their exclusion range.
Definition: filterchargedeconvolution.cpp:163
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:261
pappso::PrecisionBase::toString
virtual QString toString() const =0
pappso::PrecisionFactory::fromString
static PrecisionPtr fromString(const QString &str)
get a precision pointer from a string
Definition: precision.cpp:71