libpappsomspp
Library for mass spectrometry
pappso::FilterChargeDeconvolution Class Reference

#include <filterchargedeconvolution.h>

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

Classes

struct  DataPointInfo
 

Public Member Functions

 FilterChargeDeconvolution (PrecisionPtr precision_ptr)
 
 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...
 

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_precisionPtr
 

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/2]

FilterChargeDeconvolution::FilterChargeDeconvolution ( PrecisionPtr  precision_ptr)

Default constructor

Definition at line 32 of file filterchargedeconvolution.cpp.

33  : m_precisionPtr(precision_ptr)
34 {
37 }

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

◆ FilterChargeDeconvolution() [2/2]

FilterChargeDeconvolution::FilterChargeDeconvolution ( const FilterChargeDeconvolution other)

Copy constructor

Parameters
otherTODO

Definition at line 39 of file filterchargedeconvolution.cpp.

42 {
45 }

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

◆ ~FilterChargeDeconvolution()

FilterChargeDeconvolution::~FilterChargeDeconvolution ( )
virtual

Destructor

Definition at line 47 of file filterchargedeconvolution.cpp.

48 {
49 }

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

101 {
102  // add datapoint which match the mz_range = 1 to z1_list
103  auto i_z1 = points.begin(), end = points.end();
104  while(i_z1 != end)
105  {
106  // get the datapoint which match the range
107  i_z1 = std::find_if(i_z1, end, [&new_dpi](DataPointInfoSp dpi) {
108  return (new_dpi->data_point.x >= dpi->z1_range.first &&
109  new_dpi->data_point.x <= dpi->z1_range.second);
110  });
111  if(i_z1 != end)
112  {
113  // add the datapoint to the list and add the parent pointer
114  i_z1->get()->z1_vect.push_back(new_dpi);
115  new_dpi->parent = *i_z1;
116  DataPointInfoSp parent_z1 = i_z1->get()->parent;
117  while(parent_z1 != nullptr)
118  {
119  parent_z1.get()->z1_vect.push_back(new_dpi);
120  parent_z1 = parent_z1->parent;
121  }
122  i_z1++;
123  }
124  }
125 
126  // add datapoint which match the mz_range = 2 to z2_list
127  auto i_z2 = points.begin();
128  while(i_z2 != end)
129  {
130  // get the datapoint which match the range
131  i_z2 = std::find_if(i_z2, end, [&new_dpi](DataPointInfoSp dpi) {
132  return (new_dpi->data_point.x >= dpi->z2_range.first &&
133  new_dpi->data_point.x <= dpi->z2_range.second);
134  });
135  if(i_z2 != end)
136  {
137  // add the datapoint to the list and add the parent pointer
138  i_z2->get()->z2_vect.push_back(new_dpi);
139  new_dpi->parent = *i_z2;
140  DataPointInfoSp parent_z2 = i_z2->get()->parent;
141  while(parent_z2 != nullptr)
142  {
143  parent_z2.get()->z2_vect.push_back(new_dpi);
144  parent_z2 = parent_z2->parent;
145  }
146  i_z2++;
147  }
148  }
149 }

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

85 {
86  DataPointInfoSp new_dpi(std::make_shared<DataPointInfo>());
87 
88  new_dpi->data_point = data_point;
89  MzRange range1(data_point.x + m_diffC12C13_z1, m_precisionPtr);
90  new_dpi->z1_range = std::pair<double, double>(range1.lower(), range1.upper());
91  MzRange range2(data_point.x + m_diffC12C13_z2, m_precisionPtr);
92  new_dpi->z2_range = std::pair<double, double>(range2.lower(), range2.upper());
93  addDataPointRefByExclusion(points, new_dpi);
94  points.push_back(new_dpi);
95 }

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

Referenced by filter().

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

155 {
156  for(DataPointInfoSp &data_point_info : data_points_info)
157  {
158  if(data_point_info.get()->z1_vect.size() >= 1 &&
159  data_point_info.get()->z2_vect.size() == 0)
160  {
161  for(DataPointInfoSp other : data_point_info.get()->z1_vect)
162  {
163  other->z_charge = 1;
164  }
165  data_point_info.get()->z_charge = 1;
166  }
167  else if(data_point_info.get()->z1_vect.size() == 0 &&
168  data_point_info.get()->z2_vect.size() >= 1)
169  {
170  for(DataPointInfoSp other : data_point_info.get()->z2_vect)
171  {
172  other->z_charge = 2;
173  }
174  data_point_info.get()->z_charge = 2;
175  }
176  else if(data_point_info.get()->z1_vect.size() >= 1 &&
177  data_point_info.get()->z2_vect.size() >= 1)
178  {
179  for(DataPointInfoSp other : data_point_info.get()->z2_vect)
180  {
181  other->z_charge = 2;
182  }
183  data_point_info.get()->z_charge = 2;
184  }
185  else
186  {
187  if(data_point_info.get()->z_charge == -1)
188  {
189  data_point_info.get()->z_charge = 0;
190  }
191  }
192  }
193 }

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

