libpappsomspp
Library for mass spectrometry
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 ExperimentalSpectrumDataPointgetExperimentalSpectrumDataPoint (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< SpectralAlignmentDataPointm_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.

49{
50 m_precisionPtr = precision_ptr;
51 m_scoreValues = score_values;
52}

References m_precisionPtr, and m_scoreValues.

◆ ~SpectralAlignment()

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

Destructor

Definition at line 54 of file spectralalignment.cpp.

55{
56}

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_spectrumthe peptide sequence
experimental_spectrumthe experimental spectrum

Definition at line 71 of file spectralalignment.cpp.

73{
74 mcsp_experimentalSpectrum = experimental_spectrum;
75 mcsp_peptideSpectrum = peptide_spectrum;
76 m_maxScore = 0;
77 m_matrix.resize(mcsp_peptideSpectrum.get()->size(),
78 mcsp_experimentalSpectrum.get()->size());
79
80 // set the value of difference between Precursor mass and theoretical mass of
81 // the proposed peptide
83 mcsp_experimentalSpectrum.get()->getPrecursorMass() -
84 mcsp_peptideSpectrum.get()->getPeptideSp().get()->getMass();
85
87
88 m_itPosMax = m_matrix.end2();
89 // Make the alignment in filling the matrices
90
91 auto last_theoretical_peptide = std::prev(m_matrix.end1());
92 for(auto itmi = ++m_matrix.begin1(); itmi != m_matrix.end1(); ++itmi)
93 {
94 for(auto itmj = ++itmi.begin(); itmj != itmi.end(); itmj++)
95 {
96 // qDebug() << "i=" << itmj.index1() << " j=" << itmj.index2();
100 // keep the Max Score during matrixes filling
101 // the condition is to keep the max score in the last line (last
102 // theoretical amino acid) This is for try to keep all amino acids of
103 // the initial Theoretical sequence (but can modify alignment choice)
104 if(itmi == last_theoretical_peptide && (*itmj).score > m_maxScore)
105 {
106 m_maxScore = (*itmj).score;
107 m_itPosMax = itmj;
108 }
109 }
110 }
111}
void fillMassDelta(const PeptideSpectrum &peptide_spectrum, const ExperimentalSpectrum &experimental_spectrum)
ExperimentalSpectrumCsp mcsp_experimentalSpectrum
boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 m_itPosMax
matrix< SpectralAlignmentDataPoint > m_matrix
void fillMatricesWithScores(const boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 &it_pos, const PeptideSpectrum &peptide_spectrum, const ExperimentalSpectrum &experimental_spectrum)

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.

443{
444 if(m_maxScore < 1)
445 {
446 throw pappso::PappsoException("no backtrack");
447 }
448 QString pepModified = "";
449 QString theoSequence =
450 mcsp_peptideSpectrum.get()->getPeptideSp().get()->getSequence();
451 int actualI = m_itPosMax.index1();
452 int prevI;
453 int actualJ = m_itPosMax.index2();
454 int prevJ;
455 double actualDelMass;
456 double prevDelMass;
457 int modifCount = 0;
458 double totExplainMass = 0.0;
459
460 // System.out.println(theoSequence);
461 // System.out.println("actualI is : " + actualI + " and actualJ is : " +
462 // actualJ);
463
464 while(actualI > 0)
465 {
466 // System.out.println(actualI);
467 // define the actual mass delta to the actual i and j
468 QString tempPepSeq = "";
469 QString tempAA = "";
470 QString aminoAcid = "";
471 actualDelMass = m_matrix(actualI, actualJ).mass_difference;
472 prevI = actualI - 1;
473 prevJ = m_matrix(actualI, actualJ).origin_column_indices;
474 prevDelMass = m_matrix(prevI, prevJ).mass_difference;
475
476 // We checking first if last Amino acid are not aligned
477
478 if(m_matrix(actualI, actualJ).alignment_type ==
480 {
481 // System.out.println("I'm NON ALIGN");
482 tempPepSeq = QString("[%1]").arg(theoSequence.at(actualI - 1));
483
484 while(m_matrix(prevI, prevJ).alignment_type ==
486 prevI > 0)
487 {
488 tempPepSeq =
489 QString("[%1]").arg(theoSequence.at(prevI - 1)) + tempPepSeq;
490 prevI--;
491 }
492 // modifCount++;
493 actualI = prevI;
494 actualJ = prevJ;
495
496 pepModified = tempPepSeq + pepModified;
497
498 qDebug() << "a1 pepModified=" << pepModified;
499 // if not, we are in the case where there is an alignment or a
500 // realignment if there is Align or a re-align, put the letter of
501 // Amino Acid and check what we get before to see if we have a mass
502 // change
503 }
504 else
505 {
506 // we put the actual amino acid because he is found, and in function
507 // of alignment type, we can have a mass offset
508 tempPepSeq = QString("%1").arg(theoSequence.at(actualI - 1));
509 aminoAcid = tempPepSeq;
510
511 // we check if there is a deletion before the founded aminoAcid
512 if(prevI > 0 && m_matrix(prevI, prevJ).alignment_type ==
514 {
515
516 // modifCount++;
517
518 // we continue to check if this is a deletion bloc to keep the
519 // mass difference due to the deletion of the block
520 while(prevI > 0 && m_matrix(prevI, prevJ).alignment_type ==
522 {
523
524 tempPepSeq = QString("[%1]").arg(theoSequence.at(prevI - 1)) +
525 tempPepSeq;
526 tempAA =
527 QString("%1").arg(theoSequence.at(prevI - 1)) + tempAA;
528
529 prevI--;
530 prevDelMass = m_matrix(prevI, prevJ).mass_difference;
531 if(prevI == 0)
532 {
533 prevDelMass = 0.0;
534 }
535 }
536
537 // check the mass delta to avoid showing a null mass delta
538 if(std::abs(actualDelMass - prevDelMass) >
540 {
541
542 tempPepSeq = tempPepSeq.mid(0, tempPepSeq.length() - 1);
543
544 tempPepSeq +=
545 QString("[%1]").arg(actualDelMass - prevDelMass) +
546 aminoAcid;
547 totExplainMass += (actualDelMass - prevDelMass);
548 modifCount++;
549 qDebug() << "a2a1 tempPepSeq=" << tempPepSeq;
550 }
551
552 // if there this is just a re-align, we need to indicate the mass
553 // offset
554 }
555 else if(m_matrix(actualI, actualJ).alignment_type ==
557 {
558
559 tempPepSeq =
560 QString("[%1]").arg(actualDelMass - prevDelMass) + tempPepSeq;
561 modifCount++;
562 totExplainMass += (actualDelMass - prevDelMass);
563
564 // the fact when you align the first amino acid, but there is a
565 // leak of Amino acid in OMS solution before
566 }
567 else if(actualI == 1 &&
568 m_matrix(actualI, actualJ).alignment_type ==
570 (std::abs(actualDelMass) > m_precisionPtr->getNominal()))
571 {
572 tempPepSeq = QString("[%1]").arg(actualDelMass) + tempPepSeq;
573 totExplainMass += actualDelMass;
574 modifCount++;
575 }
576
577 pepModified = tempPepSeq + pepModified;
578 qDebug() << "a2 pepModified=" << pepModified;
579 // System.out.println(pepModified);
580
581 actualI = prevI;
582 actualJ = prevJ;
583 }
584 }
585
586 // setModificationNumber(modifCount);
587
588 return QString("%1_[%2]")
589 .arg(pepModified)
590 .arg(m_precursorMassDelta - totExplainMass);
591}
virtual pappso_double getNominal() const final
Definition precision.cpp:65
@ nonAlign
the type of alignment to put in origin matrix NON Alignment (0 - NA)

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.

596{
597 if(m_maxScore < 1)
598 {
600 QObject::tr("building peptide model failed m_maxScore == %1")
601 .arg(m_maxScore));
602 }
603 PeptideModel sg_peptide_model(
604 mcsp_experimentalSpectrum.get()->getQualifiedMassSpectrum(),
605 *(mcsp_peptideSpectrum.get()->getPeptideSp().get()));
606 int actualI = m_itPosMax.index1();
607 int prevI;
608 int actualJ = m_itPosMax.index2();
609 int prevJ;
610 double actualDelMass;
611 double prevDelMass;
612
613 // System.out.println(theoSequence);
614 // System.out.println("actualI is : " + actualI + " and actualJ is : " +
615 // actualJ);
616
617 while(actualI > 0)
618 {
619 // System.out.println(actualI);
620 // define the actual mass delta to the actual i and j
621 QString aminoAcid = "";
622 actualDelMass = m_matrix(actualI, actualJ).mass_difference;
623 prevI = actualI - 1;
624 prevJ = m_matrix(actualI, actualJ).origin_column_indices;
625 prevDelMass = m_matrix(prevI, prevJ).mass_difference;
626
627 // We checking first if last Amino acid are not aligned
628
629 if(m_matrix(actualI, actualJ).alignment_type ==
631 {
632 // System.out.println("I'm NON ALIGN");
633
634 while(m_matrix(prevI, prevJ).alignment_type ==
636 prevI > 0)
637 {
638 if(prevI > 0)
639 sg_peptide_model[prevI - 1].bracket = true;
640 prevI--;
641 }
642 // modifCount++;
643 actualI = prevI;
644 actualJ = prevJ;
645
646 // if not, we are in the case where there is an alignment or a
647 // realignment if there is Align or a re-align, put the letter of
648 // Amino Acid and check what we get before to see if we have a mass
649 // change
650 }
651 else
652 {
653 // we put the actual amino acid because he is found, and in function
654 // of alignment type, we can have a mass offset
655
656 // we check if there is a deletion before the founded aminoAcid
657 if(prevI > 0 && m_matrix(prevI, prevJ).alignment_type ==
659 {
660
661 // modifCount++;
662
663 // we continue to check if this is a deletion bloc to keep the
664 // mass difference due to the deletion of the block
665 while(prevI > 0 && m_matrix(prevI, prevJ).alignment_type ==
667 {
668
669
670 if(prevI > 0)
671 sg_peptide_model[prevI - 1].bracket = true;
672 prevI--;
673 prevDelMass = m_matrix(prevI, prevJ).mass_difference;
674 if(prevI == 0)
675 {
676 prevDelMass = 0.0;
677 }
678 }
679
680 // check the mass delta to avoid showing a null mass delta
681 if(std::abs(actualDelMass - prevDelMass) >
683 {
684
685 int mass_i = actualI - 1;
686 if(mass_i == 0)
687 {
688 sg_peptide_model.setBeginMassDelta(actualDelMass -
689 prevDelMass);
690 }
691 else
692 {
693 sg_peptide_model[mass_i - 1].mass_difference =
694 actualDelMass - prevDelMass;
695 }
696 }
697
698 // if there this is just a re-align, we need to indicate the mass
699 // offset
700 }
701 else if(m_matrix(actualI, actualJ).alignment_type ==
703 {
704
705 int mass_i = actualI - 1;
706 if(mass_i == 0)
707 {
708 sg_peptide_model.setBeginMassDelta(actualDelMass -
709 prevDelMass);
710 }
711 else
712 {
713 sg_peptide_model[mass_i - 1].mass_difference =
714 actualDelMass - prevDelMass;
715 }
716 // the fact when you align the first amino acid, but there is a
717 // leak of Amino acid in OMS solution before
718 }
719 else if(actualI == 1 &&
720 m_matrix(actualI, actualJ).alignment_type ==
722 (std::abs(actualDelMass) > m_precisionPtr->getNominal()))
723 {
724 sg_peptide_model.setBeginMassDelta(actualDelMass);
725 }
726
727 actualI = prevI;
728 actualJ = prevJ;
729 }
730 }
731
732 // setModificationNumber(modifCount);
733
734 // return QString("%1_[%2]")
735 // .arg(pepModified)
736 // .arg(m_precursorMassDelta - totExplainMass);
737 return sg_peptide_model;
738}

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.

372{
373
374 auto it_peptide = peptide_spectrum.begin();
375 auto it_spectrum = experimental_spectrum.begin();
376 for(auto itr1 = m_matrix.begin1(); itr1 != m_matrix.end1();
377 ++itr1, it_peptide++)
378 {
379 it_spectrum = experimental_spectrum.begin();
380 for(auto itr2 = itr1.begin(); itr2 != itr1.end(); itr2++, it_spectrum++)
381 {
382 (*itr2).alignment_type = SpectralAlignmentType::nonAlign;
383 if(it_peptide == peptide_spectrum.begin())
384 (*itr2).alignment_type = SpectralAlignmentType::nonAlign;
385 (*itr2).origin_column_indices = 0;
386 (*itr2).score = 0;
387 (*itr2).mass_difference = it_spectrum->symmetric_mz - it_peptide->mz;
388 // qDebug() << " i=" << itr2.index1() << " j=" << itr2.index2()
389 // << " mass_difference=" << (*itr2).mass_difference;
390 }
391 }
392}

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.

163{
164 // long theoIndiceI = it_pos.index1();
165 // long expeIndiceJ = it_pos.index2();
166 // in first time, we set score corresponding to type of peak (initial/mirror
167 // or both) we set initial score to peak mirror or initial
170 // experimental_spectrum.at(expeIndiceJ).type;
171
174 int reAlignScoreNOToAdd =
176
177 switch(expePeakType)
178 {
180 // this is a symmetric peak
183 reAlignScoreNOToAdd =
185 if(m_BETTER_END_RA &&
186 it_pos.index1() == peptide_spectrum.getPeptideSp().get()->size())
187 {
188 reAlignScoreToAdd =
191 }
192 break;
194 // this is a native peak with a symmetric corresponding
197 reAlignScoreNOToAdd =
199 if(m_BETTER_END_RA &&
200 it_pos.index1() == peptide_spectrum.getPeptideSp().get()->size())
201 {
202 reAlignScoreToAdd =
205 }
206 break;
207 default:
208 // this is a native or synthetic peak
210 reAlignScoreToAdd =
212 reAlignScoreNOToAdd =
214 if(m_BETTER_END_RA &&
215 it_pos.index1() == peptide_spectrum.getPeptideSp().get()->size())
216 {
217 reAlignScoreToAdd =
220 }
221 break;
222 }
223 SpectralAlignmentDataPoint &matrix_data_point_i_j = *it_pos;
224
225 /*
226 long k = getkValue(it_pos,
227 peptide_spectrum.at(it_pos.index1()).diff_mz,
228 experimental_spectrum);
229
230 if(it_pos.index1() == 15)
231 qDebug() << "position1" << it_pos.index1() << "position2" << it_pos.index1()
232 << " k=" << k << " " << peptide_spectrum.at(it_pos.index1()).diff_mz;
233 */
234 pappso::MzRange aaMassRange(peptide_spectrum.at(it_pos.index1()).diff_mz,
236 qDebug();
237 // long k = -1;
238 auto itKpeak =
239 experimental_spectrum.reverseFindDiffMz(it_pos.index2(), aaMassRange);
240 // if(itKpeak != experimental_spectrum.rend())
241 // k = itKpeak->indice;
242
243 if(itKpeak == experimental_spectrum.rend())
244 {
245 matrix_data_point_i_j.score =
246 m_matrix(it_pos.index1() - 1, it_pos.index2()).score +
248 matrix_data_point_i_j.origin_column_indices = it_pos.index2();
249 matrix_data_point_i_j.alignment_type = SpectralAlignmentType::nonAlign;
250 }
251 else
252 {
253 SpectralAlignmentDataPoint &matrix_data_point_previ_k =
254 m_matrix(it_pos.index1() - 1, itKpeak->indice);
255 int scoreAlignK = matrix_data_point_previ_k.score + alignScoreToAdd;
256 // if it come from non align, we must verify that there is no offset from
257 // previous align
258 if(matrix_data_point_previ_k.alignment_type ==
260 {
261 int l;
262 for(l = it_pos.index1() - 1; l > 0; l--)
263 {
264 if(m_matrix(l, itKpeak->indice).origin_column_indices !=
265 itKpeak->indice)
266 break;
267 }
268 if(std::abs(m_matrix(l, itKpeak->indice).mass_difference -
269 (*it_pos).mass_difference) > m_precisionPtr->getNominal())
270 scoreAlignK = matrix_data_point_previ_k.score + reAlignScoreToAdd;
271 }
272
273 // int[0] = the j value m and int[1] = the score value
274 SpectralAlignmentDataPoint reAlignBestScore = getBestRealignScore(
275 it_pos, itKpeak->indice, reAlignScoreToAdd, reAlignScoreNOToAdd);
276
277 // For debug to see value for any match
278 // System.out.println("score k = " + scoreAlignK + " - score m = " +
279 // reAlignBestScore[1] + " - origin m = "
280 // + reAlignBestScore[0]);
281
282 if(scoreAlignK >= reAlignBestScore.score)
283 {
284 // setMatricesData(theoIndiceI, expeIndiceJ, scoreAlignK, k, 2);
285 matrix_data_point_i_j.score = scoreAlignK;
286 matrix_data_point_i_j.origin_column_indices = itKpeak->indice;
287 matrix_data_point_i_j.alignment_type = SpectralAlignmentType::align;
288 }
289 else
290 {
291 /*setMatricesData(theoIndiceI,
292 expeIndiceJ,
293 reAlignBestScore[1],
294 reAlignBestScore[0],
295 reAlignBestScore[2]);*/
296
297 matrix_data_point_i_j = reAlignBestScore;
298 }
299 }
300}
int get(ScoreValueType type)
SpectralAlignmentDataPoint getBestRealignScore(const boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 &it_pos, std::size_t expeIndicesK, int reAlignScore, int alignScoreToAdd)
const ExperimentalSpectrumDataPoint & getExperimentalSpectrumDataPoint(const boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 &itpos) const
@ scoreAlignNative
Score for good alignment native (int)
@ scoreReAlignSymNO
Score for re-alignment without offset symmetric (int)
@ scoreNonAlign
Score for non alignment (int)
@ scoreAlignBoth
Score for good alignment both (int)
@ scoreReAlignBoth
Score for re-alignment both (int)
@ scoreReAlignBothNO
Score for re-alignment without offset both (int)
@ scoreReAlignSym
Score for re-alignment symmetric (int)
@ scoreAlignSym
Score for good alignment symmetric (int)
@ scoreReAlignNativeNO
Score for re-alignment without offset native (int)
ExperimentalSpectrumDataPointType
Definition types.h:78
@ both
both, the ion and the complement exists in the original spectrum
@ symmetric
new peak : computed symmetric mass from a corresponding native peak

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.

310{
311
312 std::size_t previous_peptide_row = it_pos.index1() - 1;
313 SpectralAlignmentDataPoint return_data_point = *it_pos;
314 int bestScore = -10000;
315 int origin = -1;
316
317 // find the best score column indice on previous row, walking back from
318 // expeIndicesK m is a j value between 0 and k where a realign can be do if we
319 // accept mass offset
320 for(long m = expeIndicesK; m > -1; m--)
321 {
322 // the >= here is for keep the highest S value if there is multiple S with
323 // the same best score
324 if(m_matrix(previous_peptide_row, m).score > bestScore)
325 {
326 bestScore = m_matrix(previous_peptide_row, m).score;
327 origin = m;
328 }
329 }
330
331 return_data_point.origin_column_indices = origin;
332 return_data_point.score = bestScore + reAlignScore;
333 return_data_point.alignment_type = SpectralAlignmentType::reAlign; // [2] = 1;
334
335 if(origin == -1)
336 return return_data_point;
337
338 // We check for the last alignment if we have chain of Non Alignment to
339 // compare the last mass offset found
340 std::size_t lastAlignIndiceI = previous_peptide_row;
341 for(long l = previous_peptide_row; l > 0; l--)
342 {
343 if(m_matrix(l, origin).origin_column_indices != 0)
344 {
345 lastAlignIndiceI = l;
346 break;
347 }
348 }
349
350 // if the difference of mass offset between actual state and last align (or
351 // realign) is null, we consider that to an alignment
352 if((lastAlignIndiceI != (previous_peptide_row)) && (it_pos.index1() > 1) &&
353 (std::abs(m_matrix(previous_peptide_row, expeIndicesK).mass_difference -
354 m_matrix(lastAlignIndiceI, origin).mass_difference) <
356 {
357 return_data_point.score = bestScore + alignScoreToAdd;
358 return_data_point.alignment_type =
360 }
361
362 // we return the origin (value of m) and the associate calculated score and
363 // the type of Alignment
364 return return_data_point;
365}

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.

61{
63}

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.

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

References mcsp_experimentalSpectrum.

Referenced by fillMatricesWithScores().

◆ getMatrix()

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

Definition at line 395 of file spectralalignment.cpp.

396{
397 return m_matrix;
398}

References m_matrix.

◆ getMaxPosIterator()

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

Definition at line 421 of file spectralalignment.cpp.

422{
423 return m_itPosMax;
424}

References m_itPosMax.

◆ getMaxScore()

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

Definition at line 415 of file spectralalignment.cpp.

416{
417 return m_maxScore;
418}

References m_maxScore.

◆ getPeptideSpectraCsp()

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

Definition at line 66 of file spectralalignment.cpp.

67{
69}

References mcsp_peptideSpectrum.

◆ getPrecursorMzDelta()

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

Definition at line 435 of file spectralalignment.cpp.

436{
438}

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.

402{
403 std::vector<int> score;
404
405 auto itr1 = m_matrix.begin1() + row_indice;
406 for(auto itr2 = itr1.begin(); itr2 != itr1.end(); itr2++)
407 {
408 score.push_back((*itr2).score);
409 }
410
411 return score;
412}

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.

115{
118
119 double precursor_mass = mcsp_experimentalSpectrum.get()->getPrecursorMass();
120 std::size_t start = 1;
121 int max_score = m_maxScore;
122 pappso::specglob::PeptideSpectraCsp ref_best_peptide = ref_peptide;
123
124 while(start < ref_peptide.get()->getPeptideSp().get()->size() - 5)
125 {
126 pappso::PeptideSp peptide_sp = std::make_shared<pappso::Peptide>(
127 ref_peptide.get()->getPeptideSp().get()->getSequence().mid(start));
128 std::size_t length = peptide_sp.get()->size();
129 while(peptide_sp.get()->getMass() > (precursor_mass * 1.1))
130 {
131 peptide_sp = std::make_shared<pappso::Peptide>(
132 peptide_sp.get()->getSequence().mid(0, length - 1));
133 if(length > 1)
134 length--;
135 }
137 std::make_shared<pappso::specglob::PeptideSpectrum>(peptide_sp);
138 align(peptide_spectra, mcsp_experimentalSpectrum);
139
140 if(max_score < m_maxScore)
141 {
142 if(m_maxScore > 0)
143 {
144 model = buildPeptideModel();
145 model.eliminateComplementaryDelta(precision_ptr);
146 model.ltrimOnRemoval();
147 max_score = m_maxScore;
148 ref_best_peptide = mcsp_peptideSpectrum;
149 }
150 }
151 start++;
152 }
153 align(ref_best_peptide, mcsp_experimentalSpectrum);
154 return model;
155}
bool ltrimOnRemoval()
try to remove left amino acid if there is a removal
bool eliminateComplementaryDelta(pappso::PrecisionPtr precision)
std::shared_ptr< const PeptideSpectrum > PeptideSpectraCsp
std::shared_ptr< const Peptide > PeptideSp

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

◆ 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

◆ 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

◆ 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: