libpappsomspp
Library for mass spectrometry
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< BucketasSortedList () 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, Bucketm_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
spectraan array of Spectrum
Returns
a map of integers to buckets

Definition at line 60 of file bucketclustering.cpp.

61{
62}

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_cartto add in the bucket list

Definition at line 79 of file bucketclustering.cpp.

80{
81 // qDebug() << " " << m_bucketMap.size();
83 for(std::size_t mass : spectrum_int.getItemList())
84 {
85 std::pair<std::map<std::size_t, Bucket>::iterator, bool> ret;
86 ret = m_bucketMap.insert(std::pair<std::size_t, Bucket>(mass, Bucket(mass)));
87 if(ret.second == false)
88 {
89 }
90 else
91 {
92 }
93
94 ret.first->second.push_back(spectrum_int.getId());
95 }
96
97 // Param.defineHighestMassValue(max_mass);
98 // return clusters;
99}
std::map< std::size_t, Bucket > m_bucketMap

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.

102{
103 qDebug() << " " << m_bucketMap.size();
104 if(m_bucketMap.size() == 0)
105 {
106 throw pappso::PappsoException(QObject::tr("bucket map is empty"));
107 }
108 std::vector<Bucket> bucketList;
109 bucketList.reserve(m_bucketMap.size());
110
111
112 for(auto &&map_pair : m_bucketMap)
113 {
114 if(map_pair.second.size() > 1)
115 bucketList.push_back(map_pair.second);
116 }
117 // m_bucketMap.clear();
118
119 std::sort(bucketList.begin(), bucketList.end());
120
121 qDebug() << " " << m_bucketMap.size();
122 return bucketList;
123}

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.

73{
74 return m_itemCartCount;
75}

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_beginspectrum index defining the starting boundary
spectrum_idx_endspectrum index defining the ending boundary

Definition at line 126 of file bucketclustering.cpp.

128{
129
130 qDebug() << "spectrum_idx_begin=" << spectrum_idx_begin
131 << " spectrum_idx_end=" << spectrum_idx_end;
132 erase_if(m_bucketMap, [spectrum_idx_begin, spectrum_idx_end](const auto &item) {
133 return ((item.second.front() >= spectrum_idx_begin) &&
134 (item.second.back() <= spectrum_idx_end));
135 });
136}
void erase_if(std::map< K, T, C, A > &c, Predicate pred)

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.

66{
67 return m_bucketMap.size();
68}

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: