libpappsomspp
Library for mass spectrometry
pappso::XtandemHyperscore Class Reference

#include <xtandemhyperscore.h>

Public Types

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

Public Member Functions

 XtandemHyperscore (const MassSpectrum &spectrum, pappso::PeptideSp peptideSp, unsigned int parent_charge, PrecisionPtr precision, std::list< PeptideIon > ion_list, bool refine_spectrum_synthesis)
 
 ~XtandemHyperscore ()
 
pappso_double getHyperscore () const
 
unsigned int getMatchedIons (PeptideIon ion_type) const
 

Private Member Functions

unsigned int getXtandemPredictedIonIntensityFactor (const QString &sequence, PeptideDirection ion_direction, unsigned int ion_size) const
 

Private Attributes

bool _refine_spectrum_synthesis
 
pappso_double _proto_hyperscore
 
std::map< PeptideIon, unsigned int > _ion_count
 

Static Private Attributes

static AaFactorMap _aa_ion_factor_y
 
static AaFactorMap _aa_ion_factor_b
 

Detailed Description

Definition at line 42 of file xtandemhyperscore.h.

Member Typedef Documentation

◆ AaFactorMap

Definition at line 45 of file xtandemhyperscore.h.

Constructor & Destructor Documentation

◆ XtandemHyperscore()

pappso::XtandemHyperscore::XtandemHyperscore ( const MassSpectrum spectrum,
pappso::PeptideSp  peptideSp,
unsigned int  parent_charge,
PrecisionPtr  precision,
std::list< PeptideIon ion_list,
bool  refine_spectrum_synthesis 
)

Definition at line 51 of file xtandemhyperscore.cpp.

57  : _refine_spectrum_synthesis(refine_spectrum_synthesis)
58 {
59  try
60  {
61  /*
62  if ((peptide_ion_sp.get()->getPeptideIonType() == PeptideIon::c) ||
63  (peptide_ion_sp.get()->getPeptideIonType() == PeptideIon::z)) {
64  if(current_max_charge > 2) {
65  current_max_charge--;
66  }
67  }*/
68  unsigned int max_charge = parent_charge;
69  if(parent_charge > 1)
70  {
71  max_charge = parent_charge - 1;
72  }
73  PeptideSpectrumMatch psm(
74  spectrum, peptideSp, max_charge, precision, ion_list);
75 
76  _ion_count = {{PeptideIon::a, 0},
77  {PeptideIon::b, 0},
78  {PeptideIon::bo, 0},
79  {PeptideIon::bstar, 0},
80  {PeptideIon::c, 0},
81  {PeptideIon::y, 0},
82  {PeptideIon::yo, 0},
83  {PeptideIon::ystar, 0},
84  {PeptideIon::z, 0}};
85 
86  std::map<PeptideIon, unsigned int> ion_count;
87  for(auto &&ion_type : ion_list)
88  {
89  ion_count.insert(std::pair<PeptideIon, unsigned int>(ion_type, 0));
90  }
91 
92  std::map<unsigned int, pappso_double> charge_dot_product;
93  std::map<unsigned int, std::map<PeptideIon, unsigned int>>
94  charge_ion_count;
95  for(unsigned int i = 1; i <= max_charge; i++)
96  {
97  charge_dot_product.insert(
98  std::pair<unsigned int, pappso_double>(i, 0));
99  charge_ion_count.insert(
100  std::pair<unsigned int, std::map<PeptideIon, unsigned int>>(
101  i, ion_count));
102  }
103  QString sequence = peptideSp.get()->getSequence();
104  for(auto &&peptide_ion_match : psm)
105  {
106  PeptideIon ion_type = peptide_ion_match.getPeptideIonType();
107  unsigned int charge = peptide_ion_match.getCharge();
108  charge_dot_product[charge] +=
109  peptide_ion_match.getPeak().y *
111  sequence,
112  peptide_ion_match.getPeptideIonDirection(),
113  peptide_ion_match.getPeptideFragmentIonSp().get()->size());
114  charge_ion_count[charge][ion_type] += 1;
115  _ion_count[ion_type] += 1;
116  }
117 
118  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
119  << " _ion_count[PeptideIon::y]=" << _ion_count[PeptideIon::y];
120  // take the 2 best component
121  pappso_double sum_intensity = 0;
122  for(unsigned int i = 1; i <= max_charge; i++)
123  {
124  sum_intensity += charge_dot_product[i];
125  }
126  for(auto count : _ion_count)
127  {
128  sum_intensity *= factorial(count.second);
129  }
130 
131  _proto_hyperscore = sum_intensity;
132  }
133  catch(PappsoException &exception_pappso)
134  {
135  QString errorStr =
136  QObject::tr("ERROR computing hyperscore, PAPPSO exception:\n%1")
137  .arg(exception_pappso.qwhat());
138  qDebug() << "XtandemHyperscore::XtandemHyperscore PappsoException :\n"
139  << errorStr;
140  throw PappsoException(errorStr);
141  }
142  catch(std::exception &exception_std)
143  {
144  QString errorStr =
145  QObject::tr("ERROR computing hyperscore, std exception:\n%1")
146  .arg(exception_std.what());
147  qDebug() << "XtandemHyperscore::XtandemHyperscore std::exception :\n"
148  << errorStr;
149  throw PappsoException(errorStr);
150  }
151 }
unsigned int getXtandemPredictedIonIntensityFactor(const QString &sequence, PeptideDirection ion_direction, unsigned int ion_size) const
std::map< PeptideIon, unsigned int > _ion_count
PeptideIon
PeptideIon enum defines all types of ions (Nter or Cter)
Definition: types.h:385
@ a
Nter aldimine ions.
@ y
Cter amino ions.
@ c
Nter amino ions.
@ ystar
Cter amino ions + NH3 loss.
@ yo
Cter amino ions + H2O loss.
@ bstar
Nter acylium ions + NH3 loss.
@ b
Nter acylium ions.
@ bo
Nter acylium ions + H2O loss.
@ z
Cter carbocations.
double pappso_double
A type definition for doubles.
Definition: types.h:48
unsigned int factorial(unsigned int n)

References _ion_count, _proto_hyperscore, pappso::a, pappso::b, pappso::bo, pappso::bstar, pappso::c, pappso::factorial(), getXtandemPredictedIonIntensityFactor(), pappso::PappsoException::qwhat(), pappso::y, pappso::yo, pappso::ystar, and pappso::z.

◆ ~XtandemHyperscore()

pappso::XtandemHyperscore::~XtandemHyperscore ( )

Definition at line 158 of file xtandemhyperscore.cpp.

159 {
160 }

Member Function Documentation

◆ getHyperscore()

pappso_double pappso::XtandemHyperscore::getHyperscore ( ) const

Definition at line 254 of file xtandemhyperscore.cpp.

255 {
256  try
257  {
258  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
259  << " _proto_hyperscore=" << _proto_hyperscore;
260  return (log10(_proto_hyperscore) * 4);
261  }
262  catch(PappsoException &exception_pappso)
263  {
264  QString errorStr =
265  QObject::tr("ERROR in getHyperscore, PAPPSO exception:\n%1")
266  .arg(exception_pappso.qwhat());
267  qDebug() << "XtandemHyperscore::getHyperscore PappsoException :\n"
268  << errorStr;
269  throw PappsoException(errorStr);
270  }
271  catch(std::exception &exception_std)
272  {
273  QString errorStr =
274  QObject::tr("ERROR in getHyperscore, std exception:\n%1")
275  .arg(exception_std.what());
276  qDebug() << "XtandemHyperscore::getHyperscore std::exception :\n"
277  << errorStr;
278  throw PappsoException(errorStr);
279  }
280 }

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

◆ getMatchedIons()

