Loading...
Searching...
No Matches
pappso::spectree::BucketClustering Class Reference

`#include <bucketclustering.h>`

## Public Member Functions

| BucketClustering ()
void | addItemCart (const ItemCart &item_cart)
| add ItemCart to Bucket list Each item in the cart is a key to build dedicated buckets for one item The buckets will then reference the carts that contains one item
std::size_t | getItemCartCount () const
std::vector< Bucket > | asSortedList () const
std::size_t | size () const
void | removeBucketsWithinCartIdRange (std::size_t spectrum_idx_begin, std::size_t spectrum_idx_end)
| removes buckets only showing intra relations in the spectrum index range

## Private Attributes

std::map< std::size_t, Bucket > | m_bucketMap
std::size_t | m_itemCartCount = 0

## Detailed Description

Definition at line 55 of file bucketclustering.h.

## Constructor & Destructor Documentation

## BucketClustering()

pappso::spectree::BucketClustering::BucketClustering | ( |  | ) |

Initializes and fill the map collection containing the buckets and their content (spectra identifiers). The spectra identifiers and masses sets are read from Spectrum objects.

Parameters

  spectra | an array of Spectrum

Returns
  a map of integers to buckets

Definition at line 60 of file bucketclustering.cpp.

{
}

## Member Function Documentation

## addItemCart()

void pappso::spectree::BucketClustering::addItemCart | ( | const ItemCart & | item_cart | ) |

add ItemCart to Bucket list Each item in the cart is a key to build dedicated buckets for one item The buckets will then reference the carts that contains one item

Parameters

  item_cart | to add in the bucket list

Definition at line 79 of file bucketclustering.cpp.

{
// qDebug() << " " << m_bucketMap.size();
m_itemCartCount++;
for(std::size_t mass : spectrum_int.getItemList())
{
std::pair<std::map<std::size_t, Bucket>::iterator, bool> ret;
ret = m_bucketMap.insert(std::pair<std::size_t, Bucket>(mass, Bucket(mass)));
if(ret.second == false)
{
}
else
{
}
ret.first->second.push_back(spectrum_int.getId());
}
// Param.defineHighestMassValue(max_mass);
// return clusters;
}
pappso::spectree::BucketClustering::m_itemCartCount
std::size_t m_itemCartCount
Definition bucketclustering.h:121
pappso::spectree::BucketClustering::m_bucketMap
std::map< std::size_t, Bucket > m_bucketMap
Definition bucketclustering.h:119

References pappso::spectree::ItemCart::getId(), pappso::spectree::ItemCart::getItemList(), m_bucketMap, and m_itemCartCount.

## asSortedList()

std::vector< Bucket > pappso::spectree::BucketClustering::asSortedList | ( |  | ) | const

Iterate the buckets present in the map collection and store them into a raw array of buckets lexicographically sorted based on the buckets content. Erase the map representation afterwards to spare memory.

Returns
  an array of buckets

Since
  0.1

Definition at line 101 of file bucketclustering.cpp.

{
qDebug() << " " << m_bucketMap.size();
if(m_bucketMap.size() == 0)
{
throw pappso::PappsoException(QObject::tr("bucket map is empty"));
}
std::vector<Bucket> bucketList;
bucketList.reserve(m_bucketMap.size());
for(auto &&map_pair : m_bucketMap)
{
if(map_pair.second.size() > 1)
bucketList.push_back(map_pair.second);
}
// m_bucketMap.clear();
std::sort(bucketList.begin(), bucketList.end());
qDebug() << " " << m_bucketMap.size();
return bucketList;
}

References m_bucketMap.

Referenced by pappso::spectree::SpecTree::SpecTree().

## getItemCartCount()

std::size_t pappso::spectree::BucketClustering::getItemCartCount | ( |  | ) | const

Definition at line 72 of file bucketclustering.cpp.

{
return m_itemCartCount;
}

References m_itemCartCount.

Referenced by pappso::spectree::SpecTree::SpecTree().

## removeBucketsWithinCartIdRange()

void pappso::spectree::BucketClustering::removeBucketsWithinCartIdRange | ( | std::size_t | spectrum_idx_begin,
|  | std::size_t | spectrum_idx_end )

removes buckets only showing intra relations in the spectrum index range

removes buckets if their relationships implies only spectrum within the range of index given as arguments

Remarks
  as spectrum index are sorted in buckets, boundaries are easy to check

Parameters

  spectrum_idx_begin | spectrum index defining the starting boundary
  spectrum_idx_end | spectrum index defining the ending boundary

Definition at line 126 of file bucketclustering.cpp.

{
qDebug() << "spectrum_idx_begin=" << spectrum_idx_begin
<< " spectrum_idx_end=" << spectrum_idx_end;
erase_if(m_bucketMap, [spectrum_idx_begin, spectrum_idx_end](const auto &item) {
return ((item.second.front() >= spectrum_idx_begin) &&
(item.second.back() <= spectrum_idx_end));
});
}
pappso::spectree::erase_if
void erase_if(std::map< K, T, C, A > &c, Predicate pred)
Definition bucketclustering.cpp:51

References pappso::spectree::erase_if(), and m_bucketMap.

## size()

std::size_t pappso::spectree::BucketClustering::size | ( |  | ) | const

Provides access to the number of buckets present in the collection.

Returns
  The size of the collection

Since
  0.1

Definition at line 65 of file bucketclustering.cpp.

{
return m_bucketMap.size();
}

References m_bucketMap.

## Member Data Documentation

## m_bucketMap

std::map<std::size_t, Bucket> pappso::spectree::BucketClustering::m_bucketMap

private

Map of the mass value to the bucket representing this mass value. This representation is mainly used to fill the data and is then stored into a raw array and disposed.

Since
  0.1

Definition at line 119 of file bucketclustering.h.

Referenced by addItemCart(), asSortedList(), removeBucketsWithinCartIdRange(), and size().

## m_itemCartCount

std::size_t pappso::spectree::BucketClustering::m_itemCartCount = 0

private

Definition at line 121 of file bucketclustering.h.

Referenced by addItemCart(), and getItemCartCount().

The documentation for this class was generated from the following files:

- pappsomspp/core/processing/spectree/bucketclustering.h
- pappsomspp/core/processing/spectree/bucketclustering.cpp