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 each 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 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
Definition: precision.cpp:202
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 filer using a string

◆ 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  qInfo() << "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 164 of file filterchargedeconvolution.cpp.

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

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

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 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(";", QString::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:71

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

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

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

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

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

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

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

107 {
108  QString strCode =
109  QString("chargeDeconvolution|%1").arg(m_precisionPtrZ1->toString());
110  strCode.replace(" ", "");
111 
112  return strCode;
113 }
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 311 of file filterchargedeconvolution.cpp.

314 {
315  for(DataPointInfoSp &dpi : data_points_info)
316  {
317  if(dpi->z_charge == 2)
318  {
319  dpi->new_mono_charge_data_point.x +=
320  dpi->new_mono_charge_data_point.x - MHPLUS;
321  }
322  }
323 }
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 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: