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 (const XtandemHyperscore &other)
 
 ~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() [1/2]

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:386
@ 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:49
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() [2/2]

pappso::XtandemHyperscore::XtandemHyperscore ( const XtandemHyperscore other)

Definition at line 153 of file xtandemhyperscore.cpp.

154 {
155  _ion_count = other._ion_count;
156  _proto_hyperscore = other._proto_hyperscore;
157  _refine_spectrum_synthesis = other._refine_spectrum_synthesis;
158 }

References _ion_count, _proto_hyperscore, and _refine_spectrum_synthesis.

◆ ~XtandemHyperscore()

pappso::XtandemHyperscore::~XtandemHyperscore ( )

Definition at line 165 of file xtandemhyperscore.cpp.

166 {
167 }

Member Function Documentation

◆ getHyperscore()

pappso_double pappso::XtandemHyperscore::getHyperscore ( ) const

Definition at line 261 of file xtandemhyperscore.cpp.

262 {
263  try
264  {
265  qDebug() << " _proto_hyperscore=" << _proto_hyperscore;
266  double hyperscore = (log10(_proto_hyperscore) * 4);
267  if(hyperscore < 0)
268  return 0;
269  return hyperscore;
270  }
271  catch(PappsoException &exception_pappso)
272  {
273  QString errorStr =
274  QObject::tr("ERROR in getHyperscore, PAPPSO exception:\n%1")
275  .arg(exception_pappso.qwhat());
276  qDebug() << "XtandemHyperscore::getHyperscore PappsoException :\n"
277  << errorStr;
278  throw PappsoException(errorStr);
279  }
280  catch(std::exception &exception_std)
281  {
282  QString errorStr =
283  QObject::tr("ERROR in getHyperscore, std exception:\n%1")
284  .arg(exception_std.what());
285  qDebug() << "XtandemHyperscore::getHyperscore std::exception :\n"
286  << errorStr;
287  throw PappsoException(errorStr);
288  }
289 }

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

◆ getMatchedIons()

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

Definition at line 161 of file xtandemhyperscore.cpp.

162 {
163  return _ion_count.at(ion_type);
164 }

References _ion_count.

◆ getXtandemPredictedIonIntensityFactor()

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

Definition at line 201 of file xtandemhyperscore.cpp.

205 {
206  unsigned int Pi(1);
207 
208  char last_aa_nter('_'), last_aa_cter('_');
209 
210  if(ion_direction == PeptideDirection::Nter)
211  {
212  last_aa_nter = sequence[ion_size - 1].toLatin1();
213  last_aa_cter = sequence[ion_size].toLatin1();
214  if(ion_size == 2)
215  {
216  if(last_aa_nter == 'P')
217  {
218  Pi *= 10;
219  }
220  else
221  {
222  Pi *= 3;
223  }
224  }
225  }
226  else
227  {
228  unsigned int offset(sequence.size() - ion_size);
229  last_aa_nter = sequence[offset - 1].toLatin1();
230  last_aa_cter = sequence[offset].toLatin1();
231  if((offset) == 2)
232  {
233  if(last_aa_nter == 'P')
234  {
235  Pi *= 10;
236  }
237  else
238  {
239  Pi *= 3;
240  }
241  }
242  }
243  // QDebug << " last_aa_nter=" << QChar(last_aa_nter) << "
244  // _aa_ion_factor_b[last_aa_nter]="s ;
245  qDebug() << PeptideFragment::getPeptideIonDirectionName(ion_direction)
246  << " last_aa_nter=" << last_aa_nter
247  << " _aa_ion_factor_b[last_aa_nter]="
248  << _aa_ion_factor_b[last_aa_nter] << " last_aa_cter=" << last_aa_cter
249  << " _aa_ion_factor_y[last_aa_cter]="
250  << _aa_ion_factor_y[last_aa_cter];
252  {
253  Pi *= _aa_ion_factor_b[last_aa_nter] * _aa_ion_factor_y[last_aa_cter];
254  }
255 
256  return Pi;
257 }
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 70 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 69 of file xtandemhyperscore.h.

Referenced by getXtandemPredictedIonIntensityFactor().

◆ _ion_count

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

Definition at line 67 of file xtandemhyperscore.h.

Referenced by XtandemHyperscore(), and getMatchedIons().

◆ _proto_hyperscore

pappso_double pappso::XtandemHyperscore::_proto_hyperscore
private

Definition at line 66 of file xtandemhyperscore.h.

Referenced by XtandemHyperscore(), and getHyperscore().

◆ _refine_spectrum_synthesis

bool pappso::XtandemHyperscore::_refine_spectrum_synthesis
private

Definition at line 59 of file xtandemhyperscore.h.

Referenced by XtandemHyperscore(), and getXtandemPredictedIonIntensityFactor().


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