libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
spectralalignment.h
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/specglob/spectraalignment.h
3 * \date 08/11/2023
4 * \author Olivier Langella
5 * \brief petide to spectrum alignment
6 *
7 * C++ implementation of the SpecGlob algorithm described in :
8 * 1. Prunier, G. et al. Fast alignment of mass spectra in large proteomics
9 * datasets, capturing dissimilarities arising from multiple complex
10 * modifications of peptides. BMC Bioinformatics 24, 421 (2023).
11 *
12 * HAL Id : hal-04296170 , version 1
13 * Mot de passe : hxo20cl
14 * DOI : 10.1186/s12859-023-05555-y
15 */
16
17
18/*
19 * SpecGlobTool, Spectra to peptide alignment tool
20 * Copyright (C) 2023 Olivier Langella
21 * <olivier.langella@universite-paris-saclay.fr>
22 *
23 * This program is free software: you can redistribute it and/or modify
24 * it under the terms of the GNU General Public License as published by
25 * the Free Software Foundation, either version 3 of the License, or
26 * (at your option) any later version.
27 *
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
32 *
33 * You should have received a copy of the GNU General Public License
34 * along with this program. If not, see <http://www.gnu.org/licenses/>.
35 *
36 */
37
38#pragma once
39#include <boost/numeric/ublas/matrix.hpp>
41#include "peptidespectrum.h"
42#include "scorevalues.h"
43#include "peptidemodel.h"
44#include "../../exportinmportconfig.h"
45
46using namespace boost::numeric::ublas;
47
48
49namespace pappso
50{
51namespace specglob
52{
60
61/**
62 * @todo write docs
63 */
65{
66 public:
67 /**
68 * Default constructor
69 */
70 SpectralAlignment(ScoreValues score_values,
71 pappso::PrecisionPtr precision_ptr);
72
73 /**
74 * Destructor
75 */
77
78
79 void align(PeptideSpectraCsp peptide_spectrum,
80 ExperimentalSpectrumCsp experimental_spectrum);
81
82 const matrix<SpectralAlignmentDataPoint> &getMatrix() const;
83 std::vector<int> getScoreRow(std::size_t row_indice) const;
84
85 int getMaxScore() const;
86
87 boost::numeric::ublas::matrix<SpectralAlignmentDataPoint>::iterator2
88 getMaxPosIterator() const;
89
90 double getPrecursorMzDelta() const;
91
92
93 /**
94 * Backtrack is here to get the HitModified Sequence during the backtrack of
95 * score calculation. It start from best score align case in matrix and use
96 * origin matrix to go back to the start of the alignment
97 *
98 * @param row : the row indices of the best score
99 * @param column : the column indices of the best score
100 * @param precision : the precision of measures
101 */
102
103 QString backTrack() const;
104
105
106 PeptideModel buildPeptideModel() const;
107
108 ExperimentalSpectrumCsp getExperimentalSpectrumCsp() const;
109
110 PeptideSpectraCsp getPeptideSpectraCsp() const;
111
112 private:
113 const ExperimentalSpectrumDataPoint &getExperimentalSpectrumDataPoint(
114 const boost::numeric::ublas::matrix<SpectralAlignmentDataPoint>::iterator2
115 &itpos) const;
116
117 void fillMassDelta(const PeptideSpectrum &peptide_spectrum,
118 const ExperimentalSpectrum &experimental_spectrum);
119
120
121 /**
122 * This method do the alignment of the 2 Spectra and fill matrices at actual
123 * coordinates i(row - theoretical) and j(column - experimental)
124 *
125 * @param theoIndiceI : The actual theoretical peak indices
126 * @param expeIndiceJ : The actual experimental peak indices
127 *
128 */
129 void fillMatricesWithScores(
130 const boost::numeric::ublas::matrix<SpectralAlignmentDataPoint>::iterator2
131 &it_pos,
132 const PeptideSpectrum &peptide_spectrum,
133 const ExperimentalSpectrum &experimental_spectrum);
134
135
136 /**
137 * Method to get a realigned j value of where come from the realignment and
138 * get the associated realigned score
139 *
140 * @param theoIndicesI : The row where we are actually
141 * @param expeIndicesK : The founded k indices
142 * @param expeIndicesJ : The column where we are actually
143 * @param reAlignScore : Score to add if it is needed to add offset to
144 * realign
145 * @param alignScoreToAdd : Score to add if there is an alignment with peak k
146 * @param precision : Precision of measures
147 * @return an int[] where int[0] is the origin column (m) where come from the
148 * re-alignment and int[1] is the calculated re-aligned score and
149 * int[3] is the alignment type code
150 *
151 */
152 SpectralAlignmentDataPoint getBestRealignScore(
153 const boost::numeric::ublas::matrix<SpectralAlignmentDataPoint>::iterator2
154 &it_pos,
155 std::size_t expeIndicesK,
156 int reAlignScore,
157 int alignScoreToAdd);
158
159
160 private:
163 matrix<SpectralAlignmentDataPoint> m_matrix; // x <= peptide, y <= spectrum
167 boost::numeric::ublas::matrix<SpectralAlignmentDataPoint>::iterator2
169
170 double m_precursorMassDelta =
171 0; // diffference between precursor ion and theoretical peptide ion
172
173 /**
174 * modifies the score on the last amino acid alignment (RA score
175 * rather than NA
176 * Not documented anyMore in the interface
177 */
178
179 bool m_BETTER_END_RA = false;
180};
181} // namespace specglob
182} // namespace pappso
ExperimentalSpectrumCsp mcsp_experimentalSpectrum
boost::numeric::ublas::matrix< SpectralAlignmentDataPoint >::iterator2 m_itPosMax
matrix< SpectralAlignmentDataPoint > m_matrix
transform a spectrum to SpecGlob spectra
#define PMSPP_LIB_DECL
std::shared_ptr< const PeptideSpectrum > PeptideSpectraCsp
std::shared_ptr< const ExperimentalSpectrum > ExperimentalSpectrumCsp
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
SpecGlobTool peptide model.
transform a peptide to SpecGlob spectrum
scores to apply in comparisons