Loading...
Searching...
No Matches
pappso::specglob::SpectralAlignment Class Reference

`#include <spectralalignment.h>`

## Public Member Functions

| SpectralAlignment (ScoreValues score_values, pappso::PrecisionPtr precision_ptr)
| ~SpectralAlignment ()
void | align (PeptideSpectraCsp peptide_spectrum, ExperimentalSpectrumCsp experimental_spectrum)
| build the alignment matrix between a peptide sequence and an experimental spectrum
PeptideModel | rtrim (PrecisionPtr precision_ptr)
| trim the current peptide to get a minimal alignment score
const matrix< SpectralAlignmentDataPoint > & | getMatrix () const
std::vector< int > | getScoreRow (std::size_t row_indice) const
int | getMaxScore () const
boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 | getMaxPosIterator () const
double | getPrecursorMzDelta () const
QString | backTrack () const
PeptideModel | buildPeptideModel () const
ExperimentalSpectrumCsp | getExperimentalSpectrumCsp () const
PeptideSpectraCsp | getPeptideSpectraCsp () const

## Private Member Functions

const ExperimentalSpectrumDataPoint & | getExperimentalSpectrumDataPoint (const boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 &itpos) const
void | fillMassDelta (const PeptideSpectrum &peptide_spectrum, const ExperimentalSpectrum &experimental_spectrum)
void | fillMatricesWithScores (const boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 &it_pos, const PeptideSpectrum &peptide_spectrum, const ExperimentalSpectrum &experimental_spectrum)
SpectralAlignmentDataPoint | getBestRealignScore (const boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 &it_pos, std::size_t expeIndicesK, int reAlignScore, int alignScoreToAdd)

## Private Attributes

ExperimentalSpectrumCsp | mcsp_experimentalSpectrum
PeptideSpectraCsp | mcsp_peptideSpectrum
matrix< SpectralAlignmentDataPoint > | m_matrix
pappso::PrecisionPtr | m_precisionPtr
ScoreValues | m_scoreValues
int | m_maxScore
boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 | m_itPosMax
double | m_precursorMassDelta
bool | m_BETTER_END_RA = false

## Detailed Description

Todo:
  write docs

Definition at line 64 of file spectralalignment.h.

## Constructor & Destructor Documentation

## SpectralAlignment()

pappso::specglob::SpectralAlignment::SpectralAlignment | ( | ScoreValues | score_values,
|  | pappso::PrecisionPtr | precision_ptr
| ) |  |

Default constructor

Definition at line 47 of file spectralalignment.cpp.

{
m_precisionPtr = precision_ptr;
m_scoreValues = score_values;
}
pappso::specglob::SpectralAlignment::m_scoreValues
ScoreValues m_scoreValues
Definition spectralalignment.h:175
pappso::specglob::SpectralAlignment::m_precisionPtr
pappso::PrecisionPtr m_precisionPtr
Definition spectralalignment.h:174

References m_precisionPtr, and m_scoreValues.

## ~SpectralAlignment()

pappso::specglob::SpectralAlignment::~SpectralAlignment | ( |  | ) |

Destructor

Definition at line 54 of file spectralalignment.cpp.

{
}

## Member Function Documentation

## align()

void pappso::specglob::SpectralAlignment::align | ( | PeptideSpectraCsp | peptide_spectrum,
|  | ExperimentalSpectrumCsp | experimental_spectrum
| ) |  |

build the alignment matrix between a peptide sequence and an experimental spectrum

Parameters

  peptide_spectrum | the peptide sequence
  experimental_spectrum | the experimental spectrum

Definition at line 71 of file spectralalignment.cpp.

