39#include "../../exception/exceptioninterrupted.h"
40#include "../../exception/exceptionoutofrange.h"
52 std::vector<Bucket> bins = bucket_clustering.
asSortedList();
54 node.
value = bins[0].getCartList().at(0);
56 qDebug() << node.
value;
62 std::vector<std::size_t> spectrumLastNodeIndex;
73 for(std::size_t cpt = 1; cpt < bins[0].size(); ++cpt)
77 node.
value = bins[0].getCartList().at(cpt);
88 for(std::size_t bins_index = 1; bins_index < bins.size(); ++bins_index)
90 qDebug() <<
"bins_index=" << bins_index;
95 std::size_t previous_bin_size = bins[bins_index - 1].size();
98 if(pos < previous_bin_size)
100 if(bins[bins_index].getCartList().at(pos) ==
101 bins[bins_index - 1].getCartList().at(pos))
110 qDebug() <<
"common pos=" << pos;
111 std::size_t spectrum_index = bins[bins_index].getCartList().at(pos);
112 qDebug() <<
"common spectrum_index=" << spectrum_index;
113 std::size_t tempNodeIndex = spectrumLastNodeIndex[spectrum_index];
114 qDebug() <<
"common tempNodeIndex=" << tempNodeIndex;
119 if((previous_bin_size - 1 == pos) ||
120 (bins[bins_index].size() - 1 == pos))
122 qDebug() <<
"last one";
127 qDebug() <<
"bins[bins_index - 1].getSpectrumIndex(pos + 1)="
128 << bins[bins_index - 1].getCartList().at(pos + 1);
129 qDebug() <<
"bins[bins_index].getSpectrumIndex(pos + 1)="
130 << bins[bins_index].getCartList().at(pos + 1);
131 if(bins[bins_index - 1].getCartList().at(pos + 1) !=
132 bins[bins_index].getCartList().at(pos + 1))
137 parentNode = tempNodeIndex;
140 qDebug() <<
"common=" << common;
146 while(pos < bins[bins_index].size())
148 std::size_t spectrum_index = bins[bins_index].getCartList().at(pos);
152 node.
value = spectrum_index;
176 auto spectrum_index =
m_nodeList.back().value;
182 spectrumLastNodeIndex[spectrum_index] = node_position;
186 if(spectrumLastNodeIndex[spectrum_index] == node_position)
191 m_nodeList[spectrumLastNodeIndex[spectrum_index]].nextIndex =
193 spectrumLastNodeIndex[spectrum_index] = node_position;
201 QString node_str(
"node|spectrum|parent|next|count|\n");
207 parent = node.parentIndex;
210 next = node.nextIndex;
211 node_str.append(QString(
"node_%1|%2|%3|%4|%5end\n")
223const std::vector<std::size_t> &
232 std::size_t minimum_count,
233 std::size_t cart_id_range_max,
234 std::size_t cart_id_range_min,
235 std::size_t target_cart_id_max,
236 std::size_t target_cart_id_min)
const
239 if(cart_id_range_max < cart_id_range_min)
241 std::swap(cart_id_range_max, cart_id_range_min);
247 monitor.
setStatus(QObject::tr(
"starting SpecXtract operation"));
258 std::size_t spectra1 = cart_id_range_max;
259 monitor.
setTotalSteps(cart_id_range_max - cart_id_range_min);
266 QObject::tr(
"SpecXtract job stopped"));
268 qDebug() <<
"spectra1=" << spectra1;
273 map_count.
keys.clear();
282 qDebug() <<
"spectra1=" << spectra1
283 <<
" map_count.aboveThreshold.size()="
285 <<
" map_count.keys.size()=" << map_count.
keys.size();
291 qDebug() <<
"spectra2=" << spectra2;
296 spectra1, spectra2, map_count.
map_id_count.at(spectra2).count);
301 if(spectra1 == cart_id_range_min)
310 "item cart index %1 out of range (item cart id max size=%2)")
311 .arg(cart_id_range_max)
320 std::size_t minimum_count,
321 std::size_t target_cart_id_max,
322 std::size_t target_cart_id_min)
const
327 qDebug() <<
" start node spectrum=" << start_node.
value
328 <<
" parent_id=" << parent_id <<
" init_count=" << start_node.
count
329 <<
" minimum_count=" << minimum_count
330 <<
" target_cart_id_min=" << target_cart_id_min;
337 if(current_node.
value < target_cart_id_min)
339 if(current_node.
value <= target_cart_id_max)
342 if(map_id_count.lastWitness == start_node.
value)
344 map_id_count.count += start_node.
count;
347 if((map_id_count.count >= minimum_count) &&
348 (map_id_count.aboveThreshold ==
false))
350 map_id_count.aboveThreshold =
true;
356 map_id_count.lastWitness = start_node.
value;
357 map_id_count.count = start_node.
count;
358 map_id_count.aboveThreshold =
false;
361 if(map_id_count.count >= minimum_count)
363 map_id_count.aboveThreshold =
true;
366 map_count.
keys.push_back(current_node.
value);
376 std::size_t spectrum_index_target)
const
385 if(current_node.
value < spectrum_index_target)
387 if(current_node.
value == spectrum_index_target)
388 return start_node.
count;
408 std::size_t minimum_count,
409 std::size_t spectrum_index,
410 std::size_t target_cart_id_max,
411 std::size_t target_cart_id_min)
const
414 qDebug() <<
" spectrum_index=" << spectrum_index;
421 qDebug() <<
"node_index=" << node_index;
436 std::size_t spectrum_b_index)
const
438 if(spectrum_a_index > spectrum_b_index)
439 std::swap(spectrum_a_index, spectrum_b_index);
441 std::size_t count_target = 0;
447 qDebug() <<
"node_index=" << node_index;
459 "spectrum_index %1 out of range (spectrum_index max size=%2)")
460 .arg(spectrum_b_index)
virtual void setStatus(const QString &status)=0
current status of the process
virtual void setTotalSteps(std::size_t total_number_of_steps)
use it if the number of steps is known in an algorithm the total number of steps is usefull to report...
virtual bool shouldIstop()=0
should the procces be stopped ? If true, then cancel process Use this function at strategic point of ...
virtual void count()=0
count steps report when a step is computed in an algorithm
std::vector< Bucket > asSortedList() const
std::size_t getItemCartCount() const
std::vector< SpecTreeNode > m_nodeList
std::size_t walkBackInBranchFromNodeToTarget(const SpecTree::SpecTreeNode &start_node, std::size_t spectrum_index_target) const
const std::vector< std::size_t > & getSpectrumFirstNodeIndex() const
get the adress map of sepctrum index and their first node index
static constexpr std::size_t index_not_defined
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
std::vector< std::size_t > m_spectrumFirstNodeIndex
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
void manageSideAccess(std::vector< std::size_t > &spectrumLastNodeIndex)
void addNewNode(const SpecTreeNode &node)
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
SpecTree(const BucketClustering &bucket_clustering)
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
yield similarities between pairs of ItemCart
virtual void beginItemCartExtraction(std::size_t cart_id_a)
virtual void reportSimilarity(std::size_t cart_id_a, std::size_t cart_id_b, std::size_t similarity)=0
virtual void endItemCartExtraction(std::size_t cart_id_a)
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Matthieu David's SpecTree structure.
std::vector< MapSimilarityCountElement > map_id_count
std::vector< std::size_t > aboveThreshold
std::vector< std::size_t > keys