libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
bucket.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/spectree/bucket.cpp
3 * \date 13/12/2023
4 * \author Olivier Langella
5 * \brief bucket for spectree
6 *
7 * C++ implementation of algorithm already described in :
8 * 1. David, M., Fertin, G., Rogniaux, H. & Tessier, D. SpecOMS: A Full Open
9 * Modification Search Method Performing All-to-All Spectra Comparisons within
10 * Minutes. J. Proteome Res. 16, 3030–3038 (2017).
11 *
12 * https://www.theses.fr/2019NANT4092
13 */
14
15
16/*
17 * SpecTree
18 * Copyright (C) 2023 Olivier Langella
19 * <olivier.langella@universite-paris-saclay.fr>
20 *
21 * This program is free software: you can redistribute ipetide to spectrum
22 * alignmentt and/or modify it under the terms of the GNU General Public License
23 * as published by the Free Software Foundation, either version 3 of the
24 * License, or (at your option) any later version.
25 *
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
30 *
31 * You should have received a copy of th^e GNU General Public License
32 * along with this program. If not, see <http://www.gnu.org/licenses/>.
33 *
34 */
35
36#include "bucket.h"
37#include <algorithm>
38
39
40namespace pappso
41{
42namespace spectree
43{
44
45Bucket::Bucket(std::size_t val)
46{
47 m_itemId = val;
48}
49
50Bucket::Bucket(const Bucket &other) : m_cartList(other.m_cartList)
51{
52 m_itemId = other.m_itemId;
53}
54
55void
56Bucket::push_back(std::size_t cart)
57{
58 m_cartList.push_back(cart);
59}
60
61std::size_t
63{
64 return m_cartList.size();
65}
66
67std::size_t
69{
70 return m_itemId;
71}
72
73
74bool
75Bucket::operator<(const Bucket &bucket_b) const
76{
77
78 auto it_bucket_end = m_cartList.end();
79 auto it_bucket_b_end = bucket_b.m_cartList.end();
80
81 auto it_bucket = m_cartList.begin();
82 auto it_bucket_b = bucket_b.m_cartList.begin();
83
84 for(; it_bucket != it_bucket_end && it_bucket_b != it_bucket_b_end;
85 it_bucket++, it_bucket_b++)
86 {
87 if(*it_bucket != *it_bucket_b)
88 return (*it_bucket < *it_bucket_b);
89 }
90
91 // When the buckets have an equal content until the limit, the shortest one
92 // is returned first
93 return (m_cartList.size() < bucket_b.m_cartList.size());
94}
95
96std::size_t
98{
99 return m_cartList.front();
100}
101
102std::size_t
104{
105 return m_cartList.back();
106}
107
108const std::vector<std::size_t> &
110{
111 return m_cartList;
112}
113} // namespace spectree
114} // namespace pappso
bucket for spectree
std::size_t size() const
Definition bucket.cpp:62
bool operator<(const Bucket &bucket_two) const
Definition bucket.cpp:75
std::size_t m_itemId
Definition bucket.h:118
void push_back(std::size_t cart)
Definition bucket.cpp:56
std::vector< std::size_t > m_cartList
Definition bucket.h:127
Bucket(std::size_t val)
Definition bucket.cpp:45
std::size_t back() const
get the last cart id of the list
Definition bucket.cpp:103
std::size_t getId() const
Definition bucket.cpp:68
std::size_t front() const
get the first cart id of the list
Definition bucket.cpp:97
const std::vector< std::size_t > & getCartList() const
Definition bucket.cpp:109
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39