{
mcsp_experimentalSpectrum = experimental_spectrum;
mcsp_peptideSpectrum = peptide_spectrum;
m_maxScore = 0;
m_matrix.resize(mcsp_peptideSpectrum.get()->size(),
mcsp_experimentalSpectrum.get()->size());
// set the value of difference between Precursor mass and theoretical mass of
// the proposed peptide
m_precursorMassDelta =
mcsp_experimentalSpectrum.get()->getPrecursorMass() -
mcsp_peptideSpectrum.get()->getPeptideSp().get()->getMass();
fillMassDelta(*mcsp_peptideSpectrum.get(), *mcsp_experimentalSpectrum.get());
m_itPosMax = m_matrix.end2();
// Make the alignment in filling the matrices
auto last_theoretical_peptide = std::prev(m_matrix.end1());
for(auto itmi = ++m_matrix.begin1(); itmi != m_matrix.end1(); ++itmi)
{
for(auto itmj = ++itmi.begin(); itmj != itmi.end(); itmj++)
{
// qDebug() << "i=" << itmj.index1() << " j=" << itmj.index2();
fillMatricesWithScores(itmj,
*mcsp_peptideSpectrum.get(),
*mcsp_experimentalSpectrum.get());
// keep the Max Score during matrixes filling
// the condition is to keep the max score in the last line (last
// theoretical amino acid) This is for try to keep all amino acids of
// the initial Theoretical sequence (but can modify alignment choice)
if(itmi == last_theoretical_peptide && (*itmj).score > m_maxScore)
{
m_maxScore = (*itmj).score;
m_itPosMax = itmj;
}
}
}
}
pappso::specglob::SpectralAlignment::mcsp_peptideSpectrum
PeptideSpectraCsp mcsp_peptideSpectrum
Definition spectralalignment.h:172
pappso::specglob::SpectralAlignment::m_maxScore
int m_maxScore
Definition spectralalignment.h:176
pappso::specglob::SpectralAlignment::m_precursorMassDelta
double m_precursorMassDelta
Definition spectralalignment.h:180
pappso::specglob::SpectralAlignment::fillMassDelta
void fillMassDelta(const PeptideSpectrum &peptide_spectrum, const ExperimentalSpectrum &experimental_spectrum)
Definition spectralalignment.cpp:369
pappso::specglob::SpectralAlignment::mcsp_experimentalSpectrum
ExperimentalSpectrumCsp mcsp_experimentalSpectrum
Definition spectralalignment.h:171
pappso::specglob::SpectralAlignment::m_itPosMax
boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 m_itPosMax
Definition spectralalignment.h:178
pappso::specglob::SpectralAlignment::m_matrix
matrix< SpectralAlignmentDataPoint > m_matrix
Definition spectralalignment.h:173
pappso::specglob::SpectralAlignment::fillMatricesWithScores
void fillMatricesWithScores(const boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 &it_pos, const PeptideSpectrum &peptide_spectrum, const ExperimentalSpectrum &experimental_spectrum)
Definition spectralalignment.cpp:158

References fillMassDelta(), fillMatricesWithScores(), pappso::specglob::ScoreValues::get(), m_itPosMax, m_matrix, m_maxScore, m_precursorMassDelta, mcsp_experimentalSpectrum, and mcsp_peptideSpectrum.

## backTrack()

QString pappso::specglob::SpectralAlignment::backTrack | ( |  | ) | const

Backtrack is here to get the HitModified Sequence during the backtrack of score calculation. It start from best score align case in matrix and use origin matrix to go back to the start of the alignment

Parameters

  row | : the row indices of the best score
  column | : the column indices of the best score
  precision | : the precision of measures

Definition at line 442 of file spectralalignment.cpp.

{
if(m_maxScore < 1)
{
throw pappso::PappsoException("no backtrack");
}
QString pepModified = "";
QString theoSequence =
mcsp_peptideSpectrum.get()->getPeptideSp().get()->getSequence();
int actualI = m_itPosMax.index1();
int prevI;
int actualJ = m_itPosMax.index2();
int prevJ;
double actualDelMass;
double prevDelMass;
int modifCount = 0;
double totExplainMass = 0.0;
// System.out.println(theoSequence);
// System.out.println("actualI is : " + actualI + " and actualJ is : " +
// actualJ);
while(actualI > 0)
{
// System.out.println(actualI);
// define the actual mass delta to the actual i and j
QString tempPepSeq = "";
QString tempAA = "";
QString aminoAcid = "";
actualDelMass = m_matrix(actualI, actualJ).mass_difference;
prevI = actualI - 1;
prevJ = m_matrix(actualI, actualJ).origin_column_indices;
prevDelMass = m_matrix(prevI, prevJ).mass_difference;
// We checking first if last Amino acid are not aligned
if(m_matrix(actualI, actualJ).alignment_type ==
SpectralAlignmentType::nonAlign)
{
// System.out.println("I'm NON ALIGN");
tempPepSeq = QString("[%1]").arg(theoSequence.at(actualI - 1));
while(m_matrix(prevI, prevJ).alignment_type ==
SpectralAlignmentType::nonAlign &&
prevI > 0)
{
tempPepSeq =
QString("[%1]").arg(theoSequence.at(prevI - 1)) + tempPepSeq;
prevI--;
}
// modifCount++;
actualI = prevI;
actualJ = prevJ;
pepModified = tempPepSeq + pepModified;
qDebug() << "a1 pepModified=" << pepModified;
// if not, we are in the case where there is an alignment or a
// realignment if there is Align or a re-align, put the letter of
// Amino Acid and check what we get before to see if we have a mass
// change
}
else
{
// we put the actual amino acid because he is found, and in function
// of alignment type, we can have a mass offset
tempPepSeq = QString("%1").arg(theoSequence.at(actualI - 1));
aminoAcid = tempPepSeq;
// we check if there is a deletion before the founded aminoAcid
if(prevI > 0 && m_matrix(prevI, prevJ).alignment_type ==
SpectralAlignmentType::nonAlign)
{
// modifCount++;
// we continue to check if this is a deletion bloc to keep the
// mass difference due to the deletion of the block
while(prevI > 0 && m_matrix(prevI, prevJ).alignment_type ==
SpectralAlignmentType::nonAlign)
{
tempPepSeq = QString("[%1]").arg(theoSequence.at(prevI - 1)) +
tempPepSeq;
tempAA =
QString("%1").arg(theoSequence.at(prevI - 1)) + tempAA;
prevI--;
prevDelMass = m_matrix(prevI, prevJ).mass_difference;
if(prevI == 0)
{
prevDelMass = 0.0;
}
}
// check the mass delta to avoid showing a null mass delta
if(std::abs(actualDelMass - prevDelMass) >
m_precisionPtr->getNominal())
{
tempPepSeq = tempPepSeq.mid(0, tempPepSeq.length() - 1);
tempPepSeq +=
QString("[%1]").arg(actualDelMass - prevDelMass) +
aminoAcid;
totExplainMass += (actualDelMass - prevDelMass);
modifCount++;
qDebug() << "a2a1 tempPepSeq=" << tempPepSeq;
}
// if there this is just a re-align, we need to indicate the mass
// offset
}
else if(m_matrix(actualI, actualJ).alignment_type ==
SpectralAlignmentType::reAlign)
{
tempPepSeq =
QString("[%1]").arg(actualDelMass - prevDelMass) + tempPepSeq;
modifCount++;
totExplainMass += (actualDelMass - prevDelMass);
// the fact when you align the first amino acid, but there is a
// leak of Amino acid in OMS solution before
}
else if(actualI == 1 &&
m_matrix(actualI, actualJ).alignment_type ==
SpectralAlignmentType::align &&
(std::abs(actualDelMass) > m_precisionPtr->getNominal()))
{
tempPepSeq = QString("[%1]").arg(actualDelMass) + tempPepSeq;
totExplainMass += actualDelMass;
modifCount++;
}
pepModified = tempPepSeq + pepModified;
qDebug() << "a2 pepModified=" << pepModified;
// System.out.println(pepModified);
actualI = prevI;
actualJ = prevJ;
}
}
// setModificationNumber(modifCount);
return QString("%1_[%2]")
.arg(pepModified)
.arg(m_precursorMassDelta - totExplainMass);
}
pappso::PappsoException
Definition pappsoexception.h:42
pappso::PrecisionBase::getNominal
virtual pappso_double getNominal() const final
Definition precision.cpp:65
pappso::specglob::SpectralAlignmentType::nonAlign
@ nonAlign
the type of alignment to put in origin matrix NON Alignment (0 - NA)
pappso::specglob::SpectralAlignmentType::reAlign
@ reAlign
Re Alignment (1 - RE)
pappso::specglob::SpectralAlignmentType::align
@ align
Alignment (2 - AL)

