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;
71 for(std::size_t cpt = 1; cpt < bins[0].size(); ++cpt)
75 node.
value = bins[0].getCartList().at(cpt);
86 for(std::size_t bins_index = 1; bins_index < bins.size(); ++bins_index)
88 qDebug() <<
"bins_index=" << bins_index;
93 std::size_t previous_bin_size = bins[bins_index - 1].size();
96 if(pos < previous_bin_size)
98 if(bins[bins_index].getCartList().at(pos) == bins[bins_index - 1].getCartList().at(pos))
107 qDebug() <<
"common pos=" << pos;
108 std::size_t spectrum_index = bins[bins_index].getCartList().at(pos);
109 qDebug() <<
"common spectrum_index=" << spectrum_index;
110 std::size_t tempNodeIndex = spectrumLastNodeIndex[spectrum_index];
111 qDebug() <<
"common tempNodeIndex=" << tempNodeIndex;
116 if((previous_bin_size - 1 == pos) || (bins[bins_index].size() - 1 == pos))
118 qDebug() <<
"last one";
123 qDebug() <<
"bins[bins_index - 1].getSpectrumIndex(pos + 1)="
124 << bins[bins_index - 1].getCartList().at(pos + 1);
125 qDebug() <<
"bins[bins_index].getSpectrumIndex(pos + 1)="
126 << bins[bins_index].getCartList().at(pos + 1);
127 if(bins[bins_index - 1].getCartList().at(pos + 1) !=
128 bins[bins_index].getCartList().at(pos + 1))
133 parentNode = tempNodeIndex;
136 qDebug() <<
"common=" << common;
142 while(pos < bins[bins_index].size())
144 std::size_t spectrum_index = bins[bins_index].getCartList().at(pos);
148 node.
value = spectrum_index;
172 auto spectrum_index =
m_nodeList.back().value;
178 spectrumLastNodeIndex[spectrum_index] = node_position;
182 if(spectrumLastNodeIndex[spectrum_index] == node_position)
187 m_nodeList[spectrumLastNodeIndex[spectrum_index]].nextIndex = node_position;
188 spectrumLastNodeIndex[spectrum_index] = node_position;
196 QString node_str(
"node|spectrum|parent|next|count|\n");
202 parent = node.parentIndex;
205 next = node.nextIndex;
206 node_str.append(QString(
"node_%1|%2|%3|%4|%5end\n")
218const std::vector<std::size_t> &
227 std::size_t minimum_count,
228 std::size_t cart_id_range_max,
229 std::size_t cart_id_range_min,
230 std::size_t target_cart_id_max,
231 std::size_t target_cart_id_min)
const
234 if(cart_id_range_max < cart_id_range_min)
236 std::swap(cart_id_range_max, cart_id_range_min);
242 monitor.
setStatus(QObject::tr(
"starting SpecXtract operation"));
253 std::size_t spectra1 = cart_id_range_max;
254 monitor.
setTotalSteps(cart_id_range_max - cart_id_range_min);
262 qDebug() <<
"spectra1=" << spectra1;
267 map_count.
keys.clear();
271 map_count, minimum_count, spectra1, target_cart_id_max, target_cart_id_min);
273 qDebug() <<
"spectra1=" << spectra1
274 <<
" map_count.aboveThreshold.size()=" << map_count.
aboveThreshold.size()
275 <<
" map_count.keys.size()=" << map_count.
keys.size();
281 qDebug() <<
"spectra2=" << spectra2;
286 spectra1, spectra2, map_count.
map_id_count.at(spectra2).count);
291 if(spectra1 == cart_id_range_min)
299 QObject::tr(
"item cart index %1 out of range (item cart id max size=%2)")
300 .arg(cart_id_range_max)
309 std::size_t minimum_count,
310 std::size_t target_cart_id_max,
311 std::size_t target_cart_id_min)
const
316 qDebug() <<
" start node spectrum=" << start_node.
value <<
" parent_id=" << parent_id
317 <<
" init_count=" << start_node.
count <<
" minimum_count=" << minimum_count
318 <<
" target_cart_id_min=" << target_cart_id_min;
325 if(current_node.
value < target_cart_id_min)
327 if(current_node.
value <= target_cart_id_max)
330 if(map_id_count.lastWitness == start_node.
value)
332 map_id_count.count += start_node.
count;
335 if((map_id_count.count >= minimum_count) && (map_id_count.aboveThreshold ==
false))
337 map_id_count.aboveThreshold =
true;
343 map_id_count.lastWitness = start_node.
value;
344 map_id_count.count = start_node.
count;
345 map_id_count.aboveThreshold =
false;
348 if(map_id_count.count >= minimum_count)
350 map_id_count.aboveThreshold =
true;
353 map_count.
keys.push_back(current_node.
value);
362 std::size_t spectrum_index_target)
const
371 if(current_node.
value < spectrum_index_target)
373 if(current_node.
value == spectrum_index_target)
374 return start_node.
count;
394 std::size_t minimum_count,
395 std::size_t spectrum_index,
396 std::size_t target_cart_id_max,
397 std::size_t target_cart_id_min)
const
400 qDebug() <<
" spectrum_index=" << spectrum_index;
407 qDebug() <<
"node_index=" << node_index;
411 current_node, map_count, minimum_count, target_cart_id_max, target_cart_id_min);
419 std::size_t spectrum_b_index)
const
421 if(spectrum_a_index > spectrum_b_index)
422 std::swap(spectrum_a_index, spectrum_b_index);
424 std::size_t count_target = 0;
430 qDebug() <<
"node_index=" << node_index;
440 QObject::tr(
"spectrum_index %1 out of range (spectrum_index max size=%2)")
441 .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...
std::vector< MapSimilarityCountElement > map_id_count
std::vector< std::size_t > aboveThreshold
std::vector< std::size_t > keys