199 {
200  std::vector<FilterChargeDeconvolution::DataPointInfoSp>
201  deconvoluted_points_info;
202 
203  for(DataPointInfoSp &data_point_info : data_points_info)
204  {
205  if(data_point_info->parent == nullptr)
206  {
207  DataPointInfoSp deconvoluted_point(std::make_shared<DataPointInfo>());
208 
209  deconvoluted_point->z_charge = data_point_info->z_charge;
210  deconvoluted_point->new_mono_charge_data_point =
211  data_point_info->data_point;
212 
213  if(data_point_info->z_charge == 1)
214  {
215  for(DataPointInfoSp data : data_point_info->z1_vect)
216  {
217  deconvoluted_point->data_point.y += data->data_point.y;
218  }
219  }
220  else if(data_point_info->z_charge == 2)
221  {
222  for(DataPointInfoSp data : data_point_info->z2_vect)
223  {
224  deconvoluted_point->data_point.y += data->data_point.y;
225  }
226  }
227  else // if z.charge == 0
228  {
229  deconvoluted_point->new_mono_charge_data_point =
230  data_point_info->data_point;
231  }
232  deconvoluted_points_info.push_back(deconvoluted_point);
233  }
234  }
235  data_points_info = deconvoluted_points_info;
236 }

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

53 {
54  std::vector<FilterChargeDeconvolution::DataPointInfoSp> data_points_info;
55  data_points.sortY();
56 
57  Trace new_trace;
58 
59  for(auto &data_point : data_points)
60  {
61  addDataPointToList(data_points_info, data_point);
62  }
63  computeBestChargeOfDataPoint(data_points_info);
64 
65  qDebug() << data_points_info.size();
66  computeIsotopeDeconvolution(data_points_info);
67  qDebug() << data_points_info.size();
68  transformToMonoChargedForAllDataPoint(data_points_info);
69  for(DataPointInfoSp &dpi : data_points_info)
70  {
71  qDebug() << dpi->new_mono_charge_data_point.x << dpi->z_charge;
72  new_trace.push_back(dpi->new_mono_charge_data_point);
73  }
74 
75  new_trace.sortX();
76  data_points = std::move(new_trace);
77 
78  return data_points;
79 }

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

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

242 {
243  for(DataPointInfoSp &dpi : data_points_info)
244  {
245  if(dpi->z_charge == 2)
246  {
247  dpi->new_mono_charge_data_point.x +=
248  dpi->new_mono_charge_data_point.x - MHPLUS;
249  }
250  }
251 }

References pappso::MHPLUS().

Referenced by filter().

Member Data Documentation

◆ m_diffC12C13_z1

double pappso::FilterChargeDeconvolution::m_diffC12C13_z1
private

Definition at line 134 of file filterchargedeconvolution.h.

Referenced by FilterChargeDeconvolution().

◆ m_diffC12C13_z2

double pappso::FilterChargeDeconvolution::m_diffC12C13_z2
private

Definition at line 135 of file filterchargedeconvolution.h.

Referenced by FilterChargeDeconvolution().

◆ m_precisionPtr

PrecisionPtr pappso::FilterChargeDeconvolution::m_precisionPtr
private

Definition at line 136 of file filterchargedeconvolution.h.


The documentation for this class was generated from the following files:
pappso::FilterChargeDeconvolution::m_diffC12C13_z2
double m_diffC12C13_z2
Definition: filterchargedeconvolution.h:135
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:82
pappso::FilterChargeDeconvolution::m_precisionPtr
PrecisionPtr m_precisionPtr
Definition: filterchargedeconvolution.h:136
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:239
pappso::Trace::sortY
void sortY()
Definition: trace.cpp:798
pappso::MzRange
Definition: mzrange.h:46
pappso::Trace
A simple container of DataPoint instances.
Definition: trace.h:132
pappso::FilterChargeDeconvolution::m_diffC12C13_z1
double m_diffC12C13_z1
Definition: filterchargedeconvolution.h:134
pappso::DIFFC12C13
const pappso_double DIFFC12C13(1.0033548378)
pappso::DataPoint::x
pappso_double x
Definition: datapoint.h:22
pappso::Trace::sortX
void sortX()
Definition: trace.cpp:790
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:152
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:98
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:196