unsigned int pappso::XtandemHyperscore::getMatchedIons ( PeptideIon  ion_type) const

Definition at line 154 of file xtandemhyperscore.cpp.

155 {
156  return _ion_count.at(ion_type);
157 }

References _ion_count.

◆ getXtandemPredictedIonIntensityFactor()

unsigned int pappso::XtandemHyperscore::getXtandemPredictedIonIntensityFactor ( const QString &  sequence,
PeptideDirection  ion_direction,
unsigned int  ion_size 
) const
private

Definition at line 194 of file xtandemhyperscore.cpp.

198 {
199  unsigned int Pi(1);
200 
201  char last_aa_nter('_'), last_aa_cter('_');
202 
203  if(ion_direction == PeptideDirection::Nter)
204  {
205  last_aa_nter = sequence[ion_size - 1].toLatin1();
206  last_aa_cter = sequence[ion_size].toLatin1();
207  if(ion_size == 2)
208  {
209  if(last_aa_nter == 'P')
210  {
211  Pi *= 10;
212  }
213  else
214  {
215  Pi *= 3;
216  }
217  }
218  }
219  else
220  {
221  unsigned int offset(sequence.size() - ion_size);
222  last_aa_nter = sequence[offset - 1].toLatin1();
223  last_aa_cter = sequence[offset].toLatin1();
224  if((offset) == 2)
225  {
226  if(last_aa_nter == 'P')
227  {
228  Pi *= 10;
229  }
230  else
231  {
232  Pi *= 3;
233  }
234  }
235  }
236  // QDebug << " last_aa_nter=" << QChar(last_aa_nter) << "
237  // _aa_ion_factor_b[last_aa_nter]="s ;
238  qDebug() << PeptideFragment::getPeptideIonDirectionName(ion_direction)
239  << " last_aa_nter=" << last_aa_nter
240  << " _aa_ion_factor_b[last_aa_nter]="
241  << _aa_ion_factor_b[last_aa_nter] << " last_aa_cter=" << last_aa_cter
242  << " _aa_ion_factor_y[last_aa_cter]="
243  << _aa_ion_factor_y[last_aa_cter];
245  {
246  Pi *= _aa_ion_factor_b[last_aa_nter] * _aa_ion_factor_y[last_aa_cter];
247  }
248 
249  return Pi;
250 }
static const QString getPeptideIonDirectionName(PeptideDirection direction)
static AaFactorMap _aa_ion_factor_y
static AaFactorMap _aa_ion_factor_b

References _aa_ion_factor_b, _aa_ion_factor_y, _refine_spectrum_synthesis, pappso::PeptideFragment::getPeptideIonDirectionName(), and pappso::Nter.

Referenced by XtandemHyperscore().

Member Data Documentation

◆ _aa_ion_factor_b

XtandemHyperscore::AaFactorMap pappso::XtandemHyperscore::_aa_ion_factor_b
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 69 of file xtandemhyperscore.h.

Referenced by getXtandemPredictedIonIntensityFactor().

◆ _aa_ion_factor_y

XtandemHyperscore::AaFactorMap pappso::XtandemHyperscore::_aa_ion_factor_y
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 68 of file xtandemhyperscore.h.

Referenced by getXtandemPredictedIonIntensityFactor().

◆ _ion_count

std::map<PeptideIon, unsigned int> pappso::XtandemHyperscore::_ion_count
private

Definition at line 66 of file xtandemhyperscore.h.

Referenced by XtandemHyperscore(), and getMatchedIons().

◆ _proto_hyperscore

pappso_double pappso::XtandemHyperscore::_proto_hyperscore
private

Definition at line 65 of file xtandemhyperscore.h.

Referenced by XtandemHyperscore(), and getHyperscore().

◆ _refine_spectrum_synthesis

bool pappso::XtandemHyperscore::_refine_spectrum_synthesis
private

Definition at line 58 of file xtandemhyperscore.h.

Referenced by getXtandemPredictedIonIntensityFactor().


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