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

#include <xtandemhyperscorebis.h>

Public Member Functions

 XtandemHyperscoreBis (bool refine_spectrum_synthesis, PrecisionPtr precision, const std::vector< Enums::PeptideIon > &ion_list)
 ~XtandemHyperscoreBis ()
pappso_double getHyperscore () const
unsigned int getMatchedIons (Enums::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, Enums::PeptideIon ion_type, unsigned int size) const

Private Attributes

bool m_isRefineSpectrumSynthesis
PrecisionPtr mp_precision
std::vector< Enums::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< Enums::PeptideIon > & ion_list )

Definition at line 50 of file xtandemhyperscorebis.cpp.

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

References m_ionList, m_isRefineSpectrumSynthesis, m_totalMatchedIons, and mp_precision.

◆ ~XtandemHyperscoreBis()

XtandemHyperscoreBis::~XtandemHyperscoreBis ( )

Definition at line 61 of file xtandemhyperscorebis.cpp.

62{
63}

Member Function Documentation

◆ computeXtandemHyperscore()

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

Definition at line 84 of file xtandemhyperscorebis.cpp.

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

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

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

◆ getMatchedIons()

unsigned int XtandemHyperscoreBis::getMatchedIons ( Enums::PeptideIon ion_type) const

Definition at line 66 of file xtandemhyperscorebis.cpp.

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

References m_ionCount.

◆ getTotalMatchedIons()

unsigned int XtandemHyperscoreBis::getTotalMatchedIons ( ) const

Definition at line 256 of file xtandemhyperscorebis.cpp.

257{
258 return m_totalMatchedIons;
259}

References m_totalMatchedIons.

◆ getXtandemPredictedIonIntensityFactor()

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

Definition at line 200 of file xtandemhyperscorebis.cpp.

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

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

Referenced by computeXtandemHyperscore().

◆ reset()

void XtandemHyperscoreBis::reset ( )

Definition at line 73 of file xtandemhyperscorebis.cpp.

74{
75
77
80}
#define PEPTIDE_ION_TYPE_COUNT
only useful for internal use DO not change this value : it is used to define static array size
Definition types.h:478

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.

53{0};

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

◆ m_ionList

std::vector<Enums::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: