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 =
87 m_bucketMap.insert(std::pair<std::size_t, Bucket>(mass, Bucket(mass)));
88 if(ret.second == false)
89 {
90 }
91 else
92 {
93 }
94
95 ret.first->second.push_back(spectrum_int.getId());
96 }
97
98 // Param.defineHighestMassValue(max_mass);
99 // return clusters;
100}
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 102 of file bucketclustering.cpp.

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

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 127 of file bucketclustering.cpp.

129{
130
131 qDebug() << "spectrum_idx_begin=" << spectrum_idx_begin
132 << " spectrum_idx_end=" << spectrum_idx_end;
134 [spectrum_idx_begin, spectrum_idx_end](const auto &item) {
135 return ((item.second.front() >= spectrum_idx_begin) &&
136 (item.second.back() <= spectrum_idx_end));
137 });
138}
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: