OpenMS
2.7.0
|
Represents a set of weights (double values and scaled with a certain precision their integer counterparts) with a quick access. More...
#include <OpenMS/CHEMISTRY/MASSDECOMPOSITION/IMS/Weights.h>
Public Types | |
typedef long unsigned int | weight_type |
Type of integer values to be used. More... | |
typedef double | alphabet_mass_type |
Type of double values to be used. More... | |
typedef std::vector< weight_type > | weights_type |
Type of container to store integer values. More... | |
typedef std::vector< alphabet_mass_type > | alphabet_masses_type |
Type of container to store double values. More... | |
typedef weights_type::size_type | size_type |
Type of container's size. More... | |
Public Member Functions | |
Weights () | |
Empty constructor. More... | |
Weights (const alphabet_masses_type &masses, alphabet_mass_type precision) | |
Weights (const Weights &other) | |
Weights & | operator= (const Weights &other) |
size_type | size () const |
weight_type | getWeight (size_type i) const |
void | setPrecision (alphabet_mass_type precision) |
alphabet_mass_type | getPrecision () const |
weight_type | operator[] (size_type i) const |
weight_type | back () const |
alphabet_mass_type | getAlphabetMass (size_type i) const |
alphabet_mass_type | getParentMass (const std::vector< unsigned int > &decomposition) const |
void | swap (size_type index1, size_type index2) |
bool | divideByGCD () |
alphabet_mass_type | getMinRoundingError () const |
alphabet_mass_type | getMaxRoundingError () const |
Private Attributes | |
alphabet_masses_type | alphabet_masses_ |
alphabet_mass_type | precision_ |
weights_type | weights_ |
Represents a set of weights (double values and scaled with a certain precision their integer counterparts) with a quick access.
Many algorithms can't work with real-valued alphabets and need integer weights. Those are usually obtained by dividing all alphabet masses by a "precision" parameter (0; 1) and rounding the result to integers. Class Weights
allows access to the scaled masses (the weights) and to the original masses as well. Weights are cached and will not be recalculated on access.
typedef double alphabet_mass_type |
Type of double values to be used.
typedef std::vector<alphabet_mass_type> alphabet_masses_type |
Type of container to store double values.
typedef weights_type::size_type size_type |
Type of container's size.
typedef long unsigned int weight_type |
Type of integer values to be used.
typedef std::vector<weight_type> weights_type |
Type of container to store integer values.
|
inline |
Empty constructor.
|
inline |
Constructor with double values and precision.
masses | Original double values to be scaled. |
precision | Precision to scale double values. |
|
inline |
Gets a last weight.
bool divideByGCD | ( | ) |
Divides the integer weights by their gcd. The precision is also adjusted.
For example, given alphabet weights 3.0, 5.0, 8.0 with precision 0.1, the integer weights would be 30, 50, 80. After calling this method, the new weights are 3, 5, 8 with precision 1.0 (since the gcd of 30, 50, and 80 is 10).
|
inline |
Gets an original (double) alphabet mass by index.
i | An index to access alphabet masses. |
alphabet_mass_type getMaxRoundingError | ( | ) | const |
alphabet_mass_type getMinRoundingError | ( | ) | const |
alphabet_mass_type getParentMass | ( | const std::vector< unsigned int > & | decomposition | ) | const |
Returns a parent mass for a given decomposition
|
inline |
Gets precision.
|
inline |
Gets a scaled integer weight by index.
i | An index to access weights. |
Referenced by IntegerMassDecomposer< ValueType, DecompositionValueType >::fillExtendedResidueTable_(), and IntegerMassDecomposer< ValueType, DecompositionValueType >::IntegerMassDecomposer().
|
inline |
Operator to access weights by index.
i | An index to access weights. |
void setPrecision | ( | alphabet_mass_type | precision | ) |
Sets a new precision to scale double values to integer.
precision | A new precision. |
|
inline |
Gets size of a set of weights.
Referenced by IntegerMassDecomposer< ValueType, DecompositionValueType >::fillExtendedResidueTable_(), and IntegerMassDecomposer< ValueType, DecompositionValueType >::IntegerMassDecomposer().
Exchanges weight and mass at index1 with weight and mass at index2.
index1 | Index of weight and mass to be exchanged. |
index2 | Index of weight and mass to be exchanged. |
|
private |
Container to store original (double) alphabet masses.
|
private |
Precision which is used to scale double values to integer.
|
private |
Container to store scaled integer weights.