libpappsomspp
Library for mass spectrometry
pappso::XtandemHyperscoreBis Class Reference

#include <xtandemhyperscorebis.h>

Public Member Functions

 XtandemHyperscoreBis (bool refine_spectrum_synthesis, PrecisionPtr precision, const std::vector< PeptideIon > &ion_list)
 
 ~XtandemHyperscoreBis ()
 
pappso_double getHyperscore () const
 
unsigned int getMatchedIons (PeptideIon ion_type) const
 
void reset ()
 
bool computeXtandemHyperscore (const MassSpectrum &spectrum, const Peptide &peptide, unsigned int parent_charge)
 
unsigned int getTotalMatchedIons () const
 

Private Types

using AaFactorMap = std::map< char, pappso_double >
 

Private Member Functions

unsigned int getXtandemPredictedIonIntensityFactor (const QString &sequence, PeptideIon ion_type, unsigned int size) const
 

Private Attributes

bool m_isRefineSpectrumSynthesis
 
PrecisionPtr mp_precision
 
std::vector< PeptideIonm_ionList
 
unsigned int m_totalMatchedIons = 0
 
unsigned int m_ionCount [PEPTIDE_ION_TYPE_COUNT] = {0}
 
pappso_double m_protoHyperscore
 

Static Private Attributes

static AaFactorMap m_aaIonFactorY
 
static AaFactorMap m_aaIonFactorBb
 

Detailed Description

Definition at line 40 of file xtandemhyperscorebis.h.

Member Typedef Documentation

◆ AaFactorMap

Definition at line 42 of file xtandemhyperscorebis.h.

Constructor & Destructor Documentation

◆ XtandemHyperscoreBis()

XtandemHyperscoreBis::XtandemHyperscoreBis ( bool  refine_spectrum_synthesis,
PrecisionPtr  precision,
const std::vector< PeptideIon > &  ion_list 
)

Definition at line 50 of file xtandemhyperscorebis.cpp.

54 {
55 
56  m_isRefineSpectrumSynthesis = refine_spectrum_synthesis;
57  mp_precision = precision;
58  m_ionList = ion_list;
60 }
std::vector< PeptideIon > m_ionList

References m_ionList, m_isRefineSpectrumSynthesis, m_totalMatchedIons, and mp_precision.

◆ ~XtandemHyperscoreBis()

XtandemHyperscoreBis::~XtandemHyperscoreBis ( )

Definition at line 62 of file xtandemhyperscorebis.cpp.

63 {
64 }

Member Function Documentation

◆ computeXtandemHyperscore()

bool XtandemHyperscoreBis::computeXtandemHyperscore ( const MassSpectrum spectrum,
const Peptide peptide,
unsigned int  parent_charge 
)

Definition at line 85 of file xtandemhyperscorebis.cpp.

88 {
89  try
90  {
91 
92  unsigned int max_charge = parent_charge;
93  if(parent_charge > 1)
94  {
95  max_charge = parent_charge - 1;
96  }
97  // PeptideSpectrumMatch psm (spectrum, peptideSp, max_charge, precision,
98  // ion_list);
99 
100  PeptideRawFragmentMasses calc_mass_list(peptide,
102 
103  std::vector<SimplePeakIonMatch> match_products;
104  unsigned int charge_i;
105  for(PeptideIon &ion : m_ionList)
106  {
107  charge_i = max_charge;
108  while(charge_i > 0)
109  {
110  calc_mass_list.pushBackMatchSpectrum(
111  match_products, spectrum, mp_precision, ion, charge_i);
112  charge_i--;
113  }
114  }
115  m_totalMatchedIons = match_products.size();
116  if(m_totalMatchedIons == 0)
117  {
118  m_protoHyperscore = 0;
119  }
120  else
121  {
122 
123  unsigned int charge_ion_count[5][20] = {0};
124 
125  pappso_double charge_dot_product[5] = {0};
126 
127  QString sequence = peptide.getSequence();
128 
129  for(SimplePeakIonMatch &peptide_ion_match : match_products)
130  {
131  charge_dot_product[peptide_ion_match.ion_charge] +=
132  peptide_ion_match.peak.y *
134  sequence,
135  peptide_ion_match.ion_type,
136  peptide_ion_match.ion_size);
137  charge_ion_count[peptide_ion_match.ion_charge]
138  [(std::int8_t)peptide_ion_match.ion_type] += 1;
139  m_ionCount[(std::int8_t)peptide_ion_match.ion_type] += 1;
140  }
141  // take the 2 best component
142  pappso_double sum_intensity = 0;
143  for(unsigned int i = 1; i <= max_charge; i++)
144  {
145  sum_intensity += charge_dot_product[i];
146  }
147  for(auto count : m_ionCount)
148  {
149  sum_intensity *= factorial(count);
150  }
151 
152  m_protoHyperscore = sum_intensity;
153  }
154  return true;
155  }
156  catch(PappsoException &exception_pappso)
157  {
158  QString errorStr =
159  QObject::tr("ERROR computing hyperscore, PAPPSO exception:\n%1")
160  .arg(exception_pappso.qwhat());
161  qDebug() << "XtandemHyperscore::XtandemHyperscore PappsoException :\n"
162  << errorStr;
163  throw PappsoException(errorStr);
164  }
165  catch(std::exception &exception_std)
166  {
167  QString errorStr =
168  QObject::tr("ERROR computing hyperscore, std exception:\n%1")
169  .arg(exception_std.what());
170  qDebug() << "XtandemHyperscore::XtandemHyperscore std::exception :\n"
171  << errorStr;
172  throw PappsoException(errorStr);
173  }
174 }
virtual const QString & qwhat() const
const QString getSequence() const override
print amino acid sequence without modifications
Definition: peptide.cpp:155
unsigned int getXtandemPredictedIonIntensityFactor(const QString &sequence, PeptideIon ion_type, unsigned int size) const
unsigned int m_ionCount[PEPTIDE_ION_TYPE_COUNT]
PeptideIon
PeptideIon enum defines all types of ions (Nter or Cter)
Definition: types.h:386
double pappso_double
A type definition for doubles.
Definition: types.h:49
unsigned int factorial(unsigned int n)

