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"
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 /** @brief build the alignment matrix between a peptide sequence and an
80 * experimental spectrum
81 *
82 * @param peptide_spectrum the peptide sequence
83 * @param experimental_spectrum the experimental spectrum
84 */
85 void align(PeptideSpectraCsp peptide_spectrum,
86 ExperimentalSpectrumCsp experimental_spectrum);
87
88 /** @brief trim the current peptide to get a minimal alignment score
89 */
90 PeptideModel rtrim(PrecisionPtr precision_ptr);
91
92 const matrix<SpectralAlignmentDataPoint> &getMatrix() const;
93 std::vector<int> getScoreRow(std::size_t row_indice) const;
94
95 int getMaxScore() const;
96
97 boost::numeric::ublas::matrix<SpectralAlignmentDataPoint>::iterator2
98 getMaxPosIterator() const;
99
100 double getPrecursorMzDelta() const;
101
102
103 /**
104 * Backtrack is here to get the HitModified Sequence during the backtrack of
105 * score calculation. It start from best score align case in matrix and use
106 * origin matrix to go back to the start of the alignment
107 *
108 * @param row : the row indices of the best score
109 * @param column : the column indices of the best score
110 * @param precision : the precision of measures
111 */
112
113 QString backTrack() const;
114
115
116 PeptideModel buildPeptideModel() const;
117
118 ExperimentalSpectrumCsp getExperimentalSpectrumCsp() const;
119
120 PeptideSpectraCsp getPeptideSpectraCsp() const;
121
122 private:
123 const ExperimentalSpectrumDataPoint &getExperimentalSpectrumDataPoint(
124 const boost::numeric::ublas::matrix<SpectralAlignmentDataPoint>::iterator2
125 &itpos) const;
126
127 void fillMassDelta(const PeptideSpectrum &peptide_spectrum,
128 const ExperimentalSpectrum &experimental_spectrum);
129
130
131 /**
132 * This method do the alignment of the 2 Spectra and fill matrices at actual
133 * coordinates i(row - theoretical) and j(column - experimental)
134 *
135 * @param theoIndiceI : The actual theoretical peak indices
136 * @param expeIndiceJ : The actual experimental peak indices
137 *
138 */
139 void fillMatricesWithScores(
140 const boost::numeric::ublas::matrix<SpectralAlignmentDataPoint>::iterator2
141 &it_pos,
142 const PeptideSpectrum &peptide_spectrum,
143 const ExperimentalSpectrum &experimental_spectrum);
144
145
146 /**
147 * Method to get a realigned j value of where come from the realignment and
148 * get the associated realigned score
149 *
150 * @param theoIndicesI : The row where we are actually
151 * @param expeIndicesK : The founded k indices
152 * @param expeIndicesJ : The column where we are actually
153 * @param reAlignScore : Score to add if it is needed to add offset to
154 * realign
155 * @param alignScoreToAdd : Score to add if there is an alignment with peak k
156 * @param precision : Precision of measures
157 * @return an int[] where int[0] is the origin column (m) where come from the
158 * re-alignment and int[1] is the calculated re-aligned score and
159 * int[3] is the alignment type code
160 *
161 */
162 SpectralAlignmentDataPoint getBestRealignScore(
163 const boost::numeric::ublas::matrix<SpectralAlignmentDataPoint>::iterator2
164 &it_pos,
165 std::size_t expeIndicesK,
166 int reAlignScore,
167 int alignScoreToAdd);
168
169
170 private:
173 matrix<SpectralAlignmentDataPoint> m_matrix; // x <= peptide, y <= spectrum
177 boost::numeric::ublas::matrix<SpectralAlignmentDataPoint>::iterator2
179
180 double m_precursorMassDelta =
181 0; // diffference between precursor ion and theoretical peptide ion
182
183 /**
184 * modifies the score on the last amino acid alignment (RA score
185 * rather than NA
186 * Not documented anyMore in the interface
187 */
188
189 bool m_BETTER_END_RA = false;
190};
191} // namespace specglob
192} // 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