References pappso::specglob::align, pappso::PrecisionBase::getNominal(), m_itPosMax, m_matrix, m_maxScore, m_precisionPtr, m_precursorMassDelta, mcsp_peptideSpectrum, pappso::specglob::nonAlign, and pappso::specglob::reAlign.

## buildPeptideModel()

PeptideModel pappso::specglob::SpectralAlignment::buildPeptideModel | ( |  | ) | const

Definition at line 595 of file spectralalignment.cpp.

{
if(m_maxScore < 1)
{
throw pappso::PappsoException(
QObject::tr("building peptide model failed m_maxScore == %1")
.arg(m_maxScore));
}
PeptideModel sg_peptide_model(
mcsp_experimentalSpectrum.get()->getQualifiedMassSpectrum(),
*(mcsp_peptideSpectrum.get()->getPeptideSp().get()));
int actualI = m_itPosMax.index1();
int prevI;
int actualJ = m_itPosMax.index2();
int prevJ;
double actualDelMass;
double prevDelMass;
// System.out.println(theoSequence);
// System.out.println("actualI is : " + actualI + " and actualJ is : " +
// actualJ);
while(actualI > 0)
{
// System.out.println(actualI);
// define the actual mass delta to the actual i and j
QString aminoAcid = "";
actualDelMass = m_matrix(actualI, actualJ).mass_difference;
prevI = actualI - 1;
prevJ = m_matrix(actualI, actualJ).origin_column_indices;
prevDelMass = m_matrix(prevI, prevJ).mass_difference;
// We checking first if last Amino acid are not aligned
if(m_matrix(actualI, actualJ).alignment_type ==
SpectralAlignmentType::nonAlign)
{
// System.out.println("I'm NON ALIGN");
while(m_matrix(prevI, prevJ).alignment_type ==
SpectralAlignmentType::nonAlign &&
prevI > 0)
{
if(prevI > 0)
sg_peptide_model[prevI - 1].bracket = true;
prevI--;
}
// modifCount++;
actualI = prevI;
actualJ = prevJ;
// if not, we are in the case where there is an alignment or a
// realignment if there is Align or a re-align, put the letter of
// Amino Acid and check what we get before to see if we have a mass
// change
}
else
{
// we put the actual amino acid because he is found, and in function
// of alignment type, we can have a mass offset
// we check if there is a deletion before the founded aminoAcid
if(prevI > 0 && m_matrix(prevI, prevJ).alignment_type ==
SpectralAlignmentType::nonAlign)
{
// modifCount++;
// we continue to check if this is a deletion bloc to keep the
// mass difference due to the deletion of the block
while(prevI > 0 && m_matrix(prevI, prevJ).alignment_type ==
SpectralAlignmentType::nonAlign)
{
if(prevI > 0)
sg_peptide_model[prevI - 1].bracket = true;
prevI--;
prevDelMass = m_matrix(prevI, prevJ).mass_difference;
if(prevI == 0)
{
prevDelMass = 0.0;
}
}
// check the mass delta to avoid showing a null mass delta
if(std::abs(actualDelMass - prevDelMass) >
m_precisionPtr->getNominal())
{
int mass_i = actualI - 1;
if(mass_i == 0)
{
sg_peptide_model.setBeginMassDelta(actualDelMass -
prevDelMass);
}
else
{
sg_peptide_model[mass_i - 1].mass_difference =
actualDelMass - prevDelMass;
}
}
// if there this is just a re-align, we need to indicate the mass
// offset
}
else if(m_matrix(actualI, actualJ).alignment_type ==
SpectralAlignmentType::reAlign)
{
int mass_i = actualI - 1;
if(mass_i == 0)
{
sg_peptide_model.setBeginMassDelta(actualDelMass -
prevDelMass);
}
else
{
sg_peptide_model[mass_i - 1].mass_difference =
actualDelMass - prevDelMass;
}
// the fact when you align the first amino acid, but there is a
// leak of Amino acid in OMS solution before
}
else if(actualI == 1 &&
m_matrix(actualI, actualJ).alignment_type ==
SpectralAlignmentType::align &&
(std::abs(actualDelMass) > m_precisionPtr->getNominal()))
{
sg_peptide_model.setBeginMassDelta(actualDelMass);
}
actualI = prevI;
actualJ = prevJ;
}
}
// setModificationNumber(modifCount);
// return QString("%1_[%2]")
// .arg(pepModified)
// .arg(m_precursorMassDelta - totExplainMass);
return sg_peptide_model;
}

References pappso::specglob::align, pappso::PrecisionBase::getNominal(), m_itPosMax, m_matrix, m_maxScore, m_precisionPtr, mcsp_experimentalSpectrum, mcsp_peptideSpectrum, pappso::specglob::nonAlign, pappso::specglob::reAlign, and pappso::specglob::PeptideModel::setBeginMassDelta().

Referenced by rtrim().

## fillMassDelta()

void pappso::specglob::SpectralAlignment::fillMassDelta | ( | const PeptideSpectrum & | peptide_spectrum,
|  | const ExperimentalSpectrum & | experimental_spectrum
| ) |  |

private

Definition at line 369 of file spectralalignment.cpp.

{
auto it_peptide = peptide_spectrum.begin();
auto it_spectrum = experimental_spectrum.begin();
for(auto itr1 = m_matrix.begin1(); itr1 != m_matrix.end1();
++itr1, it_peptide++)
{
it_spectrum = experimental_spectrum.begin();
for(auto itr2 = itr1.begin(); itr2 != itr1.end(); itr2++, it_spectrum++)
{
(*itr2).alignment_type = SpectralAlignmentType::nonAlign;
if(it_peptide == peptide_spectrum.begin())
(*itr2).alignment_type = SpectralAlignmentType::nonAlign;
(*itr2).origin_column_indices = 0;
(*itr2).score = 0;
(*itr2).mass_difference = it_spectrum->symmetric_mz - it_peptide->mz;
// qDebug() << " i=" << itr2.index1() << " j=" << itr2.index2()
// << " mass_difference=" << (*itr2).mass_difference;
}
}
}

References m_matrix, and pappso::specglob::nonAlign.

Referenced by align().

## fillMatricesWithScores()

void pappso::specglob::SpectralAlignment::fillMatricesWithScores | ( | const boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 & | it_pos,
|  | const PeptideSpectrum & | peptide_spectrum,
|  | const ExperimentalSpectrum & | experimental_spectrum
| ) |  |

private

This method do the alignment of the 2 Spectra and fill matrices at actual coordinates i(row - theoretical) and j(column - experimental)

Parameters

  theoIndiceI | : The actual theoretical peak indices
  expeIndiceJ | : The actual experimental peak indices

Definition at line 158 of file spectralalignment.cpp.

{
// long theoIndiceI = it_pos.index1();
// long expeIndiceJ = it_pos.index2();
// in first time, we set score corresponding to type of peak (initial/mirror
// or both) we set initial score to peak mirror or initial
ExperimentalSpectrumDataPointType expePeakType =
getExperimentalSpectrumDataPoint(it_pos).type;
// experimental_spectrum.at(expeIndiceJ).type;
int alignScoreToAdd = m_scoreValues.get(ScoreValueType::scoreAlignNative);
int reAlignScoreToAdd = m_scoreValues.get(ScoreValueType::scoreReAlignNative);
int reAlignScoreNOToAdd =
m_scoreValues.get(ScoreValueType::scoreReAlignNativeNO);
switch(expePeakType)
{
case ExperimentalSpectrumDataPointType::symmetric:
// this is a symmetric peak
alignScoreToAdd = m_scoreValues.get(ScoreValueType::scoreAlignSym);
reAlignScoreToAdd = m_scoreValues.get(ScoreValueType::scoreReAlignSym);
reAlignScoreNOToAdd =
m_scoreValues.get(ScoreValueType::scoreReAlignSymNO);
if(m_BETTER_END_RA &&
it_pos.index1() == peptide_spectrum.getPeptideSp().get()->size())
{
reAlignScoreToAdd =
m_scoreValues.get(ScoreValueType::scoreNonAlign) +
m_scoreValues.get(ScoreValueType::scoreAlignSym);
}
break;
case ExperimentalSpectrumDataPointType::both:
// this is a native peak with a symmetric corresponding
alignScoreToAdd = m_scoreValues.get(ScoreValueType::scoreAlignBoth);
reAlignScoreToAdd = m_scoreValues.get(ScoreValueType::scoreReAlignBoth);
reAlignScoreNOToAdd =
m_scoreValues.get(ScoreValueType::scoreReAlignBothNO);
if(m_BETTER_END_RA &&
it_pos.index1() == peptide_spectrum.getPeptideSp().get()->size())
{
reAlignScoreToAdd =
m_scoreValues.get(ScoreValueType::scoreNonAlign) +
m_scoreValues.get(ScoreValueType::scoreAlignBoth);
}
break;
default:
// this is a native or synthetic peak
alignScoreToAdd = m_scoreValues.get(ScoreValueType::scoreAlignNative);
reAlignScoreToAdd =
m_scoreValues.get(ScoreValueType::scoreReAlignNative);
reAlignScoreNOToAdd =
m_scoreValues.get(ScoreValueType::scoreReAlignNativeNO);
if(m_BETTER_END_RA &&
it_pos.index1() == peptide_spectrum.getPeptideSp().get()->size())
{
reAlignScoreToAdd =
m_scoreValues.get(ScoreValueType::scoreNonAlign) +
m_scoreValues.get(ScoreValueType::scoreAlignNative);
}
break;
}
SpectralAlignmentDataPoint &matrix_data_point_i_j = *it_pos;
/*
long k = getkValue(it_pos,
peptide_spectrum.at(it_pos.index1()).diff_mz,
experimental_spectrum);
if(it_pos.index1() == 15)
qDebug() << "position1" << it_pos.index1() << "position2" << it_pos.index1()
<< " k=" << k << " " << peptide_spectrum.at(it_pos.index1()).diff_mz;
*/
pappso::MzRange aaMassRange(peptide_spectrum.at(it_pos.index1()).diff_mz,
m_precisionPtr);
qDebug();
// long k = -1;
auto itKpeak =
experimental_spectrum.reverseFindDiffMz(it_pos.index2(), aaMassRange);
// if(itKpeak != experimental_spectrum.rend())
// k = itKpeak->indice;
if(itKpeak == experimental_spectrum.rend())
{
matrix_data_point_i_j.score =
m_matrix(it_pos.index1() - 1, it_pos.index2()).score +
(m_scoreValues.get(ScoreValueType::scoreNonAlign));
matrix_data_point_i_j.origin_column_indices = it_pos.index2();
matrix_data_point_i_j.alignment_type = SpectralAlignmentType::nonAlign;
}
else
{
SpectralAlignmentDataPoint &matrix_data_point_previ_k =
m_matrix(it_pos.index1() - 1, itKpeak->indice);
int scoreAlignK = matrix_data_point_previ_k.score + alignScoreToAdd;
// if it come from non align, we must verify that there is no offset from
// previous align
if(matrix_data_point_previ_k.alignment_type ==
SpectralAlignmentType::nonAlign)
{
int l;
for(l = it_pos.index1() - 1; l > 0; l--)
{
if(m_matrix(l, itKpeak->indice).origin_column_indices !=
itKpeak->indice)
break;
}
if(std::abs(m_matrix(l, itKpeak->indice).mass_difference -
(*it_pos).mass_difference) > m_precisionPtr->getNominal())
scoreAlignK = matrix_data_point_previ_k.score + reAlignScoreToAdd;
}
// int[0] = the j value m and int[1] = the score value
SpectralAlignmentDataPoint reAlignBestScore = getBestRealignScore(
it_pos, itKpeak->indice, reAlignScoreToAdd, reAlignScoreNOToAdd);
// For debug to see value for any match
// System.out.println("score k = " + scoreAlignK + " - score m = " +
// reAlignBestScore[1] + " - origin m = "
// + reAlignBestScore[0]);
if(scoreAlignK >= reAlignBestScore.score)
{
// setMatricesData(theoIndiceI, expeIndiceJ, scoreAlignK, k, 2);
matrix_data_point_i_j.score = scoreAlignK;
matrix_data_point_i_j.origin_column_indices = itKpeak->indice;
matrix_data_point_i_j.alignment_type = SpectralAlignmentType::align;
}
else
{
/*setMatricesData(theoIndiceI,
expeIndiceJ,
reAlignBestScore[1],
reAlignBestScore[0],
reAlignBestScore[2]);*/
matrix_data_point_i_j = reAlignBestScore;
}
}
}
pappso::MzRange
Definition mzrange.h:46
pappso::specglob::ScoreValues::get
int get(ScoreValueType type)
Definition scorevalues.cpp:84
pappso::specglob::SpectralAlignment::getBestRealignScore
SpectralAlignmentDataPoint getBestRealignScore(const boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 &it_pos, std::size_t expeIndicesK, int reAlignScore, int alignScoreToAdd)
Definition spectralalignment.cpp:304
pappso::specglob::SpectralAlignment::m_BETTER_END_RA
bool m_BETTER_END_RA
Definition spectralalignment.h:189
pappso::specglob::SpectralAlignment::getExperimentalSpectrumDataPoint
const ExperimentalSpectrumDataPoint & getExperimentalSpectrumDataPoint(const boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 &itpos) const
Definition spectralalignment.cpp:427
pappso::specglob::ScoreValueType::scoreAlignNative
@ scoreAlignNative
Score for good alignment native (int)
pappso::specglob::ScoreValueType::scoreReAlignSymNO
@ scoreReAlignSymNO
Score for re-alignment without offset symmetric (int)
pappso::specglob::ScoreValueType::scoreNonAlign
@ scoreNonAlign
Score for non alignment (int)
pappso::specglob::ScoreValueType::scoreAlignBoth
@ scoreAlignBoth
Score for good alignment both (int)
pappso::specglob::ScoreValueType::scoreReAlignBoth
@ scoreReAlignBoth
Score for re-alignment both (int)
pappso::specglob::ScoreValueType::scoreReAlignBothNO
@ scoreReAlignBothNO
Score for re-alignment without offset both (int)
pappso::specglob::ScoreValueType::scoreReAlignSym
@ scoreReAlignSym
Score for re-alignment symmetric (int)
pappso::specglob::ScoreValueType::scoreReAlignNative
@ scoreReAlignNative
pappso::specglob::ScoreValueType::scoreAlignSym
@ scoreAlignSym
Score for good alignment symmetric (int)
pappso::specglob::ScoreValueType::scoreReAlignNativeNO
@ scoreReAlignNativeNO
Score for re-alignment without offset native (int)
pappso::specglob::ExperimentalSpectrumDataPointType
ExperimentalSpectrumDataPointType
Definition types.h:78
pappso::specglob::ExperimentalSpectrumDataPointType::both
@ both
both, the ion and the complement exists in the original spectrum
pappso::specglob::ExperimentalSpectrumDataPointType::symmetric
@ symmetric
new peak : computed symmetric mass from a corresponding native peak
pappso::specglob::ExperimentalSpectrumDataPoint::type
ExperimentalSpectrumDataPointType type
Definition experimentalspectrum.h:52

