libpappsomspp
Library for mass spectrometry
locationsaver.h
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/specpeptidoms/locationsaver.h
3 * \date 24/03/2025
4 * \author Aurélien Berthier
5 * \brief save protein subsequences for alignment
6 *
7 * C++ implementation of the SpecPeptidOMS algorithm described in :
8 * (1) Benoist, É.; Jean, G.; Rogniaux, H.; Fertin, G.; Tessier, D. SpecPeptidOMS Directly and
9 * Rapidly Aligns Mass Spectra on Whole Proteomes and Identifies Peptides That Are Not Necessarily
10 * Tryptic: Implications for Peptidomics. J. Proteome Res. 2025.
11 * https://doi.org/10.1021/acs.jproteome.4c00870.
12 */
13
14/*
15 * Copyright (c) 2025 Aurélien Berthier
16 * <aurelien.berthier@ls2n.fr>
17 *
18 * This program is free software: you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation, either version 3 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 */
31
32#pragma once
33
34#include <cstddef>
35#include <vector>
36#include <algorithm>
37#include <QString>
38
39namespace pappso
40{
41namespace specpeptidoms
42{
43
45{
46 // std::vector<uint8_t> prot_sequence;
47 std::size_t beginning, length;
48 int tree, score;
49 QString protein; // Protein accession TODO : use an id
50};
51
53{
54 public:
55 /**
56 * Constructor
57 */
59
60 /**
61 * Destructor
62 */
64
65 /**
66 * @brief Adds a location to the locations heap. If a saved location has the same tree_id, it will
67 * replace it. Otherwise, it replaces the location with the lowest score.
68 */
69 void addLocation(
70 std::size_t beginning, std::size_t length, int tree, int score, const QString &protein);
71
72 /**
73 * @brief Returns a vector containing the saved locations.
74 * @return vector of Location of size MAX_SAVED_ALIGNMENTS
75 */
76 std::vector<Location> getLocations() const;
77
78 /**
79 * @brief Creates a new alignment tree and returns its id
80 */
81 std::size_t getNextTree();
82
83 /**
84 * @brief Returns the minimum score for a location with the provided tree_id to be saved in the
85 * heap.
86 */
87 int getMinScore(int tree_id) const;
88
89 void resetLocationSaver();
90
91 private:
92 static bool locationCompare(const Location &loc1, const Location &loc2);
93
94 std::vector<Location> m_locations_heap;
95 std::vector<int> m_tree_scores;
96 std::vector<bool> m_tree_in_heap;
98};
99} // namespace specpeptidoms
100} // namespace pappso
int getMinScore(int tree_id) const
Returns the minimum score for a location with the provided tree_id to be saved in the heap.
static bool locationCompare(const Location &loc1, const Location &loc2)
void addLocation(std::size_t beginning, std::size_t length, int tree, int score, const QString &protein)
Adds a location to the locations heap. If a saved location has the same tree_id, it will replace it....
std::vector< Location > getLocations() const
Returns a vector containing the saved locations.
std::vector< Location > m_locations_heap
Definition: locationsaver.h:94
std::size_t getNextTree()
Creates a new alignment tree and returns its id.
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39