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

#include <experimentalspectrum.h>

Inheritance diagram for pappso::specglob::ExperimentalSpectrum:

Public Member Functions

 ExperimentalSpectrum (const pappso::QualifiedMassSpectrum &qmass_spectrum, pappso::PrecisionPtr precision_ptr)
 
 ExperimentalSpectrum (const ExperimentalSpectrum &other)
 
virtual ~ExperimentalSpectrum ()
 
std::vector< double > getMassList () const
 
double getSymetricMz (double mz) const
 compute the symmetric mass for debuggin purpose
 
double getTargetMzSum () const
 
double getPrecursorMass () const
 
std::vector< double > getMassList (ExperimentalSpectrumDataPointType type) const
 
QString toString () const
 
const pappso::QualifiedMassSpectrumgetQualifiedMassSpectrum () const
 
std::vector< ExperimentalSpectrumDataPoint >::const_reverse_iterator reverseFindDiffMz (std::size_t start_position, const pappso::MzRange &targeted_mass_range) const
 find the peak for wich mass difference from rbegin corresponds to aaTheoMass Find if a peak back in the peak list has a mass difference that corresponds to the targeted mass
 

Private Member Functions

void createSymetricPeakList ()
 add symmetric peaks to the spectrum Create a SymetricPeakList that contain symmetric peaks and the information if a peak is the initial peak, the symmetric peak, or both if already exist. assuming fragment ion charge is 1
 
std::vector< pappso::DataPoint >::const_iterator findMz (double mz)
 find the correspondin mz in the mass spectrum (given the precision)
 

Private Attributes

pappso::QualifiedMassSpectrum m_qualifiedMassSpectrum
 
double m_targetMzSum
 
double m_precursorMass
 
pappso::PrecisionPtr m_precisionPtr
 

Detailed Description

Todo:
write docs

Definition at line 63 of file experimentalspectrum.h.

Constructor & Destructor Documentation

◆ ExperimentalSpectrum() [1/2]

pappso::specglob::ExperimentalSpectrum::ExperimentalSpectrum ( const pappso::QualifiedMassSpectrum qmass_spectrum,
pappso::PrecisionPtr  precision_ptr 
)

Default constructor

Definition at line 45 of file experimentalspectrum.cpp.

48 : std::vector<ExperimentalSpectrumDataPoint>()
49{
50 m_qualifiedMassSpectrum = qmass_spectrum;
51 m_precisionPtr = precision_ptr;
53}
void createSymetricPeakList()
add symmetric peaks to the spectrum Create a SymetricPeakList that contain symmetric peaks and the in...
pappso::QualifiedMassSpectrum m_qualifiedMassSpectrum

References createSymetricPeakList(), m_precisionPtr, and m_qualifiedMassSpectrum.

◆ ExperimentalSpectrum() [2/2]

pappso::specglob::ExperimentalSpectrum::ExperimentalSpectrum ( const ExperimentalSpectrum other)

Copy constructor

Parameters
otherTODO

Definition at line 55 of file experimentalspectrum.cpp.

56 : std::vector<ExperimentalSpectrumDataPoint>(other)
57{
58 m_targetMzSum = other.m_targetMzSum;
59 m_qualifiedMassSpectrum = other.m_qualifiedMassSpectrum;
60 m_precisionPtr = other.m_precisionPtr;
61}

References m_precisionPtr, m_qualifiedMassSpectrum, and m_targetMzSum.

◆ ~ExperimentalSpectrum()

pappso::specglob::ExperimentalSpectrum::~ExperimentalSpectrum ( )
virtual

Destructor

Definition at line 63 of file experimentalspectrum.cpp.

64{
65}

Member Function Documentation

◆ createSymetricPeakList()

void pappso::specglob::ExperimentalSpectrum::createSymetricPeakList ( )
private

add symmetric peaks to the spectrum Create a SymetricPeakList that contain symmetric peaks and the information if a peak is the initial peak, the symmetric peak, or both if already exist. assuming fragment ion charge is 1

Definition at line 68 of file experimentalspectrum.cpp.

69{
70
71 bool ok;
73 if(!ok)
74 {
76 QObject::tr("precursor charge is not defined in spectrum %1")
78 }
79
80 double mz_prec = m_qualifiedMassSpectrum.getPrecursorMz(&ok);
81 if(!ok)
82 {
84 QObject::tr("precursor m/z is not defined in spectrum %1")
86 }
87
88 // compute precursor mass given the charge state
89 m_precursorMass = mz_prec * (double)charge;
90 m_precursorMass -= pappso::MHPLUS * (double)charge;
92
93 std::vector<double> mz_list =
95
96 std::size_t mz_current_indice = 0;
97 auto itend = m_qualifiedMassSpectrum.getMassSpectrumCstSPtr().get()->end();
98 for(std::vector<pappso::DataPoint>::const_iterator it =
100 it != itend;
101 it++)
102 {
103 double current_mz = it->x;
104
105 double symmetric_current_mz = getSymetricMz(current_mz);
106
107 auto itpair_symmetric = findMz(symmetric_current_mz);
108 if(itpair_symmetric != itend)
109 {
110 // there is a counterpart
111 push_back({ExperimentalSpectrumDataPointType::both, it->x, 0});
112 qDebug() << "current_mz=" << current_mz << " both";
113 }
114 else
115 {
116 // there is no counterpart
117 push_back({ExperimentalSpectrumDataPointType::native, it->x, 0});
119 symmetric_current_mz,
120 0});
121 qDebug() << "current_mz=" << current_mz << " symmetrics";
122 }
123
124 mz_current_indice++;
125 }
126
127 // we add a peak with NT mass (1.0078) if it is not detected, to give better
128 // chance to align the first amino acid in b if it is present
129 if(findMz(pappso::MPROTIUM) == itend)
130 {
131 push_back(
133 }
134
135 // We add the B peak corresponding to the precursor (complete peptide)
136 double precusorBion = m_targetMzSum - pappso::MASSH2O - pappso::MPROTIUM;
137
138 if(findMz(precusorBion) == itend)
139 {
140 push_back(
142 }
143
144 std::sort(begin(),
145 end(),
146 [](const ExperimentalSpectrumDataPoint &a,
147 const ExperimentalSpectrumDataPoint &b) {
148 return (a.symmetric_mz < b.symmetric_mz);
149 });
150
151 std::size_t i = 0;
152 for(auto &data_point : *this)
153 {
154 data_point.indice = i;
155 i++;
156 }
157}
const QString & getNativeId() const
MassSpectrumCstSPtr getMassSpectrumCstSPtr() const
Get the MassSpectrumCstSPtr.
uint getPrecursorCharge(bool *ok=nullptr) const
get precursor charge
const MassSpectrumId & getMassSpectrumId() const
Get the MassSpectrumId.
pappso_double getPrecursorMz(bool *ok=nullptr) const
get precursor mz
double getSymetricMz(double mz) const
compute the symmetric mass for debuggin purpose
std::vector< pappso::DataPoint >::const_iterator findMz(double mz)
find the correspondin mz in the mass spectrum (given the precision)
@ synthetic
does not correspond to existing peak, for computational purpose
@ both
both, the ion and the complement exists in the original spectrum
@ symmetric
new peak : computed symmetric mass from a corresponding native peak
const pappso_double MHPLUS(1.007276466879)
const pappso_double MPROTIUM(1.007825032241)
const pappso_double MASSH2O((MPROTIUM *2)+MASSOXYGEN)

References pappso::a, pappso::b, pappso::specglob::both, findMz(), pappso::QualifiedMassSpectrum::getMassSpectrumCstSPtr(), pappso::QualifiedMassSpectrum::getMassSpectrumId(), pappso::MassSpectrumId::getNativeId(), pappso::QualifiedMassSpectrum::getPrecursorCharge(), pappso::QualifiedMassSpectrum::getPrecursorMz(), getSymetricMz(), m_precursorMass, m_qualifiedMassSpectrum, m_targetMzSum, pappso::MASSH2O(), pappso::MHPLUS(), pappso::MPROTIUM(), pappso::specglob::native, pappso::specglob::symmetric, and pappso::specglob::synthetic.

Referenced by ExperimentalSpectrum().

◆ findMz()

std::vector< pappso::DataPoint >::const_iterator pappso::specglob::ExperimentalSpectrum::findMz ( double  mz)
private

find the correspondin mz in the mass spectrum (given the precision)

Definition at line 160 of file experimentalspectrum.cpp.

161{
163 auto itend = m_qualifiedMassSpectrum.getMassSpectrumCstSPtr().get()->end();
164 auto it = findFirstEqualOrGreaterX(
167 mz_range.lower());
168
169 if(it != itend)
170 {
171 if(it->x <= mz_range.upper())
172 {
173 return it;
174 }
175 }
176 return itend;
177}
std::vector< DataPoint >::iterator findFirstEqualOrGreaterX(std::vector< DataPoint >::iterator begin, std::vector< DataPoint >::iterator end, const double &value)
find the first element in which X is equal or greater than the value searched important : it implies ...
Definition trace.cpp:71

References pappso::findFirstEqualOrGreaterX(), pappso::QualifiedMassSpectrum::getMassSpectrumCstSPtr(), pappso::MzRange::lower(), m_precisionPtr, m_qualifiedMassSpectrum, pappso::mz, and pappso::MzRange::upper().

Referenced by createSymetricPeakList().

◆ getMassList() [1/2]

std::vector< double > pappso::specglob::ExperimentalSpectrum::getMassList ( ) const

Definition at line 186 of file experimentalspectrum.cpp.

187{
188 std::vector<double> mass_list;
189 for(const ExperimentalSpectrumDataPoint &n : *this)
190 {
191 mass_list.push_back(n.symmetric_mz);
192 }
193
194 return mass_list;
195}

◆ getMassList() [2/2]

std::vector< double > pappso::specglob::ExperimentalSpectrum::getMassList ( ExperimentalSpectrumDataPointType  type) const

Definition at line 204 of file experimentalspectrum.cpp.

205{
206 std::vector<double> mass_list;
207 for(const ExperimentalSpectrumDataPoint &n : *this)
208 {
209 if(n.type == type)
210 mass_list.push_back(n.symmetric_mz);
211 }
212
213 return mass_list;
214}

◆ getPrecursorMass()

double pappso::specglob::ExperimentalSpectrum::getPrecursorMass ( ) const

Definition at line 229 of file experimentalspectrum.cpp.

230{
231 return m_precursorMass;
232}

References m_precursorMass.

◆ getQualifiedMassSpectrum()

const pappso::QualifiedMassSpectrum & pappso::specglob::ExperimentalSpectrum::getQualifiedMassSpectrum ( ) const

Definition at line 278 of file experimentalspectrum.cpp.

279{
281}

References m_qualifiedMassSpectrum.

◆ getSymetricMz()

double pappso::specglob::ExperimentalSpectrum::getSymetricMz ( double  mz) const

compute the symmetric mass for debuggin purpose

Definition at line 198 of file experimentalspectrum.cpp.

199{
200 return m_targetMzSum - mz;
201}

References m_targetMzSum, and pappso::mz.

Referenced by createSymetricPeakList().

◆ getTargetMzSum()

double pappso::specglob::ExperimentalSpectrum::getTargetMzSum ( ) const

Definition at line 180 of file experimentalspectrum.cpp.

181{
182 return m_targetMzSum;
183}

References m_targetMzSum.

◆ reverseFindDiffMz()

std::vector< ExperimentalSpectrumDataPoint >::const_reverse_iterator pappso::specglob::ExperimentalSpectrum::reverseFindDiffMz ( std::size_t  start_position,
const pappso::MzRange targeted_mass_range 
) const

find the peak for wich mass difference from rbegin corresponds to aaTheoMass Find if a peak back in the peak list has a mass difference that corresponds to the targeted mass

Parameters
start_positionreverse iterator on the reference peak to look for mass difference from
targeted_mass_rangethe mass difference to look forconst pappso::PeptideSp peptide_sp
Returns
a reverse iterator on the peak (found) or the end of the search (not found)

Definition at line 235 of file experimentalspectrum.cpp.

237{
238
239 qDebug() << "start_position" << start_position
240 << " lookfor=" << aaTheoMzRange.getMz();
241 std::vector<ExperimentalSpectrumDataPoint>::const_reverse_iterator itrbegin =
242 rbegin() + (size() - 1 - start_position);
243
244 qDebug() << itrbegin->indice << "mz=" << itrbegin->symmetric_mz;
245 double eperimentalMzReference = itrbegin->symmetric_mz;
246 auto itrend = this->rend();
247 // We check all row from j to 0
248 qDebug();
249 for(auto itr = itrbegin + 1; itr != itrend; ++itr)
250 {
251 qDebug() << itr->indice;
252 double experimentalMzDifference =
253 eperimentalMzReference - itr->symmetric_mz;
254
255 if(experimentalMzDifference > aaTheoMzRange.upper())
256 {
257 // if we pass the mass of the theoretical amino acid, we stop to not
258 // over
259 // calculate
260 qDebug() << experimentalMzDifference << ">" << aaTheoMzRange.upper();
261 return itrend;
262 }
263 else if(experimentalMzDifference < aaTheoMzRange.lower())
264 {
265 continue;
266 }
267
268 qDebug() << itr->indice << " diff=" << experimentalMzDifference;
269 // if we found that j-k give an amino acid, we keep k value
270 return itr;
271 }
272 qDebug() << "rend";
273 return itrend; // a value of -1 to show that
274 // there is no k value
275}

References pappso::MzRange::getMz(), pappso::MzRange::lower(), and pappso::MzRange::upper().

Referenced by pappso::specglob::SpectralAlignment::fillMatricesWithScores().

◆ toString()

QString pappso::specglob::ExperimentalSpectrum::toString ( ) const

Definition at line 217 of file experimentalspectrum.cpp.

218{
219 QStringList all_element;
220 for(const ExperimentalSpectrumDataPoint &n : *this)
221 {
222 all_element
223 << QString("%1 %2").arg(n.symmetric_mz).arg((std::uint8_t)n.type);
224 }
225 return QString("[%1]").arg(all_element.join("] ["));
226}

Member Data Documentation

◆ m_precisionPtr

pappso::PrecisionPtr pappso::specglob::ExperimentalSpectrum::m_precisionPtr
private

Definition at line 134 of file experimentalspectrum.h.

Referenced by ExperimentalSpectrum(), ExperimentalSpectrum(), and findMz().

◆ m_precursorMass

double pappso::specglob::ExperimentalSpectrum::m_precursorMass
private

Definition at line 133 of file experimentalspectrum.h.

Referenced by createSymetricPeakList(), and getPrecursorMass().

◆ m_qualifiedMassSpectrum

pappso::QualifiedMassSpectrum pappso::specglob::ExperimentalSpectrum::m_qualifiedMassSpectrum
private

◆ m_targetMzSum

double pappso::specglob::ExperimentalSpectrum::m_targetMzSum
private

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