References pappso::specglob::align, pappso::specglob::SpectralAlignmentDataPoint::alignment_type, pappso::specglob::both, pappso::specglob::ScoreValues::get(), getBestRealignScore(), getExperimentalSpectrumDataPoint(), pappso::PrecisionBase::getNominal(), pappso::specglob::PeptideSpectrum::getPeptideSp(), m_BETTER_END_RA, m_matrix, m_precisionPtr, m_scoreValues, pappso::specglob::nonAlign, pappso::specglob::SpectralAlignmentDataPoint::origin_column_indices, pappso::specglob::ExperimentalSpectrum::reverseFindDiffMz(), pappso::specglob::SpectralAlignmentDataPoint::score, pappso::specglob::scoreAlignBoth, pappso::specglob::scoreAlignNative, pappso::specglob::scoreAlignSym, pappso::specglob::scoreNonAlign, pappso::specglob::scoreReAlignBoth, pappso::specglob::scoreReAlignBothNO, pappso::specglob::scoreReAlignNative, pappso::specglob::scoreReAlignNativeNO, pappso::specglob::scoreReAlignSym, pappso::specglob::scoreReAlignSymNO, pappso::specglob::symmetric, and pappso::specglob::ExperimentalSpectrumDataPoint::type.

Referenced by align().

## getBestRealignScore()

SpectralAlignmentDataPoint pappso::specglob::SpectralAlignment::getBestRealignScore | ( | const boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 & | it_pos,
|  | std::size_t | expeIndicesK,
|  | int | reAlignScore,
|  | int | alignScoreToAdd
| ) |  |

private

Method to get a realigned j value of where come from the realignment and get the associated realigned score

Parameters

  theoIndicesI | : The row where we are actually
  expeIndicesK | : The founded k indices
  expeIndicesJ | : The column where we are actually
  reAlignScore | : Score to add if it is needed to add offset to realign
  alignScoreToAdd | : Score to add if there is an alignment with peak k
  precision | : Precision of measures

Returns
  an int[] where int[0] is the origin column (m) where come from the re-alignment and int[1] is the calculated re-aligned score and int[3] is the alignment type code

Definition at line 304 of file spectralalignment.cpp.