References pappso::factorial(), pappso::full, pappso::Peptide::getSequence(), getXtandemPredictedIonIntensityFactor(), m_ionCount, m_ionList, m_protoHyperscore, m_totalMatchedIons, mp_precision, pappso::PeptideRawFragmentMasses::pushBackMatchSpectrum(), and pappso::PappsoException::qwhat().

◆ getHyperscore()

pappso_double XtandemHyperscoreBis::getHyperscore ( ) const

Definition at line 269 of file xtandemhyperscorebis.cpp.

270 {
271  try
272  {
273  if(m_protoHyperscore == 0)
274  return 0.0;
275  return (log10(m_protoHyperscore) * 4);
276  }
277  catch(PappsoException &exception_pappso)
278  {
279  QString errorStr =
280  QObject::tr("ERROR in getHyperscore, PAPPSO exception:\n%1")
281  .arg(exception_pappso.qwhat());
282  qDebug() << "XtandemHyperscore::getHyperscore PappsoException :\n"
283  << errorStr;
284  throw PappsoException(errorStr);
285  }
286  catch(std::exception &exception_std)
287  {
288  QString errorStr =
289  QObject::tr("ERROR in getHyperscore, std exception:\n%1")
290  .arg(exception_std.what());
291  qDebug() << "XtandemHyperscore::getHyperscore std::exception :\n"
292  << errorStr;
293  throw PappsoException(errorStr);
294  }
295 }

References pappso::log10, m_protoHyperscore, and pappso::PappsoException::qwhat().

◆ getMatchedIons()

unsigned int XtandemHyperscoreBis::getMatchedIons ( PeptideIon  ion_type) const

Definition at line 67 of file xtandemhyperscorebis.cpp.

68 {
69  return m_ionCount[(std::int8_t)ion_type];
70 }

References m_ionCount.

◆ getTotalMatchedIons()

unsigned int XtandemHyperscoreBis::getTotalMatchedIons ( ) const

Definition at line 263 of file xtandemhyperscorebis.cpp.

264 {
265  return m_totalMatchedIons;
266 }

References m_totalMatchedIons.

◆ getXtandemPredictedIonIntensityFactor()

unsigned int XtandemHyperscoreBis::getXtandemPredictedIonIntensityFactor ( const QString &  sequence,
PeptideIon  ion_type,
unsigned int  size 
) const
private

Definition at line 208 of file xtandemhyperscorebis.cpp.

