libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
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< Enums::PeptideIon > ion_list, bool refine_spectrum_synthesis)
 XtandemHyperscore (const XtandemHyperscore &other)
 ~XtandemHyperscore ()
pappso_double getHyperscore () const
unsigned int getMatchedIons (Enums::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< Enums::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< Enums::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() == Enums::PeptideIon::c) ||
63 (peptide_ion_sp.get()->getPeptideIonType() == Enums::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(spectrum, peptideSp, max_charge, precision, ion_list);
74
84
85 std::map<Enums::PeptideIon, unsigned int> ion_count;
86 for(auto &&ion_type : ion_list)
87 {
88 ion_count.insert(std::pair<Enums::PeptideIon, unsigned int>(ion_type, 0));
89 }
90
91 std::map<unsigned int, pappso_double> charge_dot_product;
92 std::map<unsigned int, std::map<Enums::PeptideIon, unsigned int>> charge_ion_count;
93 for(unsigned int i = 1; i <= max_charge; i++)
94 {
95 charge_dot_product.insert(std::pair<unsigned int, pappso_double>(i, 0));
96 charge_ion_count.insert(
97 std::pair<unsigned int, std::map<Enums::PeptideIon, unsigned int>>(i, ion_count));
98 }
99 QString sequence = peptideSp.get()->getSequence();
100 for(auto &&peptide_ion_match : psm)
101 {
102 Enums::PeptideIon ion_type = peptide_ion_match.getPeptideIonType();
103 unsigned int charge = peptide_ion_match.getCharge();
104 charge_dot_product[charge] +=
105 peptide_ion_match.getPeak().y *
107 sequence,
108 peptide_ion_match.getPeptideIonDirection(),
109 peptide_ion_match.getPeptideFragmentIonSp().get()->size());
110 charge_ion_count[charge][ion_type] += 1;
111 _ion_count[ion_type] += 1;
112 }
113
114 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
115 << " _ion_count[Enums::PeptideIon::y]=" << _ion_count[Enums::PeptideIon::y];
116 // take the 2 best component
117 pappso_double sum_intensity = 0;
118 for(unsigned int i = 1; i <= max_charge; i++)
119 {
120 sum_intensity += charge_dot_product[i];
121 }
122 for(auto count : _ion_count)
123 {
124 sum_intensity *= factorial(count.second);
125 }
126
127 _proto_hyperscore = sum_intensity;
128 }
129 catch(PappsoException &exception_pappso)
130 {
131 QString errorStr = QObject::tr("ERROR computing hyperscore, PAPPSO exception:\n%1")
132 .arg(exception_pappso.qwhat());
133 qDebug() << "XtandemHyperscore::XtandemHyperscore PappsoException :\n" << errorStr;
134 throw PappsoException(errorStr);
135 }
136 catch(std::exception &exception_std)
137 {
138 QString errorStr =
139 QObject::tr("ERROR computing hyperscore, std exception:\n%1").arg(exception_std.what());
140 qDebug() << "XtandemHyperscore::XtandemHyperscore std::exception :\n" << errorStr;
141 throw PappsoException(errorStr);
142 }
143}
unsigned int getXtandemPredictedIonIntensityFactor(const QString &sequence, PeptideDirection ion_direction, unsigned int ion_size) const
std::map< Enums::PeptideIon, unsigned int > _ion_count
PeptideIon
Enums::PeptideIon enum defines all types of ions (Nter or Cter).
Definition types.h:286
@ a
Nter aldimine ions.
Definition types.h:290
@ y
Cter amino ions.
Definition types.h:295
@ c
Nter amino ions.
Definition types.h:294
@ ystar
Cter amino ions + NH3 loss.
Definition types.h:296
@ yo
Cter amino ions + H2O loss.
Definition types.h:297
@ bstar
Nter acylium ions + NH3 loss.
Definition types.h:288
@ b
Nter acylium ions.
Definition types.h:287
@ bo
Nter acylium ions + H2O loss.
Definition types.h:289
@ z
Cter carbocations.
Definition types.h:298
double pappso_double
A type definition for doubles.
Definition types.h:60
unsigned int factorial(unsigned int n)

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

Referenced by XtandemHyperscore().

◆ XtandemHyperscore() [2/2]

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

Definition at line 145 of file xtandemhyperscore.cpp.

146{
147 _ion_count = other._ion_count;
148 _proto_hyperscore = other._proto_hyperscore;
149 _refine_spectrum_synthesis = other._refine_spectrum_synthesis;
150}

References XtandemHyperscore(), _ion_count, _proto_hyperscore, and _refine_spectrum_synthesis.

◆ ~XtandemHyperscore()

pappso::XtandemHyperscore::~XtandemHyperscore ( )

Definition at line 157 of file xtandemhyperscore.cpp.

158{
159}

Member Function Documentation

◆ getHyperscore()

pappso_double pappso::XtandemHyperscore::getHyperscore ( ) const

Definition at line 251 of file xtandemhyperscore.cpp.

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

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

Referenced by pappso::cbor::psm::PsmFeaturesScan::process().

◆ getMatchedIons()

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

Definition at line 153 of file xtandemhyperscore.cpp.

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

References _ion_count.

◆ getXtandemPredictedIonIntensityFactor()

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

Definition at line 193 of file xtandemhyperscore.cpp.

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

Definition at line 67 of file xtandemhyperscore.h.

Referenced by XtandemHyperscore(), XtandemHyperscore(), and getMatchedIons().

◆ _proto_hyperscore

pappso_double pappso::XtandemHyperscore::_proto_hyperscore
private

Definition at line 66 of file xtandemhyperscore.h.

Referenced by XtandemHyperscore(), XtandemHyperscore(), and getHyperscore().

◆ _refine_spectrum_synthesis

bool pappso::XtandemHyperscore::_refine_spectrum_synthesis
private

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