{
std::size_t previous_peptide_row = it_pos.index1() - 1;
SpectralAlignmentDataPoint return_data_point = *it_pos;
int bestScore = -10000;
int origin = -1;
// find the best score column indice on previous row, walking back from
// expeIndicesK m is a j value between 0 and k where a realign can be do if we
// accept mass offset
for(long m = expeIndicesK; m > -1; m--)
{
// the >= here is for keep the highest S value if there is multiple S with
// the same best score
if(m_matrix(previous_peptide_row, m).score > bestScore)
{
bestScore = m_matrix(previous_peptide_row, m).score;
origin = m;
}
}
return_data_point.origin_column_indices = origin;
return_data_point.score = bestScore + reAlignScore;
return_data_point.alignment_type = SpectralAlignmentType::reAlign; // [2] = 1;
if(origin == -1)
return return_data_point;
// We check for the last alignment if we have chain of Non Alignment to
// compare the last mass offset found
std::size_t lastAlignIndiceI = previous_peptide_row;
for(long l = previous_peptide_row; l > 0; l--)
{
if(m_matrix(l, origin).origin_column_indices != 0)
{
lastAlignIndiceI = l;
break;
}
}
// if the difference of mass offset between actual state and last align (or
// realign) is null, we consider that to an alignment
if((lastAlignIndiceI != (previous_peptide_row)) && (it_pos.index1() > 1) &&
(std::abs(m_matrix(previous_peptide_row, expeIndicesK).mass_difference -
m_matrix(lastAlignIndiceI, origin).mass_difference) <
m_precisionPtr->getNominal()))
{
return_data_point.score = bestScore + alignScoreToAdd;
return_data_point.alignment_type =
SpectralAlignmentType::align; //[2] = 2;
}
// we return the origin (value of m) and the associate calculated score and
// the type of Alignment
return return_data_point;
}

References pappso::specglob::align, pappso::specglob::SpectralAlignmentDataPoint::alignment_type, pappso::PrecisionBase::getNominal(), m_matrix, m_precisionPtr, pappso::specglob::SpectralAlignmentDataPoint::origin_column_indices, pappso::specglob::reAlign, and pappso::specglob::SpectralAlignmentDataPoint::score.

Referenced by fillMatricesWithScores().

## getExperimentalSpectrumCsp()

ExperimentalSpectrumCsp pappso::specglob::SpectralAlignment::getExperimentalSpectrumCsp | ( |  | ) | const

Definition at line 60 of file spectralalignment.cpp.

{
return mcsp_experimentalSpectrum;
}

References mcsp_experimentalSpectrum.

## getExperimentalSpectrumDataPoint()

const ExperimentalSpectrumDataPoint & pappso::specglob::SpectralAlignment::getExperimentalSpectrumDataPoint | ( | const boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 & | itpos | ) | const

private

Definition at line 427 of file spectralalignment.cpp.

{
return mcsp_experimentalSpectrum.get()->at(itpos.index2());
}

References mcsp_experimentalSpectrum.

Referenced by fillMatricesWithScores().

## getMatrix()

const matrix< SpectralAlignmentDataPoint > & pappso::specglob::SpectralAlignment::getMatrix | ( |  | ) | const

Definition at line 395 of file spectralalignment.cpp.

{
return m_matrix;
}

References m_matrix.

## getMaxPosIterator()

boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 pappso::specglob::SpectralAlignment::getMaxPosIterator | ( |  | ) | const

Definition at line 421 of file spectralalignment.cpp.

{
return m_itPosMax;
}

References m_itPosMax.

## getMaxScore()

int pappso::specglob::SpectralAlignment::getMaxScore | ( |  | ) | const

Definition at line 415 of file spectralalignment.cpp.

{
return m_maxScore;
}

References m_maxScore.

## getPeptideSpectraCsp()

PeptideSpectraCsp pappso::specglob::SpectralAlignment::getPeptideSpectraCsp | ( |  | ) | const

Definition at line 66 of file spectralalignment.cpp.

{
return mcsp_peptideSpectrum;
}

References mcsp_peptideSpectrum.

## getPrecursorMzDelta()

double pappso::specglob::SpectralAlignment::getPrecursorMzDelta | ( |  | ) | const

Definition at line 435 of file spectralalignment.cpp.

{
return m_precursorMassDelta;
}

References m_precursorMassDelta.

## getScoreRow()

std::vector< int > pappso::specglob::SpectralAlignment::getScoreRow | ( | std::size_t | row_indice | ) | const

Definition at line 401 of file spectralalignment.cpp.

{
std::vector<int> score;
auto itr1 = m_matrix.begin1() + row_indice;
for(auto itr2 = itr1.begin(); itr2 != itr1.end(); itr2++)
{
score.push_back((*itr2).score);
}
return score;
}

References m_matrix.

## rtrim()

PeptideModel pappso::specglob::SpectralAlignment::rtrim | ( | PrecisionPtr | precision_ptr | ) |

trim the current peptide to get a minimal alignment score

Definition at line 114 of file spectralalignment.cpp.