210 {
211  unsigned int Pi(1);
212 
213  char last_aa_nter('_'), last_aa_cter('_');
214 
215  if(peptideIonIsNter(ion_type))
216  {
217  last_aa_nter = sequence[ion_size - 1].toLatin1();
218  last_aa_cter = sequence[ion_size].toLatin1();
219  if(ion_size == 2)
220  {
221  if(last_aa_nter == 'P')
222  {
223  Pi *= 10;
224  }
225  else
226  {
227  Pi *= 3;
228  }
229  }
230  }
231  else
232  {
233  unsigned int offset(sequence.size() - ion_size);
234  last_aa_nter = sequence[offset - 1].toLatin1();
235  last_aa_cter = sequence[offset].toLatin1();
236  if((offset) == 2)
237  {
238  if(last_aa_nter == 'P')
239  {
240  Pi *= 10;
241  }
242  else
243  {
244  Pi *= 3;
245  }
246  }
247  }
248  // QDebug << " last_aa_nter=" << QChar(last_aa_nter) << "
249  // m_aaIonFactorBb[last_aa_nter]="s ;
250  // qDebug() << PeptideFragment::getPeptideIonDirectionName(ion_direction) << "
251  // last_aa_nter=" << last_aa_nter << " m_aaIonFactorBb[last_aa_nter]=" <<
252  // m_aaIonFactorBb[last_aa_nter] << " last_aa_cter=" << last_aa_cter << "
253  // m_aaIonFactorY[last_aa_cter]=" << m_aaIonFactorY[last_aa_cter];
255  {
256  Pi *= m_aaIonFactorBb[last_aa_nter] * m_aaIonFactorY[last_aa_cter];
257  }
258 
259  return Pi;
260 }
bool peptideIonIsNter(PeptideIon ion_type)
tells if an ion is Nter
Definition: peptide.cpp:60

References m_aaIonFactorBb, m_aaIonFactorY, m_isRefineSpectrumSynthesis, and pappso::peptideIonIsNter().

Referenced by computeXtandemHyperscore().

◆ reset()

void XtandemHyperscoreBis::reset ( )

Definition at line 74 of file xtandemhyperscorebis.cpp.

75 {
76 
78 
81 }
#define PEPTIDE_ION_TYPE_COUNT
only usefull for inernal usefull DO not change this value : it is used to define static array size
Definition: types.h:406

References m_ionCount, m_protoHyperscore, m_totalMatchedIons, and PEPTIDE_ION_TYPE_COUNT.

Member Data Documentation

◆ m_aaIonFactorBb

XtandemHyperscoreBis::AaFactorMap XtandemHyperscoreBis::m_aaIonFactorBb
staticprivate
Initial value:
= [] {
for(long c = 64; c < 126; c++)
{
ret.insert(std::pair<char, pappso_double>(c, pappso_double(1.0)));
}
ret['D'] = pappso_double(5.0);
ret['N'] = pappso_double(2.0);
ret['V'] = pappso_double(3.0);
ret['E'] = pappso_double(3.0);
ret['Q'] = pappso_double(2.0);
ret['I'] = pappso_double(3.0);
ret['L'] = pappso_double(3.0);
return ret;
}()
std::map< char, pappso_double > AaFactorMap

Definition at line 59 of file xtandemhyperscorebis.h.

Referenced by getXtandemPredictedIonIntensityFactor().

◆ m_aaIonFactorY

XtandemHyperscoreBis::AaFactorMap XtandemHyperscoreBis::m_aaIonFactorY
staticprivate
Initial value:
= [] {
for(long c = 64; c < 126; c++)
{
ret.insert(std::pair<char, pappso_double>(c, pappso_double(1.0)));
}
ret['P'] = pappso_double(5.0);
return ret;
}()

Definition at line 58 of file xtandemhyperscorebis.h.

Referenced by getXtandemPredictedIonIntensityFactor().

◆ m_ionCount

unsigned int pappso::XtandemHyperscoreBis::m_ionCount[PEPTIDE_ION_TYPE_COUNT] = {0}
private

Definition at line 53 of file xtandemhyperscorebis.h.

Referenced by computeXtandemHyperscore(), getMatchedIons(), and reset().

◆ m_ionList

std::vector<PeptideIon> pappso::XtandemHyperscoreBis::m_ionList
private

Definition at line 50 of file xtandemhyperscorebis.h.

Referenced by XtandemHyperscoreBis(), and computeXtandemHyperscore().

◆ m_isRefineSpectrumSynthesis

bool pappso::XtandemHyperscoreBis::m_isRefineSpectrumSynthesis
private

◆ m_protoHyperscore

pappso_double pappso::XtandemHyperscoreBis::m_protoHyperscore
private

Definition at line 56 of file xtandemhyperscorebis.h.

Referenced by computeXtandemHyperscore(), getHyperscore(), and reset().

◆ m_totalMatchedIons

unsigned int pappso::XtandemHyperscoreBis::m_totalMatchedIons = 0
private

◆ mp_precision

PrecisionPtr pappso::XtandemHyperscoreBis::mp_precision
private

Definition at line 49 of file xtandemhyperscorebis.h.

Referenced by XtandemHyperscoreBis(), and computeXtandemHyperscore().


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