libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
spectree.h
Go to the documentation of this file.
1
/**
2
* \file pappsomspp/processing/spectree/spectree.h
3
* \date 11/12/2023
4
* \author Olivier Langella
5
* \brief Matthieu David's SpecTree structure
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 the GNU General Public License
32
* along with this program. If not, see <http://www.gnu.org/licenses/>.
33
*
34
*/
35
36
#pragma once
37
38
#include "
bucketclustering.h
"
39
#include <cstdlib>
40
#include <QString>
41
#include "
../uimonitor/uimonitorinterface.h
"
42
#include "
specxtractinterface.h
"
43
44
namespace
pappso
45
{
46
namespace
spectree
47
{
48
49
/**
50
* @todo write docs
51
*/
52
class
PMSPP_LIB_DECL
SpecTree
53
{
54
public
:
55
/**
56
* Build a SpecTree with BucketClustering
57
*/
58
SpecTree
(
const
BucketClustering
&bucket_clustering);
59
60
/**
61
* Destructor
62
*/
63
virtual
~SpecTree
();
64
65
QString
toString
()
const
;
66
67
/** @brief get the adress map of sepctrum index and their first node index
68
*
69
* convenience function intended for testing
70
* @return vector of the size of max spectrum index containing list of first
71
* node index
72
*/
73
const
std::vector<std::size_t> &
getSpectrumFirstNodeIndex
()
const
;
74
75
76
/**
77
* Extract all similarities above a threshold value between all spectra from
78
* the deepest one up to the given limit using the predefined extraction
79
* algorithm. The results are stored in the mentionned reporter.
80
*
81
* Performs the extraction of the similarities above a given threshold for all
82
* spectra between the deepest one and a given index in the transversal
83
* accessor. The extracted pairs are feed to a shifter to try to improve the
84
* spectrum identification. Afterwards, the retained results are written to
85
* the given reporter. This extraction step represents most of SpecOMS
86
* execution time. Note: This function heavily evolved through the development
87
* process to match new needs, it became clumsy and heavy. A clean refactor
88
* might be appropriate.
89
*
90
* @param monitor progress monitor, indicates progression in spectree
91
* @param spec_xtract report results of similarities to the user (write in
92
* file or consolidate)
93
* @param cart_id_range_max The position in the transversal accessor from
94
* which the similarities must be reported (item cart id)
95
* @param cart_id_range_min The position in the transversal accessor up to
96
* which the similarities must be reported (item cart id)
97
* @param target_cart_id_max targeted item cart id relevant for comparison
98
* @param target_cart_id_min targeted item cart id relevant for comparison
99
*/
100
void
xtract
(
UiMonitorInterface
&monitor,
101
SpecXtractInterface
&spec_xtract,
102
std::size_t minimum_count,
103
std::size_t cart_id_range_max,
104
std::size_t cart_id_range_min,
105
std::size_t target_cart_id_max,
106
std::size_t target_cart_id_min)
const
;
107
108
/** @brief get the number of common component for a pair of spectrum
109
* @param spectrum_a_index the first spectrum index
110
* @param spectrum_b_index the second spectrum index
111
* @return integer the number of common component between spectrum
112
*/
113
std::size_t
extractSpectrumPairSimilarityCount
(std::size_t spectrum_a_index,
114
std::size_t spectrum_b_index)
const
;
115
116
private
:
117
static
constexpr
std::size_t
index_not_defined
{std::numeric_limits<std::size_t>::max()};
118
struct
SpecTreeNode
119
{
120
std::size_t
parentIndex
=
index_not_defined
;
121
std::size_t
nextIndex
=
index_not_defined
;
122
std::size_t
value
;
123
std::size_t
count
;
124
};
125
126
struct
MapSimilarityCountElement
127
{
128
std::size_t
lastWitness
=
index_not_defined
;
129
std::size_t
count
= 0;
130
bool
aboveThreshold
=
false
;
131
};
132
struct
MapSimilarityCount
133
{
134
std::vector<std::size_t>
keys
;
135
std::vector<std::size_t>
aboveThreshold
;
136
std::vector<MapSimilarityCountElement>
map_id_count
;
137
};
138
139
void
addNewNode
(
const
SpecTreeNode
&node);
140
void
manageSideAccess
(std::vector<std::size_t> &spectrumLastNodeIndex);
141
void
walkBackInBranchFromNode
(
const
SpecTree::SpecTreeNode
&start_node,
142
MapSimilarityCount
&map_count,
143
std::size_t minimum_count,
144
std::size_t target_cart_id_max,
145
std::size_t target_cart_id_min)
const
;
146
147
std::size_t
walkBackInBranchFromNodeToTarget
(
const
SpecTree::SpecTreeNode
&start_node,
148
std::size_t spectrum_index_target)
const
;
149
150
/** @brief get a map of similarities for a given spectrum index
151
*
152
* this function can only retrieve spectrum index map lower than the spectrum
153
* index given in the parameters (check original publication for details)
154
*
155
* @param spectrum_index the spectrum index to retrieve similarities
156
* @param spectrum_index_lower_limit lower spectrum index limit to save CPU
157
* (do not use it if you want a full similarity map)
158
* @return map of spectrum_index keys containing the corresponding count value
159
* (similarity) for the targeted spectrum index
160
*/
161
void
extractSpectrumSimilarityCount
(
MapSimilarityCount
&map_count,
162
std::size_t minimum_count,
163
std::size_t spectrum_index,
164
std::size_t target_cart_id_max,
165
std::size_t target_cart_id_min)
const
;
166
167
168
private
:
169
std::vector<SpecTreeNode>
m_nodeList
;
170
std::vector<std::size_t>
m_spectrumFirstNodeIndex
;
171
};
172
}
// namespace spectree
173
}
// namespace pappso
bucketclustering.h
pappso::UiMonitorInterface
Definition
uimonitorinterface.h:50
pappso::spectree::BucketClustering
Definition
bucketclustering.h:56
pappso::spectree::SpecTree::m_nodeList
std::vector< SpecTreeNode > m_nodeList
Definition
spectree.h:169
pappso::spectree::SpecTree::walkBackInBranchFromNodeToTarget
std::size_t walkBackInBranchFromNodeToTarget(const SpecTree::SpecTreeNode &start_node, std::size_t spectrum_index_target) const
Definition
spectree.cpp:361
pappso::spectree::SpecTree::getSpectrumFirstNodeIndex
const std::vector< std::size_t > & getSpectrumFirstNodeIndex() const
get the adress map of sepctrum index and their first node index
Definition
spectree.cpp:219
pappso::spectree::SpecTree::index_not_defined
static constexpr std::size_t index_not_defined
Definition
spectree.h:117
pappso::spectree::SpecTree::walkBackInBranchFromNode
void walkBackInBranchFromNode(const SpecTree::SpecTreeNode &start_node, MapSimilarityCount &map_count, std::size_t minimum_count, std::size_t target_cart_id_max, std::size_t target_cart_id_min) const
Definition
spectree.cpp:307
pappso::spectree::SpecTree::m_spectrumFirstNodeIndex
std::vector< std::size_t > m_spectrumFirstNodeIndex
Definition
spectree.h:170
pappso::spectree::SpecTree::toString
QString toString() const
Definition
spectree.cpp:194
pappso::spectree::SpecTree::extractSpectrumPairSimilarityCount
std::size_t extractSpectrumPairSimilarityCount(std::size_t spectrum_a_index, std::size_t spectrum_b_index) const
get the number of common component for a pair of spectrum
Definition
spectree.cpp:418
pappso::spectree::SpecTree::manageSideAccess
void manageSideAccess(std::vector< std::size_t > &spectrumLastNodeIndex)
Definition
spectree.cpp:170
pappso::spectree::SpecTree::addNewNode
void addNewNode(const SpecTreeNode &node)
Definition
spectree.cpp:164
pappso::spectree::SpecTree::extractSpectrumSimilarityCount
void extractSpectrumSimilarityCount(MapSimilarityCount &map_count, std::size_t minimum_count, std::size_t spectrum_index, std::size_t target_cart_id_max, std::size_t target_cart_id_min) const
get a map of similarities for a given spectrum index
Definition
spectree.cpp:393
pappso::spectree::SpecTree::SpecTree
SpecTree(const BucketClustering &bucket_clustering)
Definition
spectree.cpp:48
pappso::spectree::SpecTree::xtract
void xtract(UiMonitorInterface &monitor, SpecXtractInterface &spec_xtract, std::size_t minimum_count, std::size_t cart_id_range_max, std::size_t cart_id_range_min, std::size_t target_cart_id_max, std::size_t target_cart_id_min) const
Definition
spectree.cpp:225
pappso::spectree::SpecXtractInterface
yield similarities between pairs of ItemCart
Definition
specxtractinterface.h:53
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition
export-import-config.h:14
pappso::spectree
Definition
bucket.cpp:43
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
specxtractinterface.h
pappso::spectree::SpecTree::MapSimilarityCountElement
Definition
spectree.h:127
pappso::spectree::SpecTree::MapSimilarityCountElement::lastWitness
std::size_t lastWitness
Definition
spectree.h:128
pappso::spectree::SpecTree::MapSimilarityCountElement::aboveThreshold
bool aboveThreshold
Definition
spectree.h:130
pappso::spectree::SpecTree::MapSimilarityCountElement::count
std::size_t count
Definition
spectree.h:129
pappso::spectree::SpecTree::MapSimilarityCount
Definition
spectree.h:133
pappso::spectree::SpecTree::MapSimilarityCount::map_id_count
std::vector< MapSimilarityCountElement > map_id_count
Definition
spectree.h:136
pappso::spectree::SpecTree::MapSimilarityCount::aboveThreshold
std::vector< std::size_t > aboveThreshold
Definition
spectree.h:135
pappso::spectree::SpecTree::MapSimilarityCount::keys
std::vector< std::size_t > keys
Definition
spectree.h:134
pappso::spectree::SpecTree::SpecTreeNode
Definition
spectree.h:119
pappso::spectree::SpecTree::SpecTreeNode::count
std::size_t count
Definition
spectree.h:123
pappso::spectree::SpecTree::SpecTreeNode::parentIndex
std::size_t parentIndex
Definition
spectree.h:120
pappso::spectree::SpecTree::SpecTreeNode::nextIndex
std::size_t nextIndex
Definition
spectree.h:121
pappso::spectree::SpecTree::SpecTreeNode::value
std::size_t value
Definition
spectree.h:122
uimonitorinterface.h
pappsomspp
core
processing
spectree
spectree.h
Generated on
for libpappsomspp by
1.17.0