{
pappso::specglob::PeptideModel model;
pappso::specglob::PeptideSpectraCsp ref_peptide = mcsp_peptideSpectrum;
double precursor_mass = mcsp_experimentalSpectrum.get()->getPrecursorMass();
std::size_t start = 1;
int max_score = m_maxScore;
pappso::specglob::PeptideSpectraCsp ref_best_peptide = ref_peptide;
while(start < ref_peptide.get()->getPeptideSp().get()->size() - 5)
{
pappso::PeptideSp peptide_sp = std::make_shared<pappso::Peptide>(
ref_peptide.get()->getPeptideSp().get()->getSequence().mid(start));
std::size_t length = peptide_sp.get()->size();
while(peptide_sp.get()->getMass() > (precursor_mass * 1.1))
{
peptide_sp = std::make_shared<pappso::Peptide>(
peptide_sp.get()->getSequence().mid(0, length - 1));
if(length > 1)
length--;
}
pappso::specglob::PeptideSpectraCsp peptide_spectra =
std::make_shared<pappso::specglob::PeptideSpectrum>(peptide_sp);
align(peptide_spectra, mcsp_experimentalSpectrum);
if(max_score < m_maxScore)
{
if(m_maxScore > 0)
{
model = buildPeptideModel();
model.eliminateComplementaryDelta(precision_ptr);
model.ltrimOnRemoval();
max_score = m_maxScore;
ref_best_peptide = mcsp_peptideSpectrum;
}
}
start++;
}
align(ref_best_peptide, mcsp_experimentalSpectrum);
return model;
}
pappso::specglob::PeptideModel
Definition peptidemodel.h:73
pappso::specglob::PeptideModel::ltrimOnRemoval
bool ltrimOnRemoval()
try to remove left amino acid if there is a removal
Definition peptidemodel.cpp:193
pappso::specglob::PeptideModel::eliminateComplementaryDelta
bool eliminateComplementaryDelta(pappso::PrecisionPtr precision)
Definition peptidemodel.cpp:479
pappso::specglob::SpectralAlignment::buildPeptideModel
PeptideModel buildPeptideModel() const
Definition spectralalignment.cpp:595
pappso::specglob::PeptideSpectraCsp
std::shared_ptr< const PeptideSpectrum > PeptideSpectraCsp
Definition peptidespectrum.h:56
pappso::PeptideSp
std::shared_ptr< const Peptide > PeptideSp
Definition aamodification.h:48

References pappso::specglob::align, buildPeptideModel(), pappso::specglob::PeptideModel::eliminateComplementaryDelta(), pappso::specglob::PeptideModel::ltrimOnRemoval(), m_maxScore, mcsp_experimentalSpectrum, and mcsp_peptideSpectrum.

## Member Data Documentation

## m_BETTER_END_RA

bool pappso::specglob::SpectralAlignment::m_BETTER_END_RA = false

private

modifies the score on the last amino acid alignment (RA score rather than NA Not documented anyMore in the interface

Definition at line 189 of file spectralalignment.h.

Referenced by fillMatricesWithScores().

## m_itPosMax

boost::numeric::ublas::matrix<SpectralAlignmentDataPoint>::iterator2 pappso::specglob::SpectralAlignment::m_itPosMax

private

Definition at line 178 of file spectralalignment.h.

Referenced by align(), backTrack(), buildPeptideModel(), and getMaxPosIterator().

## m_matrix

matrix<SpectralAlignmentDataPoint> pappso::specglob::SpectralAlignment::m_matrix

private

Definition at line 173 of file spectralalignment.h.

Referenced by align(), backTrack(), buildPeptideModel(), fillMassDelta(), fillMatricesWithScores(), getBestRealignScore(), getMatrix(), and getScoreRow().

## m_maxScore

int pappso::specglob::SpectralAlignment::m_maxScore

private

Definition at line 176 of file spectralalignment.h.

Referenced by align(), backTrack(), buildPeptideModel(), getMaxScore(), and rtrim().

## m_precisionPtr

pappso::PrecisionPtr pappso::specglob::SpectralAlignment::m_precisionPtr

private

Definition at line 174 of file spectralalignment.h.

Referenced by SpectralAlignment(), backTrack(), buildPeptideModel(), fillMatricesWithScores(), and getBestRealignScore().

## m_precursorMassDelta

double pappso::specglob::SpectralAlignment::m_precursorMassDelta

private

Initial value:
=
0

Definition at line 180 of file spectralalignment.h.

Referenced by align(), backTrack(), and getPrecursorMzDelta().

## m_scoreValues

ScoreValues pappso::specglob::SpectralAlignment::m_scoreValues

private

Definition at line 175 of file spectralalignment.h.

Referenced by SpectralAlignment(), and fillMatricesWithScores().

## mcsp_experimentalSpectrum

ExperimentalSpectrumCsp pappso::specglob::SpectralAlignment::mcsp_experimentalSpectrum

private

Definition at line 171 of file spectralalignment.h.

Referenced by align(), buildPeptideModel(), getExperimentalSpectrumCsp(), getExperimentalSpectrumDataPoint(), and rtrim().

## mcsp_peptideSpectrum

PeptideSpectraCsp pappso::specglob::SpectralAlignment::mcsp_peptideSpectrum

private

Definition at line 172 of file spectralalignment.h.

Referenced by align(), backTrack(), buildPeptideModel(), getPeptideSpectraCsp(), and rtrim().

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

- pappsomspp/processing/specglob/spectralalignment.h
- pappsomspp/processing/specglob/spectralalignment.cpp